summaryrefslogtreecommitdiff
path: root/contrib/cirrus/win-installer-main.ps1
blob: 64a94ee639b25a162a3b1fd9c230474174f343c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 # Powershell doesn't exit after
 function CheckExit {
    if ($LASTEXITCODE -ne 0) {
        Exit $LASTEXITCODE
    }
}
function DownloadFile {
    param(
        [Parameter(Mandatory)]
        [string]$url,
        [Parameter(Mandatory)]
        [string]$file,
        [Int]$retries=5,
        [Int]$delay=8
    )
    $ProgressPreference = 'SilentlyContinue';
    Write-Host "Downloading $url to $file"
    For($i = 0;;) {
        Try {
            Invoke-WebRequest -UseBasicParsing -ErrorAction Stop -Uri $url -OutFile $file
            Break
        } Catch {
            if (++$i -gt $retries) {
                throw $_.Exception
            }
            Write-Host "Download failed - retrying:" $_.Exception.Response.StatusCode
            Start-Sleep -Seconds $delay
        }
    }
}
# Drop global envs which have unix paths, defaults are fine
Remove-Item Env:\GOPATH
Remove-Item Env:\GOSRC
Remove-Item Env:\GOCACHE

Set-Location contrib\win-installer

# Download and extract alt_build win release zip
$url = "${ENV:ART_URL}/Windows Cross/repo/repo.tbz"
# Arc requires extension to be "tbz2"
DownloadFile "$url" "repo.tbz2"
arc unarchive repo.tbz2 .; CheckExit

# Build Installer
.\build.ps1 $Env:WIN_INST_VER dev repo; CheckExit

# Run the installer silently and WSL install option disabled (prevent reboots, wsl requirements)
# We need AllowOldWin=1 for server 2019 (cirrus image), can be dropped after server 2022
$ret = Start-Process -Wait -PassThru ".\podman-${ENV:WIN_INST_VER}-dev-setup.exe" -ArgumentList "/install /quiet WSLCheckbox=0 AllowOldWin=1 /log inst.log"
if ($ret.ExitCode -ne 0) {
    Write-Host "Install failed, dumping log"
    Get-Content inst.log
    Exit $ret.ExitCode
}
if (! ((Test-Path -Path "C:\Program Files\RedHat\Podman\podman.exe") -and `
       (Test-Path -Path "C:\Program Files\RedHat\Podman\win-sshproxy.exe"))) {
    Write-Host "Expected podman.exe and win-sshproxy.exe, one or both not present after install"
    Exit 1
}
Write-Host "Installer verification successful!"