@@ -77,9 +77,12 @@ mkdirp "bin"
7777 Write-Host $_.file
7878 }
7979
80- if ($_ | Get-Member prebuild) {
81- $0 = $outfile
82- Invoke-Expression $_.prebuild
80+ if ($_ | Get-Member dirName) {
81+ $strip = 0 ;
82+ if ($_ | Get-Member extractStrip) { $strip = $_.extractStrip }
83+
84+ mkdirp " build\$ ( $_.dirName ) " - clean
85+ exec { tar - xf $outfile - C " build\$ ( $_.dirName ) " -- strip- components $strip }
8386 }
8487}
8588
@@ -125,6 +128,13 @@ if (-not (Test-Path build\NSIS)) {
125128 Expand-Archive ' .\downloads\nsis-log.zip' - DestinationPath ' .\build\NSIS' - Force
126129}
127130
131+ function sign {
132+ param ([string []] $filesToSign )
133+
134+ $cert = Get-ChildItem - Path Cert:\CurrentUser\My - CodeSigningCert | Where-Object { $_.Subject -like " CN=Raspberry Pi*" }
135+ $filesToSign | Set-AuthenticodeSignature - Certificate $cert - TimestampServer " http://timestamp.digicert.com" - HashAlgorithm SHA256
136+ }
137+
128138function msys {
129139 param ([string ] $cmd )
130140
@@ -366,9 +376,9 @@ Section "$($_.name)" Sec$($_.shortName)
366376"@
367377 })
368378
369- $ ( if ($_ | Get-Member copy ) {
370- " SetOutPath '`$ INSTDIR\$ ( $_.copy ) '`r`n "
371- " File /r build\$ ( $_.copy ) \*.*"
379+ $ ( if ($_ | Get-Member dirName ) {
380+ " SetOutPath '`$ INSTDIR\$ ( $_.dirName ) '`r`n "
381+ " File /r build\$ ( $_.dirName ) \*.*"
372382 })
373383
374384SectionEnd
@@ -484,9 +494,19 @@ $env:__COMPAT_LAYER = "RunAsInvoker"
484494exec { Start-Process - FilePath " .\build\build-uninstaller-$suffix .exe" - ArgumentList " /S /D=$PSScriptRoot \build" - Wait }
485495$env: __COMPAT_LAYER = " "
486496
497+ # Sign files before packaging up the installer
498+ sign " build\uninstall-$suffix .exe" ,
499+ " build\openocd-install\mingw$bitness \bin\openocd.exe" ,
500+ " build\pico-sdk-tools\mingw$bitness \elf2uf2.exe" ,
501+ " build\pico-sdk-tools\mingw$bitness \pioasm.exe" ,
502+ " build\picotool-install\mingw$bitness \picotool.exe"
503+
487504exec { .\build\NSIS\makensis " .\$basename -$suffix .nsi" }
488505Write-Host " Installer saved to $binfile "
489506
507+ # Sign the installer
508+ sign $binfile
509+
490510# Package OpenOCD separately as well
491511
492512$version = (cmd / c " .\build\openocd-install\mingw$bitness \bin\openocd.exe" -- version ' 2>&1' )[0 ]
0 commit comments