From 42f4aebbde97ee8746db269c0f8e6a4f46db1f25 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 15 Nov 2026 00:48:36 +0800 Subject: [PATCH] feat: publish architecture-specific Windows update payloads --- .github/workflows/build.yaml | 2 +- .../publish-windows-update-feed.yaml | 57 +++++----- crates/openconnect/deps/openconnect | 2 +- packaging/windows/README.md | 6 +- scripts/gh-release.sh | 2 +- scripts/tests/test_windows_update_feed.py | 62 ++++++++--- scripts/windows-update-feed.py | 104 ++++++++++-------- 7 files changed, 145 insertions(+), 90 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6fb83ad..d477aaf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -43,7 +43,7 @@ on: default: false type: boolean build_windows: - description: 'Build the Windows x64 NSH installer and development ZIP' + description: 'Build Windows x64 and ARM64 NSH installers and development ZIPs' required: true default: false type: boolean diff --git a/.github/workflows/publish-windows-update-feed.yaml b/.github/workflows/publish-windows-update-feed.yaml index d1bd9fb..8a981c0 100644 --- a/.github/workflows/publish-windows-update-feed.yaml +++ b/.github/workflows/publish-windows-update-feed.yaml @@ -9,11 +9,7 @@ on: default: main type: string release_tag: - description: GitHub release containing the tested installer and detached signature - required: true - type: string - installer_name: - description: Exact Windows x64 installer asset name + description: GitHub release containing both tested native installers and signatures required: true type: string version: @@ -46,7 +42,6 @@ jobs: env: REPOSITORY: yuezk/GlobalProtect-openconnect RELEASE_TAG: ${{ inputs.release_tag }} - INSTALLER_NAME: ${{ inputs.installer_name }} PRODUCT_VERSION: ${{ inputs.version }} UPDATE_CHANNEL: ${{ inputs.channel }} BUILD_VERSION: ${{ inputs.build }} @@ -72,7 +67,7 @@ jobs: - uses: actions/setup-node@v6 with: node-version: 22 - - name: Verify tested release installer + - name: Verify both tested native installers shell: pwsh run: | $ErrorActionPreference = 'Stop' @@ -82,28 +77,31 @@ jobs: } elseif ($env:RELEASE_TAG -ne 'snapshot' -or $env:BUILD_VERSION -notmatch '^\d+(\.\d+){0,2}$') { throw 'Snapshot release identity does not match.' } $displayVersion = $env:PRODUCT_VERSION if ($env:UPDATE_CHANNEL -eq 'snapshot') { $displayVersion += "-snapshot.$env:BUILD_VERSION" } - if ($env:INSTALLER_NAME -ne "GPConnect_${displayVersion}_windows-x64-setup.exe") { throw 'Installer asset does not match the product version, channel and build.' } if (!$env:WINDOWS_UPDATE_PUBLIC_KEY) { throw 'Configure the Windows public update key before promotion.' } $downloads = Join-Path $env:RUNNER_TEMP 'windows-update' New-Item -ItemType Directory -Force $downloads | Out-Null - foreach ($asset in @($env:INSTALLER_NAME, "$env:INSTALLER_NAME.sig", "$env:INSTALLER_NAME.sha256")) { - gh release download $env:RELEASE_TAG --repo $env:REPOSITORY --pattern $asset --dir $downloads - if ($LASTEXITCODE -ne 0) { throw "Missing release asset: $asset" } - } - $installer = Join-Path $downloads $env:INSTALLER_NAME - $sum = (Get-Content "$installer.sha256" -Raw).Trim() - if ($sum -notmatch '^([a-fA-F0-9]{64}) (.+)$' -or $Matches[2] -ne $env:INSTALLER_NAME) { throw 'Invalid installer checksum file.' } - if ((Get-FileHash $installer).Hash -ne $Matches[1]) { throw 'Installer checksum mismatch.' } - if ($env:WINDOWS_SIGNING_PUBLISHER) { - $authenticode = Get-AuthenticodeSignature $installer - if ($authenticode.Status -ne 'Valid' -or $authenticode.SignerCertificate.GetNameInfo([Security.Cryptography.X509Certificates.X509NameType]::SimpleName, $false) -ne $env:WINDOWS_SIGNING_PUBLISHER) { throw 'Installer publisher signature is invalid.' } - } - if ([Diagnostics.FileVersionInfo]::GetVersionInfo($installer).ProductVersion -ne $displayVersion) { throw 'Installer product version/build mismatch.' } . ./gpgui/scripts/windows-updates/Get-WinSparkle.ps1 $tools = Get-WinSparkleTools (Join-Path $env:RUNNER_TEMP 'signing-tools') - $signature = (Get-Content "$installer.sig" -Raw).Trim() - & $tools.Tool verify -p $env:WINDOWS_UPDATE_PUBLIC_KEY -s $signature $installer - if ($LASTEXITCODE -ne 0) { throw 'Installer update signature is invalid.' } + foreach ($architecture in @('x64','arm64')) { + $name = "GPConnect_${displayVersion}_windows-$architecture-setup.exe" + foreach ($asset in @($name, "$name.sig", "$name.sha256")) { + gh release download $env:RELEASE_TAG --repo $env:REPOSITORY --pattern $asset --dir $downloads + if ($LASTEXITCODE -ne 0) { throw "Missing release asset: $asset" } + } + $installer = Join-Path $downloads $name + $sum = (Get-Content "$installer.sha256" -Raw).Trim() + if ($sum -notmatch '^([a-fA-F0-9]{64}) (.+)$' -or $Matches[2] -ne $name) { throw 'Invalid installer checksum file.' } + if ((Get-FileHash $installer).Hash -ne $Matches[1]) { throw 'Installer checksum mismatch.' } + if ($env:WINDOWS_SIGNING_PUBLISHER) { + $authenticode = Get-AuthenticodeSignature $installer + if ($authenticode.Status -ne 'Valid' -or $authenticode.SignerCertificate.GetNameInfo([Security.Cryptography.X509Certificates.X509NameType]::SimpleName, $false) -ne $env:WINDOWS_SIGNING_PUBLISHER) { throw 'Installer publisher signature is invalid.' } + } + if ([Diagnostics.FileVersionInfo]::GetVersionInfo($installer).ProductVersion -ne $displayVersion) { throw 'Installer product version/build mismatch.' } + $signature = (Get-Content "$installer.sig" -Raw).Trim() + & $tools.Tool verify -p $env:WINDOWS_UPDATE_PUBLIC_KEY -s $signature $installer + if ($LASTEXITCODE -ne 0) { throw 'Installer update signature is invalid.' } + } + "WINDOWS_DISPLAY_VERSION=$displayVersion" >> $env:GITHUB_ENV - name: Preserve other feeds and generate Windows metadata shell: pwsh run: | @@ -115,12 +113,15 @@ jobs: $env:UPDATE_HIGHLIGHTS | Set-Content $notes -Encoding utf8NoBOM $output = Join-Path $public 'windows' $previous = Join-Path $output 'latest.json' - $installer = Join-Path (Join-Path $env:RUNNER_TEMP 'windows-update') $env:INSTALLER_NAME - $arguments = @('scripts/windows-update-feed.py', '--installer', $installer, - '--installer-url', "https://github.com/$env:REPOSITORY/releases/download/$env:RELEASE_TAG/$env:INSTALLER_NAME", - '--signature-file', "$installer.sig", '--version', $env:PRODUCT_VERSION, + $arguments = @('scripts/windows-update-feed.py', '--version', $env:PRODUCT_VERSION, '--channel', $env:UPDATE_CHANNEL, '--released-at', [DateTime]::UtcNow.ToString('yyyy-MM-dd'), '--highlights-file', $notes, '--output', $output) + foreach ($architecture in @('x64','arm64')) { + $name = "GPConnect_$($env:WINDOWS_DISPLAY_VERSION)_windows-$architecture-setup.exe" + $installer = Join-Path (Join-Path $env:RUNNER_TEMP 'windows-update') $name + $arguments += @('--payload', $architecture, $installer, + "https://github.com/$env:REPOSITORY/releases/download/$env:RELEASE_TAG/$name", "$installer.sig") + } if (Test-Path $previous) { $arguments += @('--input', $previous) } if ($env:BUILD_VERSION) { $arguments += @('--build', $env:BUILD_VERSION) } python @arguments diff --git a/crates/openconnect/deps/openconnect b/crates/openconnect/deps/openconnect index 067e90c..f85d4f7 160000 --- a/crates/openconnect/deps/openconnect +++ b/crates/openconnect/deps/openconnect @@ -1 +1 @@ -Subproject commit 067e90c8de49abe77deefe046c54cf4e11855f1b +Subproject commit f85d4f7b142dd8fa4cac8ba261cf9485ac53960e diff --git a/packaging/windows/README.md b/packaging/windows/README.md index 0b81632..87b9fb6 100644 --- a/packaging/windows/README.md +++ b/packaging/windows/README.md @@ -4,9 +4,13 @@ `machine-install.ps1` installation implementation. Build it with NSIS 3 Unicode: ```powershell -& makensis /DPAYLOAD_DIR=C:\build\payload /DOUTPUT_FILE=C:\build\GPConnect-Setup.exe /DPRODUCT_VERSION=3.4.0 /DBUILD_VERSION=3.4.0.0 /DDISPLAY_VERSION=3.4.0-snapshot.2026.1114.2 .\packaging\windows\installer.nsi +& makensis /DTARGET_ARCH=x64 /DPAYLOAD_DIR=C:\build\payload /DOUTPUT_FILE=C:\build\GPConnect-Setup.exe /DPRODUCT_VERSION=3.4.0 /DBUILD_VERSION=3.4.0.0 /DDISPLAY_VERSION=3.4.0-snapshot.2026.1114.2 .\packaging\windows\installer.nsi ``` +`TARGET_ARCH` is `x64` or `arm64` and must match every executable and DLL in +the payload. Each installer accepts only its native Windows architecture. ARM64 +requires Windows 11; x64 requires Windows 10 build 19041 or newer. + `BUILD_VERSION` must contain four numeric components. `PRODUCT_VERSION` must match the payload's `build-info.json`. `DISPLAY_VERSION` is the full release identity, including the snapshot build when applicable. The payload must contain matching diff --git a/scripts/gh-release.sh b/scripts/gh-release.sh index 5245db4..67fce6e 100755 --- a/scripts/gh-release.sh +++ b/scripts/gh-release.sh @@ -175,7 +175,7 @@ release_snapshot() { # The appcast publisher removes expired macOS snapshots after the new feed # is live. Removing them here would temporarily break the current feed. - if [[ "$asset" == GPConnect_*_arm64.* || "$asset" == GPConnect_*_windows-x64-setup.exe* ]]; then + if [[ "$asset" == GPConnect_*_arm64.* || "$asset" == GPConnect_*_windows-x64-setup.exe* || "$asset" == GPConnect_*_windows-arm64-setup.exe* ]]; then continue fi if ! delete_release_asset "$asset"; then diff --git a/scripts/tests/test_windows_update_feed.py b/scripts/tests/test_windows_update_feed.py index 525991c..5996efa 100644 --- a/scripts/tests/test_windows_update_feed.py +++ b/scripts/tests/test_windows_update_feed.py @@ -22,17 +22,17 @@ preserver = load("preserve_update_feeds", "preserve-update-feeds.py") class WindowsFeedTests(unittest.TestCase): - def args(self, root, channel="stable", version="3.4.0", build=None): - name = feed.installer_name(version, channel, build) + def args(self, root, channel="stable", version="3.4.0", build=None, architecture="x64"): + name = feed.installer_name(version, channel, build, architecture) installer = root / name - installer.write_bytes(b"test installer") - signature = root / "installer.sig" - signature.write_text(base64.b64encode(bytes(64)).decode()) + installer.write_bytes(f"test installer {architecture}".encode()) + signature = root / f"installer-{architecture}.sig" + signature.write_text(base64.b64encode(bytes([1 if architecture == "arm64" else 0]) * 64).decode()) highlights = root / "highlights.txt" highlights.write_text("Update & improve .\n") tag = f"v{version}" if channel == "stable" else "snapshot" - return argparse.Namespace(installer=installer, signature_file=signature, - installer_url=f"https://github.com/yuezk/GlobalProtect-openconnect/releases/download/{tag}/{name}", + return argparse.Namespace(payload=[feed.Payload(architecture, installer, + f"https://github.com/yuezk/GlobalProtect-openconnect/releases/download/{tag}/{name}", signature)], repository="yuezk/GlobalProtect-openconnect", channel=channel, version=version, build=build, released_at="2026-11-14", highlights_file=highlights, input=None, output=root / "windows", allow_localhost=False) @@ -47,17 +47,49 @@ class WindowsFeedTests(unittest.TestCase): self.assertEqual(item.findtext("description"), "Update & improve .") enclosure = item.find("enclosure") self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), catalog["stable"]["version"]) - self.assertEqual(int(enclosure.get("length")), args.installer.stat().st_size) + self.assertEqual(int(enclosure.get("length")), args.payload[0].installer.stat().st_size) self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}os"), "windows-x64") + def test_native_architectures_share_one_release_with_separate_signed_enclosures(self): + with tempfile.TemporaryDirectory() as directory: + args = self.args(Path(directory)) + arm = self.args(Path(directory), architecture="arm64") + args.payload += arm.payload + feed.generate(args) + items = ET.parse(args.output / "stable/appcast.xml").findall("channel/item") + self.assertEqual(len(items), 2) + for item, payload in zip(items, args.payload): + enclosure = item.find("enclosure") + self.assertEqual(enclosure.get("url"), payload.installer_url) + self.assertEqual(int(enclosure.get("length")), payload.installer.stat().st_size) + self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}edSignature"), payload.signature_file.read_text()) + self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}os"), f"windows-{payload.architecture}") + self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), "3.4.0") + minimum = "10.0.22000" if payload.architecture == "arm64" else "10.0.19041" + self.assertEqual(item.findtext(f"{{{feed.SPARKLE}}}minimumSystemVersion"), minimum) + self.assertEqual(json.loads((args.output / "latest.json").read_text())["stable"]["platforms"], ["windows"]) + + def test_mismatched_or_duplicate_architecture_does_not_write_a_feed(self): + with tempfile.TemporaryDirectory() as directory: + args = self.args(Path(directory)) + args.payload[0].architecture = "arm64" + with self.assertRaisesRegex(ValueError, "filename"): + feed.generate(args) + self.assertFalse(args.output.exists()) + args.payload[0].architecture = "x64" + args.payload *= 2 + with self.assertRaisesRegex(ValueError, "one installer per"): + feed.generate(args) + self.assertFalse(args.output.exists()) + def test_snapshot_promotion_retains_stable_and_rejects_downgrade(self): with tempfile.TemporaryDirectory() as directory: args = self.args(Path(directory)) feed.generate(args) args.input = args.output / "latest.json" args.channel, args.build = "snapshot", "2026.1114.2" - args.installer = args.installer.rename(args.installer.parent / feed.installer_name(args.version, args.channel, args.build)) - args.installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.installer.name}" + args.payload[0].installer = args.payload[0].installer.rename(args.payload[0].installer.parent / feed.installer_name(args.version, args.channel, args.build)) + args.payload[0].installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.payload[0].installer.name}" feed.generate(args) catalog = json.loads(args.input.read_text()) self.assertEqual(catalog["stable"]["version"], "3.4.0") @@ -65,8 +97,8 @@ class WindowsFeedTests(unittest.TestCase): enclosure = ET.parse(args.output / "snapshot/appcast.xml").find("channel/item/enclosure") self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), "3.4.0-snapshot.2026.1114.2") args.build = "2026.1114.1" - args.installer = args.installer.rename(args.installer.parent / feed.installer_name(args.version, args.channel, args.build)) - args.installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.installer.name}" + args.payload[0].installer = args.payload[0].installer.rename(args.payload[0].installer.parent / feed.installer_name(args.version, args.channel, args.build)) + args.payload[0].installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.payload[0].installer.name}" with self.assertRaisesRegex(ValueError, "older"): feed.generate(args) @@ -91,7 +123,7 @@ class WindowsFeedTests(unittest.TestCase): for channel in ("stable", "snapshot"): enclosure = ET.parse(stable.output / channel / "appcast.xml").find("channel/item/enclosure") self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), "3.5.0") - self.assertEqual(enclosure.get("url"), stable.installer_url) + self.assertEqual(enclosure.get("url"), stable.payload[0].installer_url) def test_stable_without_snapshot_initializes_both_native_feeds(self): with tempfile.TemporaryDirectory() as directory: @@ -130,7 +162,7 @@ class WindowsFeedTests(unittest.TestCase): def test_private_loopback_download_requires_explicit_opt_in(self): with tempfile.TemporaryDirectory() as directory: args = self.args(Path(directory)) - args.installer_url = "http://127.0.0.1:18770/setup.exe" + args.payload[0].installer_url = "http://127.0.0.1:18770/setup.exe" with self.assertRaisesRegex(ValueError, "matching GitHub"): feed.generate(args) args.allow_localhost = True @@ -139,7 +171,7 @@ class WindowsFeedTests(unittest.TestCase): def test_missing_or_malformed_signature_is_rejected(self): with tempfile.TemporaryDirectory() as directory: args = self.args(Path(directory)) - args.signature_file.write_text("not a signature") + args.payload[0].signature_file.write_text("not a signature") with self.assertRaises(ValueError): feed.generate(args) diff --git a/scripts/windows-update-feed.py b/scripts/windows-update-feed.py index 9e3a2ab..0b9d339 100644 --- a/scripts/windows-update-feed.py +++ b/scripts/windows-update-feed.py @@ -1,9 +1,8 @@ #!/usr/bin/env python3 -"""Build the Windows catalog and WinSparkle appcast from one verified installer.""" -from __future__ import annotations - +"""Build one Windows catalog and appcast from verified native installers.""" import argparse import base64 +from dataclasses import dataclass import hashlib import importlib.util import json @@ -18,14 +17,47 @@ manifest = importlib.util.module_from_spec(spec) spec.loader.exec_module(manifest) +@dataclass +class Payload: + architecture: str + installer: Path + installer_url: str + signature_file: Path + + def release_version(version: str, channel: str, build: str | None) -> str: if channel == "snapshot": return f"{version}-snapshot.{build}" return version -def installer_name(version: str, channel: str, build: str | None) -> str: - return f"GPConnect_{release_version(version, channel, build)}_windows-x64-setup.exe" +def installer_name(version: str, channel: str, build: str | None, architecture: str = "x64") -> str: + return f"GPConnect_{release_version(version, channel, build)}_windows-{architecture}-setup.exe" + + +def validate_payload(payload: Payload, args: argparse.Namespace) -> tuple[str, int]: + if payload.architecture not in {"x64", "arm64"}: + raise ValueError("unsupported Windows architecture") + expected_name = installer_name(args.version, args.channel, args.build, payload.architecture) + if not args.allow_localhost and payload.installer.name != expected_name: + raise ValueError("installer filename does not match the version, channel, build and architecture") + parsed = urlparse(payload.installer_url) + tag = f"v{args.version}" if args.channel == "stable" else "snapshot" + expected = f"https://github.com/{args.repository}/releases/download/{tag}/" + local = args.allow_localhost and parsed.scheme == "http" and parsed.hostname in {"localhost", "127.0.0.1", "::1"} + if not local and not payload.installer_url.startswith(expected): + raise ValueError("installer URL must identify the matching GitHub release asset") + if parsed.query or parsed.fragment or not parsed.path.endswith(".exe"): + raise ValueError("installer URL must name an EXE without query or fragment") + if not local and parsed.path.rsplit("/", 1)[-1] != expected_name: + raise ValueError("installer download filename does not match the version, channel, build and architecture") + signature = payload.signature_file.read_text(encoding="ascii").strip() + if len(base64.b64decode(signature, validate=True)) != 64: + raise ValueError("EdDSA signature must contain 64 bytes") + length = payload.installer.stat().st_size + if length == 0: + raise ValueError("installer is empty") + return signature, length def generate(args: argparse.Namespace) -> None: @@ -36,25 +68,9 @@ def generate(args: argparse.Namespace) -> None: manifest.build_tuple(args.build) elif args.build is not None: raise ValueError("stable releases must not specify --build") - expected_name = installer_name(args.version, args.channel, args.build) - if not args.allow_localhost and args.installer.name != expected_name: - raise ValueError("installer filename does not match the version, channel and build") - parsed = urlparse(args.installer_url) - tag = f"v{args.version}" if args.channel == "stable" else "snapshot" - expected = f"https://github.com/{args.repository}/releases/download/{tag}/" - local = args.allow_localhost and parsed.scheme == "http" and parsed.hostname in {"localhost", "127.0.0.1", "::1"} - if not local and not args.installer_url.startswith(expected): - raise ValueError("installer URL must identify the matching GitHub release asset") - if parsed.query or parsed.fragment or not parsed.path.endswith(".exe"): - raise ValueError("installer URL must name an EXE without query or fragment") - if not local and parsed.path.rsplit("/", 1)[-1] != expected_name: - raise ValueError("installer download filename does not match the version, channel and build") - signature = args.signature_file.read_text(encoding="ascii").strip() - if len(base64.b64decode(signature, validate=True)) != 64: - raise ValueError("EdDSA signature must contain 64 bytes") - length = args.installer.stat().st_size - if length == 0: - raise ValueError("installer is empty") + if not args.payload or len({payload.architecture for payload in args.payload}) != len(args.payload): + raise ValueError("provide one installer per Windows architecture") + prepared = [(payload, *validate_payload(payload, args)) for payload in args.payload] if args.channel == "snapshot" and args.input is not None: previous = manifest.validate_manifest(json.loads(args.input.read_text(encoding="utf-8")), args.repository) stable = previous["stable"] @@ -76,40 +92,40 @@ def generate(args: argparse.Namespace) -> None: rss = ET.Element("rss", {"version": "2.0"}) channel = ET.SubElement(rss, "channel") ET.SubElement(channel, "title").text = "GP Connect for Windows" - item = ET.SubElement(channel, "item") - ET.SubElement(item, "title").text = f"GP Connect {display_version}" - ET.SubElement(item, "description").text = "\n".join(release["highlights"]) - ET.SubElement(item, f"{{{SPARKLE}}}minimumSystemVersion").text = "10.0.19041" - ET.SubElement(item, "enclosure", { - "url": args.installer_url, "length": str(length), "type": "application/octet-stream", - f"{{{SPARKLE}}}version": display_version, - f"{{{SPARKLE}}}shortVersionString": display_version, - f"{{{SPARKLE}}}os": "windows-x64", f"{{{SPARKLE}}}edSignature": signature, - }) + for payload, signature, length in prepared: + item = ET.SubElement(channel, "item") + ET.SubElement(item, "title").text = f"GP Connect {display_version}" + ET.SubElement(item, "description").text = "\n".join(release["highlights"]) + minimum = "10.0.22000" if payload.architecture == "arm64" else "10.0.19041" + ET.SubElement(item, f"{{{SPARKLE}}}minimumSystemVersion").text = minimum + ET.SubElement(item, "enclosure", { + "url": payload.installer_url, "length": str(length), "type": "application/octet-stream", + f"{{{SPARKLE}}}version": display_version, + f"{{{SPARKLE}}}shortVersionString": display_version, + f"{{{SPARKLE}}}os": f"windows-{payload.architecture}", f"{{{SPARKLE}}}edSignature": signature, + }) ET.indent(rss) channels = [args.channel] snapshot = data["snapshot"] if args.channel == "stable" and ( snapshot is None or manifest.version_tuple(args.version) > manifest.version_tuple(snapshot["baseVersion"]) ): - # Core offers a newer stable release to snapshot installations too. - # Keep the snapshot catalog history, but route its native install feed - # to the same newer stable candidate until a new snapshot is promoted. + # A newer stable release also updates snapshot installations. channels.append("snapshot") for target_channel in channels: channel_directory = output / target_channel channel_directory.mkdir(exist_ok=True) ET.ElementTree(rss).write(channel_directory / "appcast.xml", encoding="utf-8", xml_declaration=True) - with args.installer.open("rb") as installer: - digest = hashlib.file_digest(installer, "sha256").hexdigest() - (output / (args.installer.name + ".sha256")).write_text(f"{digest} {args.installer.name}\n", encoding="ascii") + for payload, _, _ in prepared: + with payload.installer.open("rb") as installer: + digest = hashlib.file_digest(installer, "sha256").hexdigest() + (output / (payload.installer.name + ".sha256")).write_text(f"{digest} {payload.installer.name}\n", encoding="ascii") def main() -> None: parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--installer", type=Path, required=True) - parser.add_argument("--installer-url", required=True) - parser.add_argument("--signature-file", type=Path, required=True) + parser.add_argument("--payload", nargs=4, action="append", required=True, + metavar=("ARCH", "INSTALLER", "URL", "SIGNATURE_FILE")) parser.add_argument("--repository", default="yuezk/GlobalProtect-openconnect") parser.add_argument("--channel", choices=("stable", "snapshot"), required=True) parser.add_argument("--version", required=True) @@ -120,6 +136,8 @@ def main() -> None: parser.add_argument("--output", type=Path, required=True) parser.add_argument("--allow-localhost", action="store_true", help="Permit an isolated loopback test download") args = parser.parse_args() + args.payload = [Payload(architecture, Path(installer), url, Path(signature)) + for architecture, installer, url, signature in args.payload] try: generate(args) except (OSError, ValueError) as error: