forked from Icinga/icinga2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
win-dev.ps1
97 lines (75 loc) · 2.52 KB
/
win-dev.ps1
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Set-PSDebug -Trace 1
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
function ThrowOnNativeFailure {
if (-not $?) {
throw 'Native failure'
}
}
$VsVersion = 2019
$MsvcVersion = '14.2'
$BoostVersion = @(1, 79, 0)
$OpensslVersion = '1_1_1q'
switch ($Env:BITS) {
32 { }
64 { }
default {
$Env:BITS = 64
}
}
function Install-Exe {
param (
[string]$Url,
[string]$Dir
)
$TempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().Guid)
$ExeFile = Join-Path $TempDir inst.exe
New-Item -ItemType Directory -Path $TempDir
for ($trial = 1;; ++$trial) {
try {
Invoke-WebRequest -Uri $Url -OutFile $ExeFile -UseBasicParsing
} catch {
if ($trial -ge 2) {
throw
}
continue
}
break
}
Start-Process -Wait -FilePath $ExeFile -ArgumentList @('/VERYSILENT', '/INSTALL', '/PASSIVE', '/NORESTART', "/DIR=${Dir}")
ThrowOnNativeFailure
Remove-Item -Recurse -Path $TempDir
}
try {
Get-Command choco
} catch {
Invoke-Expression (New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')
ThrowOnNativeFailure
$RegEnv = 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
$ChocoPath = ";$(Join-Path $Env:AllUsersProfile chocolatey\bin)"
Set-ItemProperty -Path $RegEnv -Name Path -Value ((Get-ItemProperty -Path $RegEnv -Name Path).Path + $ChocoPath)
$Env:Path += $ChocoPath
}
# GitHub Actions uses an image that comes with most dependencies preinstalled. Don't install them twice.
if (-not $Env:GITHUB_ACTIONS) {
choco install -y `
"visualstudio${VsVersion}community" `
"visualstudio${VsVersion}-workload-netcoretools" `
"visualstudio${VsVersion}-workload-vctools" `
"visualstudio${VsVersion}-workload-manageddesktop" `
"visualstudio${VsVersion}-workload-nativedesktop" `
"visualstudio${VsVersion}-workload-universal" `
"visualstudio${VsVersion}buildtools" `
git `
cmake `
winflexbison3 `
windows-sdk-8.1 `
wixtoolset
ThrowOnNativeFailure
} else {
choco install -y winflexbison3
ThrowOnNativeFailure
}
Install-Exe -Url "https://packages.icinga.com/windows/dependencies/boost_$($BoostVersion -join '_')-msvc-${MsvcVersion}-${Env:BITS}.exe" -Dir "C:\local\boost_$($BoostVersion -join '_')-Win${Env:BITS}"
Install-Exe -Url "https://packages.icinga.com/windows/dependencies/Win${Env:BITS}OpenSSL-${OpensslVersion}.exe" -Dir "C:\local\OpenSSL_${OpensslVersion}-Win${Env:BITS}"