Skip to content

Commit 6651207

Browse files
committed
release: make bootstrap and archive smoke reproducible
1 parent 0643a87 commit 6651207

6 files changed

Lines changed: 95 additions & 10 deletions

File tree

‎.github/workflows/devil-mutation.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ jobs:
2222
fetch-depth: 0
2323
- name: Install FPC 3.2.2 bootstrap
2424
shell: powershell
25-
run: choco install freepascal --version=3.2.2 -y --no-progress
25+
run: |
26+
.\scripts\Install-FpcBootstrap.ps1 `
27+
-Destination "$env:RUNNER_TEMP\fpc-3.2.2"
2628
- name: Create disposable mutation clone
2729
shell: powershell
2830
run: git clone --no-local . ..\mooncompiler-mutation
2931
- name: Measure Devil mutation strength
3032
shell: powershell
33+
env:
34+
MOONBOT_BOOTSTRAP_FPC: ${{ runner.temp }}\fpc-3.2.2\bin\i386-win32\fpc.exe
3135
run: |
3236
python .\qualification\suite\scripts\run_devil_mutation.py `
3337
--repo ..\mooncompiler-mutation `

‎.github/workflows/qualification.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ jobs:
9090
- uses: actions/checkout@v4
9191
- name: Install FPC 3.2.2 bootstrap
9292
shell: powershell
93-
run: choco install freepascal --version=3.2.2 -y --no-progress
93+
run: |
94+
.\scripts\Install-FpcBootstrap.ps1 `
95+
-Destination "$env:RUNNER_TEMP\fpc-3.2.2"
9496
- name: Build product toolchain
9597
shell: powershell
9698
run: |
9799
.\build.ps1 compiler `
98-
-Bootstrap C:\tools\freepascal\bin\i386-win32\fpc.exe
100+
-Bootstrap "$env:RUNNER_TEMP\fpc-3.2.2\bin\i386-win32\fpc.exe"
99101
- name: Run platform contracts
100102
shell: powershell
101103
run: |

‎.github/workflows/release.yml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ jobs:
8888
- uses: actions/checkout@v4
8989
- name: Install FPC 3.2.2 bootstrap
9090
shell: powershell
91-
run: choco install freepascal --version=3.2.2 -y --no-progress
91+
run: |
92+
.\scripts\Install-FpcBootstrap.ps1 `
93+
-Destination "$env:RUNNER_TEMP\fpc-3.2.2"
9294
- name: Build toolchain
9395
shell: powershell
9496
run: |
9597
.\build.ps1 compiler `
96-
-Bootstrap C:\tools\freepascal\bin\i386-win32\fpc.exe
98+
-Bootstrap "$env:RUNNER_TEMP\fpc-3.2.2\bin\i386-win32\fpc.exe"
9799
- name: Pack toolchain
98100
shell: powershell
99101
run: |
@@ -139,6 +141,7 @@ jobs:
139141
artifact-metadata: write
140142
env:
141143
GH_TOKEN: ${{ github.token }}
144+
GH_REPO: ${{ github.repository }}
142145
RELEASE_TAG: ${{ needs.validate-tag.outputs.tag }}
143146
RELEASE_VERSION: ${{ needs.validate-tag.outputs.version }}
144147
steps:

‎build‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ install_toolchain() {
162162
# Reject archive entries that could escape the transactional staging tree.
163163
while IFS= read -r member; do
164164
member=${member#./}
165-
[[ -z "$member" || "$member" == /* ||
165+
[[ -z "$member" ]] && continue
166+
[[ "$member" == /* ||
166167
"$member" == .. || "$member" == ../* || "$member" == */../* ||
167168
"$member" == */.. ]] && {
168169
echo "unsafe path in toolchain archive: $member" >&2

‎doc/SETUP.md‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,19 @@ If `fpc.exe` is already on `PATH`, `-Bootstrap` is unnecessary. If `make.exe`
7878
is installed separately, pass its path with `-Make` or the `MOONBOT_MAKE`
7979
environment variable.
8080

81-
On a clean GitHub Windows runner, install the bootstrap compiler with
82-
Chocolatey:
81+
The repository includes a helper that downloads the official combined Win32
82+
and Win64 FPC distribution, verifies its checksum, and installs a complete
83+
bootstrap into an isolated directory:
8384

8485
```powershell
85-
choco install freepascal --version=3.2.2 -y --no-progress
86-
.\build.ps1 compiler -Bootstrap C:\tools\freepascal\bin\i386-win32\fpc.exe
86+
$Bootstrap = .\scripts\Install-FpcBootstrap.ps1
87+
.\build.ps1 compiler -Bootstrap $Bootstrap
8788
```
8889

90+
The combined distribution matters: a Win32-only installation can compile the
91+
bootstrap stages but does not contain the Win64 target binutils needed by the
92+
published toolchain.
93+
8994
Python 3 is needed only for qualification. If it is not on `PATH`, set its full
9095
path in `$env:PYTHON`.
9196

‎scripts/Install-FpcBootstrap.ps1‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[CmdletBinding()]
2+
param(
3+
[string]$Destination = (Join-Path $env:LOCALAPPDATA `
4+
'MoonCompiler\bootstrap\3.2.2')
5+
)
6+
7+
$ErrorActionPreference = 'Stop'
8+
Set-StrictMode -Version Latest
9+
10+
$Version = '3.2.2'
11+
$Url = 'https://downloads.freepascal.org/fpc/dist/3.2.2/i386-win32/' + `
12+
'fpc-3.2.2.win32.and.win64.exe'
13+
$ExpectedSha256 = `
14+
'8C255390544B051388B577EB61C6191A04883264AFE0E3369B3600A56DAF7BDE'
15+
$Bin = Join-Path $Destination 'bin\i386-win32'
16+
$Bootstrap = Join-Path $Bin 'fpc.exe'
17+
$RequiredTools = @(
18+
'make.exe',
19+
'fpcmkcfg.exe',
20+
'x86_64-win64-ar.exe',
21+
'x86_64-win64-as.exe',
22+
'x86_64-win64-ld.exe',
23+
'x86_64-win64-nm.exe',
24+
'x86_64-win64-objcopy.exe',
25+
'x86_64-win64-objdump.exe',
26+
'x86_64-win64-strip.exe',
27+
'x86_64-win64-windres.exe'
28+
)
29+
30+
function Test-Bootstrap {
31+
If (-not (Test-Path -LiteralPath $Bootstrap)) {
32+
return $false
33+
}
34+
foreach ($Tool in $RequiredTools) {
35+
If (-not (Test-Path -LiteralPath (Join-Path $Bin $Tool))) {
36+
return $false
37+
}
38+
}
39+
return ((& $Bootstrap -iV).Trim() -eq $Version)
40+
}
41+
42+
If (-not (Test-Bootstrap)) {
43+
$Installer = Join-Path ([IO.Path]::GetTempPath()) `
44+
'fpc-3.2.2.win32.and.win64.exe'
45+
$Download = $true
46+
If (Test-Path -LiteralPath $Installer) {
47+
$Actual = (Get-FileHash -LiteralPath $Installer -Algorithm SHA256).Hash
48+
$Download = ($Actual -ne $ExpectedSha256)
49+
}
50+
If ($Download) {
51+
Invoke-WebRequest -UseBasicParsing -Uri $Url -OutFile $Installer
52+
}
53+
$Actual = (Get-FileHash -LiteralPath $Installer -Algorithm SHA256).Hash
54+
If ($Actual -ne $ExpectedSha256) {
55+
throw "FPC installer checksum mismatch: $Actual"
56+
}
57+
58+
New-Item -ItemType Directory -Force -Path $Destination | Out-Null
59+
$Process = Start-Process -FilePath $Installer -ArgumentList @(
60+
'/verysilent', '/norestart', "/dir=`"$Destination`"") `
61+
-Wait -PassThru -WindowStyle Hidden
62+
If ($Process.ExitCode -ne 0) {
63+
throw "FPC installer failed with exit code $($Process.ExitCode)"
64+
}
65+
If (-not (Test-Bootstrap)) {
66+
throw "FPC $Version bootstrap installation is incomplete: $Destination"
67+
}
68+
}
69+
70+
Write-Output $Bootstrap

0 commit comments

Comments
 (0)