podman

Форк
0
171 строка · 4.8 Кб
1
function ExitOnError() {
2
    if ($LASTEXITCODE -ne 0) {
3
        Exit 1
4
    }
5
}
6

7
function FetchPanel() {
8
    Remove-Item -Recurse -Force -Path fetch -ErrorAction SilentlyContinue | Out-Null
9
    New-Item -Force -ItemType Directory fetch | Out-Null
10
    Push-Location fetch
11

12
    $ProgressPreference = 'SilentlyContinue'
13
    Invoke-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
19
    Pop-Location
20
    if ($code -gt 0) {
21
        Exit 1
22
    }
23
    $loc = Get-ChildItem -Recurse -Path fetch -Name PanelSwWixExtension.dll
24
    if (!$loc) {
25
        Write-Host "Could not locate PanelSwWixExtension.dll"
26
        Exit 1
27
    }
28

29
    Copy-Item -Path fetch/$loc -Destination artifacts/PanelSwWixExtension.dll -ErrorAction Stop
30
}
31

32
function SignItem() {
33
    param(
34
        [Parameter(Mandatory)]
35
        [string[]]$fileNames
36
    )
37

38
    foreach ($val in $ENV:APP_ID, $ENV:TENANT_ID, $ENV:CLIENT_SECRET, $ENV:CERT_NAME) {
39
        if (!$val) {
40
            Write-Host "Skipping signing (no config)"
41
            Return
42
        }
43
    }
44

45
    CheckCommand AzureSignTool.exe "AzureSignTool"
46

47
    AzureSignTool.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

55
    ExitOnError
56
}
57

58
function CheckCommand() {
59
    param(
60
        [Parameter(Mandatory)]
61
        [string] $cmd,
62
        [Parameter(Mandatory)]
63
        [string] $description
64
    )
65

66
    if (! (Get-Command $cmd -errorAction SilentlyContinue)) {
67
        Write-Host "Required dep `"$description`" is not installed"
68
        Exit 1
69
    }
70
}
71

72
function CheckRequirements() {
73
    CheckCommand "gcc" "MingW CC"
74
    CheckCommand "candle" "WiX Toolset"
75
    CheckCommand "go" "Golang"
76
}
77

78

79
if ($args.Count -lt 1 -or $args[0].Length -lt 1) {
80
    Write-Host "Usage: " $MyInvocation.MyCommand.Name "<version> [dev|prod] [release_dir]"
81
    Write-Host
82
    Write-Host 'Uses Env Vars: '
83
    Write-Host '   $ENV:FETCH_BASE_URL - GitHub Repo Address to locate release on'
84
    Write-Host 'Env Settings for signing (optional)'
85
    Write-Host '   $ENV:VAULT_ID'
86
    Write-Host '   $ENV:APP_ID'
87
    Write-Host '   $ENV:TENANT_ID'
88
    Write-Host '   $ENV:CLIENT_SECRET'
89
    Write-Host '   $ENV:CERT_NAME'
90
    Write-Host
91
    Write-Host "Example: Download and build from the official Github release (dev output): "
92
    Write-Host " .\build.ps1 4.2.0"
93
    Write-Host
94
    Write-Host "Example: Build a dev build from a pre-download release "
95
    Write-Host " .\build.ps1 4.2.0 dev fetchdir"
96
    Write-Host
97

98
    Exit 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

104
CheckRequirements
105

106
$version = $args[0]
107

108
if ($version[0] -eq "v") {
109
    $version = $version.Substring(1)
110
}
111

112
$suffix = "-dev"
113
if ($args.Count -gt 1 -and $args[1] -eq "prod") {
114
    $suffix = ""
115
}
116

117
$releaseDir = ""
118
if ($args.Count -gt 2) {
119
    $releaseDir = $args[2]
120
}
121

122
.\process-release.ps1 $version $releaseDir
123
if ($LASTEXITCODE -eq 2) {
124
    Write-Host "Skip signaled, relaying skip"
125
    Exit 2
126
}
127
if ($ENV:INSTVER -eq "") {
128
    Write-Host "process-release did not define an install version!"
129
    Exit 1
130
}
131

132
FetchPanel
133

134
.\build-hooks.bat; ExitOnError
135
SignItem @("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"
140
if ($gvExists) {
141
    SignItem @("artifacts/gvproxy.exe")
142
    Remove-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
155
SignItem @("podman.msi")
156

157
.\build-burn.bat $ENV:INSTVER; ExitOnError
158
insignia -ib podman-setup.exe -o engine.exe; ExitOnError
159
SignItem @("engine.exe")
160

161
$file = "podman-$version$suffix-setup.exe"
162
insignia -ab engine.exe podman-setup.exe -o $file; ExitOnError
163
SignItem @("$file")
164

165
if (Test-Path -Path shasums) {
166
    $hash = (Get-FileHash -Algorithm SHA256 $file).Hash.ToLower()
167
    Write-Output "$hash  $file" | Out-File -Append -FilePath shasums
168
}
169

170
Write-Host "Complete"
171
Get-ChildItem "podman-$version$suffix-setup.exe"
172

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.