podman
171 строка · 4.8 Кб
1function ExitOnError() {
2if ($LASTEXITCODE -ne 0) {
3Exit 1
4}
5}
6
7function FetchPanel() {
8Remove-Item -Recurse -Force -Path fetch -ErrorAction SilentlyContinue | Out-Null
9New-Item -Force -ItemType Directory fetch | Out-Null
10Push-Location fetch
11
12$ProgressPreference = 'SilentlyContinue'
13Invoke-WebRequest -UseBasicParsing -OutFile nuget.exe -ErrorAction Stop `
14-Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
15# 3.3.3.224 generates invalid schema with RemoveFeature defaults.
16# Lock the version to 211 until this issue is fixed (7/18/2023)
17.\nuget.exe install PanelSwWixExtension -Version 3.3.3.211
18$code = $LASTEXITCODE
19Pop-Location
20if ($code -gt 0) {
21Exit 1
22}
23$loc = Get-ChildItem -Recurse -Path fetch -Name PanelSwWixExtension.dll
24if (!$loc) {
25Write-Host "Could not locate PanelSwWixExtension.dll"
26Exit 1
27}
28
29Copy-Item -Path fetch/$loc -Destination artifacts/PanelSwWixExtension.dll -ErrorAction Stop
30}
31
32function SignItem() {
33param(
34[Parameter(Mandatory)]
35[string[]]$fileNames
36)
37
38foreach ($val in $ENV:APP_ID, $ENV:TENANT_ID, $ENV:CLIENT_SECRET, $ENV:CERT_NAME) {
39if (!$val) {
40Write-Host "Skipping signing (no config)"
41Return
42}
43}
44
45CheckCommand AzureSignTool.exe "AzureSignTool"
46
47AzureSignTool.exe sign -du "https://github.com/containers/podman" `
48-kvu "https://$ENV:VAULT_ID.vault.azure.net" `
49-kvi $ENV:APP_ID `
50-kvt $ENV:TENANT_ID `
51-kvs $ENV:CLIENT_SECRET `
52-kvc $ENV:CERT_NAME `
53-tr http://timestamp.digicert.com $fileNames
54
55ExitOnError
56}
57
58function CheckCommand() {
59param(
60[Parameter(Mandatory)]
61[string] $cmd,
62[Parameter(Mandatory)]
63[string] $description
64)
65
66if (! (Get-Command $cmd -errorAction SilentlyContinue)) {
67Write-Host "Required dep `"$description`" is not installed"
68Exit 1
69}
70}
71
72function CheckRequirements() {
73CheckCommand "gcc" "MingW CC"
74CheckCommand "candle" "WiX Toolset"
75CheckCommand "go" "Golang"
76}
77
78
79if ($args.Count -lt 1 -or $args[0].Length -lt 1) {
80Write-Host "Usage: " $MyInvocation.MyCommand.Name "<version> [dev|prod] [release_dir]"
81Write-Host
82Write-Host 'Uses Env Vars: '
83Write-Host ' $ENV:FETCH_BASE_URL - GitHub Repo Address to locate release on'
84Write-Host 'Env Settings for signing (optional)'
85Write-Host ' $ENV:VAULT_ID'
86Write-Host ' $ENV:APP_ID'
87Write-Host ' $ENV:TENANT_ID'
88Write-Host ' $ENV:CLIENT_SECRET'
89Write-Host ' $ENV:CERT_NAME'
90Write-Host
91Write-Host "Example: Download and build from the official Github release (dev output): "
92Write-Host " .\build.ps1 4.2.0"
93Write-Host
94Write-Host "Example: Build a dev build from a pre-download release "
95Write-Host " .\build.ps1 4.2.0 dev fetchdir"
96Write-Host
97
98Exit 1
99}
100
101# Pre-set to standard locations in-case build env does not refresh paths
102$Env:Path="$Env:Path;C:\Program Files (x86)\WiX Toolset v3.14\bin;C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin;;C:\Program Files\Go\bin"
103
104CheckRequirements
105
106$version = $args[0]
107
108if ($version[0] -eq "v") {
109$version = $version.Substring(1)
110}
111
112$suffix = "-dev"
113if ($args.Count -gt 1 -and $args[1] -eq "prod") {
114$suffix = ""
115}
116
117$releaseDir = ""
118if ($args.Count -gt 2) {
119$releaseDir = $args[2]
120}
121
122.\process-release.ps1 $version $releaseDir
123if ($LASTEXITCODE -eq 2) {
124Write-Host "Skip signaled, relaying skip"
125Exit 2
126}
127if ($ENV:INSTVER -eq "") {
128Write-Host "process-release did not define an install version!"
129Exit 1
130}
131
132FetchPanel
133
134.\build-hooks.bat; ExitOnError
135SignItem @("artifacts/win-sshproxy.exe",
136"artifacts/podman.exe",
137"artifacts/podman-msihooks.dll",
138"artifacts/podman-wslkerninst.exe")
139$gvExists = Test-Path "artifacts/gvproxy.exe"
140if ($gvExists) {
141SignItem @("artifacts/gvproxy.exe")
142Remove-Item Env:\UseGVProxy -ErrorAction SilentlyContinue
143} else {
144$env:UseGVProxy = "Skip"
145}
146
147# Retaining for possible future additions
148# $pExists = Test-Path "artifacts/policy.json"
149# if ($pExists) {
150# Remove-Item Env:\IncludePolicyJSON -ErrorAction SilentlyContinue
151# } else {
152# $env:IncludePolicyJSON = "Skip"
153# }
154.\build-msi.bat $ENV:INSTVER; ExitOnError
155SignItem @("podman.msi")
156
157.\build-burn.bat $ENV:INSTVER; ExitOnError
158insignia -ib podman-setup.exe -o engine.exe; ExitOnError
159SignItem @("engine.exe")
160
161$file = "podman-$version$suffix-setup.exe"
162insignia -ab engine.exe podman-setup.exe -o $file; ExitOnError
163SignItem @("$file")
164
165if (Test-Path -Path shasums) {
166$hash = (Get-FileHash -Algorithm SHA256 $file).Hash.ToLower()
167Write-Output "$hash $file" | Out-File -Append -FilePath shasums
168}
169
170Write-Host "Complete"
171Get-ChildItem "podman-$version$suffix-setup.exe"
172