-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild-installer.ps1
More file actions
294 lines (265 loc) · 10.6 KB
/
Copy pathbuild-installer.ps1
File metadata and controls
294 lines (265 loc) · 10.6 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
[CmdletBinding()]
param (
[Parameter()]
[string]$Target = "Rebuild",
[Parameter(Mandatory)]
[ValidateSet("Debug", "Release")]
[string]$Configuration,
[Parameter(Mandatory)]
[ValidateSet("x86", "x64")]
[string]$Platform,
[Parameter()]
[string]$OutDir = "$PSScriptRoot\output",
[Parameter()]
[switch]$ExportCertificate,
[Parameter()]
[switch]$ExportSymbols,
[Parameter()]
[switch]$ExportExtras,
[Parameter()]
[string]$ReleaseTag,
[Parameter()]
[switch]$NoBuild,
[Parameter()]
[switch]$Sbom,
[Parameter()]
[switch]$Zip,
[Parameter()]
[switch]$Iso
)
$ErrorActionPreference = "Stop"
. $PSScriptRoot\branding.ps1
. $PSScriptRoot\scripts\branding-generic.ps1
. $PSScriptRoot\scripts\sign.ps1
if (!$NoBuild) {
msbuild.exe `
"$PSScriptRoot\installer\installer.slnx" `
/t:XenDrivers:$Target `
/restore `
/p:Configuration=$Configuration `
/p:Platform=$Platform
if ($LASTEXITCODE -ne 0) {
throw "MSBuild failed with error $LASTEXITCODE"
}
}
if ([string]::IsNullOrEmpty($ReleaseTag)) {
$ReleaseTag = "xcpng-winpv-$(Get-PackageVersion Product)-$Configuration-$Platform"
}
if ($Env:GITHUB_ACTIONS) {
Add-Content -Path $Env:GITHUB_OUTPUT -Value "ReleaseTag=$ReleaseTag" -Force
Add-Content -Path $Env:GITHUB_STEP_SUMMARY -Value "ReleaseTag: ``$ReleaseTag``" -Force
}
$VersionDir = "$OutDir\$ReleaseTag"
Remove-Item -Path $VersionDir -Force -Recurse -ErrorAction SilentlyContinue
if ($Target -ine "Clean") {
$PackageDir = "$VersionDir\package"
New-Item -Path $PackageDir -ItemType Directory -Force
Copy-Item `
-Path "$PSScriptRoot\installer\bin\$Platform\$Configuration\en-US\*" `
-Exclude *.wixpdb `
-Destination $PackageDir\ `
-Force
# XenClean
$XenCleanDir = "$PackageDir\XenClean"
New-Item -Path $XenCleanDir -ItemType Directory -Force
Copy-Item `
-Path "$PSScriptRoot\XenClean\bin\$Platform\$Configuration\net462\*" `
-Include *.exe `
-Destination $XenCleanDir\ `
-Force
# XenBootFix
$XenBootFixDir = "$PackageDir\XenBootFix"
New-Item -Path $XenBootFixDir -ItemType Directory -Force
Copy-Item `
-Path "$PSScriptRoot\XenBootFix\$Platform\$Configuration\*" `
-Include *.exe `
-Destination $XenBootFixDir\ `
-Force
if ($Sbom) {
& "$PSScriptRoot\scripts\Build-DriverSbom.ps1" -Configuration $Configuration -Platform $Platform
Get-ChildItem -Directory -Filter _manifest -Recurse $PSScriptRoot\installer\driver-bins\ | ForEach-Object {
$Driver = $($_.Parent.Name)
$_ | Copy-Item -Destination $VersionDir\sbom\$Driver -Recurse
}
New-Item -Path $VersionDir\sbom\XenDriverUtils -ItemType Directory -Force
sbom.exe generate `
-b $PSScriptRoot\XenDriverUtils\bin\$Platform\$Configuration\net462 `
-bc $PSScriptRoot\XenDriverUtils `
-m $VersionDir\sbom\XenDriverUtils `
-D true `
-ps $Env:VENDOR_NAME `
-pn XenDriverUtils `
-pv (Get-PackageVersion Product)
if ($LASTEXITCODE -ne 0) {
throw "sbom-tool for XenDriverUtils failed with error $LASTEXITCODE"
}
New-Item -Path $VersionDir\sbom\XenClean -ItemType Directory -Force
sbom.exe generate `
-b $PSScriptRoot\XenClean\bin\$Platform\$Configuration\net462 `
-bc $PSScriptRoot\XenClean `
-m $VersionDir\sbom\XenClean `
-D true `
-ps $Env:VENDOR_NAME `
-pn XenClean `
-pv (Get-PackageVersion XenClean)
if ($LASTEXITCODE -ne 0) {
throw "sbom-tool for XenClean failed with error $LASTEXITCODE"
}
New-Item -Path $VersionDir\sbom\XenBootFix -ItemType Directory -Force
sbom.exe generate `
-b $PSScriptRoot\XenBootFix\$Platform\$Configuration `
-bc $PSScriptRoot\XenBootFix `
-m $VersionDir\sbom\XenBootFix `
-D true `
-ps $Env:VENDOR_NAME `
-pn XenBootFix `
-pv (Get-PackageVersion XenBootFix)
if ($LASTEXITCODE -ne 0) {
throw "sbom-tool for XenBootFix failed with error $LASTEXITCODE"
}
New-Item -Path $VersionDir\sbom\xenplus -ItemType Directory -Force
sbom.exe generate `
-b $PSScriptRoot\xenplus\bin\publish\$Platform\$Configuration `
-bc $PSScriptRoot\xenplus `
-m $VersionDir\sbom\xenplus `
-D true `
-ps $Env:VENDOR_NAME `
-pn xenplus `
-pv (Get-PackageVersion xenplus)
if ($LASTEXITCODE -ne 0) {
throw "sbom-tool for xenplus failed with error $LASTEXITCODE"
}
New-Item -Path $VersionDir\sbom\xentimeprovider -ItemType Directory -Force
sbom.exe generate `
-b $PSScriptRoot\xentimeprovider\$Platform\$Configuration `
-bc $PSScriptRoot\xentimeprovider `
-m $VersionDir\sbom\xentimeprovider `
-D true `
-ps $Env:VENDOR_NAME `
-pn xentimeprovider `
-pv (Get-PackageVersion XenTimeProvider)
if ($LASTEXITCODE -ne 0) {
throw "sbom-tool for xentimeprovider failed with error $LASTEXITCODE"
}
New-Item -Path $VersionDir\sbom\xstdvga -ItemType Directory -Force
sbom.exe generate `
-b $PSScriptRoot\xstdvga\vs2022\$Platform\$Configuration\xstdvga `
-bc $PSScriptRoot\xstdvga\vs2022 `
-m $VersionDir\sbom\xstdvga `
-D true `
-ps $Env:VENDOR_NAME `
-pn xstdvga `
-pv (Get-PackageVersion xstdvga)
if ($LASTEXITCODE -ne 0) {
throw "sbom-tool for xstdvga failed with error $LASTEXITCODE"
}
New-Item -Path $VersionDir\sbom\DriverInstallCustomAction -ItemType Directory -Force
sbom.exe generate `
-b $PSScriptRoot\DriverInstallCustomAction\bin\$Platform\$Configuration\net462 `
-bc $PSScriptRoot\DriverInstallCustomAction `
-m $VersionDir\sbom\DriverInstallCustomAction `
-D true `
-ps $Env:VENDOR_NAME `
-pn DriverInstallerCustomAction `
-pv (Get-PackageVersion Product)
if ($LASTEXITCODE -ne 0) {
throw "sbom-tool for DriverInstallCustomAction failed with error $LASTEXITCODE"
}
New-Item -Path $VersionDir\sbom\win-pv-drivers-installer -ItemType Directory -Force
sbom.exe generate `
-b $PSScriptRoot\installer\bin\$Platform\$Configuration\en-US `
-bc $PSScriptRoot\installer\ `
-m $VersionDir\sbom\win-pv-drivers-installer `
-D true `
-ps $Env:VENDOR_NAME `
-pn win-pv-drivers-installer `
-pv (Get-PackageVersion Product)
if ($LASTEXITCODE -ne 0) {
throw "sbom-tool for win-pv-drivers-installer failed with error $LASTEXITCODE"
}
}
if ($ExportExtras) {
$ExtrasDir = "$VersionDir\extras"
New-Item -Path $ExtrasDir -ItemType Directory -Force
Copy-Item -Path "$PSScriptRoot\extras\*" -Destination $ExtrasDir\ -Force
}
if ($ExportCertificate) {
$TestsignDir = "$VersionDir\testsign"
New-Item -Path $TestsignDir -ItemType Directory -Force
Copy-Item -Path "$PSScriptRoot\testsign\install.ps1" -Destination $TestsignDir\ -Force
Export-SignerCertificate -OutDir $TestsignDir
}
if ($ExportSymbols) {
$SymbolDir = "$VersionDir\symbols"
New-Item -Path $SymbolDir -ItemType Directory -Force
Copy-Item `
-Path "$PSScriptRoot\installer\bin\$Platform\$Configuration\en-US\*" `
-Filter *.wixpdb `
-Destination $SymbolDir\ `
-Force
$DriversSymbolDir = "$VersionDir\symbols\drivers"
New-Item -Path $DriversSymbolDir -ItemType Directory -Force
Copy-Item `
-Path "$PSScriptRoot\installer\driver-bins\$Platform\$Configuration\*\*" `
-Filter *.pdb `
-Destination $DriversSymbolDir\ `
-Force
$XenCleanSymbolDir = "$SymbolDir\XenClean"
New-Item -Path $XenCleanSymbolDir -ItemType Directory -Force
Copy-Item `
-Path "$PSScriptRoot\XenClean\bin\$Platform\$Configuration\net462\*" `
-Filter *.pdb `
-Destination $XenCleanSymbolDir\ `
-Force
$XenBootFixSymbolDir = "$SymbolDir\XenBootFix"
New-Item -Path $XenBootFixSymbolDir -ItemType Directory -Force
Copy-Item `
-Path "$PSScriptRoot\XenBootFix\$Platform\$Configuration\*" `
-Include *.pdb `
-Destination $XenBootFixSymbolDir\ `
-Force
$XenplusSymbolDir = "$SymbolDir\xenplus"
New-Item -Path $XenplusSymbolDir -ItemType Directory -Force
Copy-Item `
-Path "$PSScriptRoot\xenplus\bin\publish\$Platform\$Configuration\*" `
-Include *.pdb `
-Destination $XenplusSymbolDir\ `
-Force
$XenTimeProviderSymbolDir = "$SymbolDir\xentimeprovider"
New-Item -Path $XenTimeProviderSymbolDir -ItemType Directory -Force
Copy-Item `
-Path "$PSScriptRoot\xentimeprovider\$Platform\$Configuration\*" `
-Include *.pdb `
-Destination $XenTimeProviderSymbolDir\ `
-Force
$XstdvgaSymbolDir = "$SymbolDir\xstdvga"
New-Item -Path $XstdvgaSymbolDir -ItemType Directory -Force
Copy-Item `
-Path "$PSScriptRoot\xstdvga\vs2022\$Platform\$Configuration\xstdvga\*" `
-Include *.pdb `
-Destination $XstdvgaSymbolDir\ `
-Force
}
if ($Zip) {
# Compress-Archive (and .NET zip support in general) has a bug that causes path separators to be non-compliant:
# https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/mitigation-ziparchiveentry-fullname-path-separator
# So use Windows's bsdtar instead.
$tar = Join-Path ([System.Environment]::SystemDirectory) "tar.exe"
Push-Location $OutDir
try {
& $tar --format zip -cf "$OutDir\$ReleaseTag.zip" $ReleaseTag
if ($LASTEXITCODE -ne 0) {
throw "tar failed with error $LASTEXITCODE"
}
}
finally {
Pop-Location
}
}
if ($Iso) {
& "$PSScriptRoot\scripts\New-IsoImage.ps1" `
-Path $VersionDir `
-ImageFilePath "$OutDir\$ReleaseTag.iso" `
-VolumeLabel $ReleaseTag
}
}