Stage the native compiler under the agent execution policy
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
"""Extract the signed Inno compiler through its native portable installer."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from uuid import uuid4
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tests"))
|
||||
from windows_gui import start_isolated
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
installer, destination = (Path(value).resolve() for value in sys.argv[1:])
|
||||
raise SystemExit(start_isolated(
|
||||
[str(installer), "/PORTABLE=1", "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART", f"/DIR={destination}"],
|
||||
f"ARM_Compiler_{uuid4().hex[:10]}", timeout=90,
|
||||
))
|
||||
@@ -1,19 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$scratch = Join-Path $PWD '.ci'
|
||||
$compiler = Join-Path $scratch 'inno'
|
||||
$download = Join-Path $scratch 'innosetup-7.1.1-x64.exe'
|
||||
$origin = 'https://github.com/jrsoftware/issrc/releases/download/is-7_1_1/innosetup-7.1.1-x64.exe'
|
||||
$expected = '8a5a6711c3766a6e5fb74f280ba0e3551e719ce94538d901fdbd1f8f9920b3f0'
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $origin -OutFile $download
|
||||
if ((Get-FileHash -LiteralPath $download -Algorithm SHA256).Hash -ine $expected) {
|
||||
throw 'Inno Setup download SHA-256 mismatch'
|
||||
}
|
||||
$signature = Get-AuthenticodeSignature -LiteralPath $download
|
||||
if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch 'CN=Pyrsys B\.V\.') {
|
||||
throw 'Inno Setup publisher verification failed'
|
||||
}
|
||||
& '.ci\python\Scripts\python.exe' tools\install_ci_compiler.py $download $compiler
|
||||
if ($LASTEXITCODE -ne 0 -or -not (Test-Path -LiteralPath (Join-Path $compiler 'ISCC.exe'))) {
|
||||
throw 'Portable Inno Setup staging failed'
|
||||
}
|
||||
Write-Host 'Inno Setup 7.1.1 x64 hash, publisher and portable staging verified.'
|
||||
45
tools/prepare_windows_compiler.py
Normal file
45
tools/prepare_windows_compiler.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""Stage the pinned Windows compiler without changing the agent's execution policy."""
|
||||
from hashlib import file_digest
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from urllib.request import urlopen
|
||||
from uuid import uuid4
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / "tests"))
|
||||
from windows_gui import start_isolated
|
||||
|
||||
NAME = "innosetup-7.1.1-x64.exe"
|
||||
ORIGIN = f"https://github.com/jrsoftware/issrc/releases/download/is-7_1_1/{NAME}"
|
||||
SHA256 = "8a5a6711c3766a6e5fb74f280ba0e3551e719ce94538d901fdbd1f8f9920b3f0"
|
||||
|
||||
|
||||
def main():
|
||||
scratch = ROOT / ".ci"
|
||||
installer = scratch / NAME
|
||||
destination = scratch / "inno"
|
||||
with urlopen(ORIGIN, timeout=60) as response, installer.open("xb") as output:
|
||||
shutil.copyfileobj(response, output)
|
||||
with installer.open("rb") as source:
|
||||
if file_digest(source, "sha256").hexdigest() != SHA256:
|
||||
raise RuntimeError("Inno Setup download SHA-256 mismatch")
|
||||
signature = subprocess.check_output(
|
||||
["powershell.exe", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command",
|
||||
f"(Get-AuthenticodeSignature -LiteralPath '{NAME}').Status.ToString()"],
|
||||
cwd=scratch, text=True,
|
||||
).strip()
|
||||
if signature != "Valid":
|
||||
raise RuntimeError(f"Inno Setup Authenticode verification failed: {signature}")
|
||||
code = start_isolated(
|
||||
[str(installer), "/PORTABLE=1", "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART", f"/DIR={destination}"],
|
||||
f"ARM_Compiler_{uuid4().hex[:10]}", timeout=90,
|
||||
)
|
||||
if code or not (destination / "ISCC.exe").is_file():
|
||||
raise RuntimeError(f"Portable Inno Setup staging failed: exit {code}")
|
||||
print("Inno Setup 7.1.1 x64 hash, Authenticode and native portable staging verified.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user