From 16bfe7b09598197a41a74c1071a64a6908352b75 Mon Sep 17 00:00:00 2001 From: patchzyy <64382339+patchzyy@users.noreply.github.com> Date: Sun, 18 Oct 2026 18:51:56 +0200 Subject: [PATCH] Fix prebuilt packaging (#311) --- Launcher/Build-Installer.ps1 | 3 ++- Launcher/NativeBuildFlags.ps1 | 17 +++++++++-------- Launcher/build-appimage.sh | 2 +- Launcher/macos/build-setup-pkg.command | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Launcher/Build-Installer.ps1 b/Launcher/Build-Installer.ps1 index e66c3ef..6f6eaa5 100644 --- a/Launcher/Build-Installer.ps1 +++ b/Launcher/Build-Installer.ps1 @@ -244,7 +244,8 @@ foreach ($name in $requiredDependencies) { Copy-Directory (Join-Path $dependency # The translation identity covers the runtime's native registrations through this index (see # ToolkitFingerprint), so it is extracted from exactly the staged runtime sources. $nativeIndex = Join-Path $workspace 'runtime\native-index.json' -& $translator emit-native-index --project (Join-Path $workspace 'projects\mkwii\recomp.yml') --out $nativeIndex +# The payload has no game inputs, so the project file (which validates them) cannot be loaded here. +& $translator emit-native-index --native-source-dir (Join-Path $workspace 'runtime\src') --out $nativeIndex if ($LASTEXITCODE -ne 0) { throw "Native index extraction failed with exit code $LASTEXITCODE." } Assert-File $nativeIndex 'Runtime native index' # A staged runtime that fingerprints differently from the shipped archive would make every diff --git a/Launcher/NativeBuildFlags.ps1 b/Launcher/NativeBuildFlags.ps1 index 00bb12e..6aa628a 100644 --- a/Launcher/NativeBuildFlags.ps1 +++ b/Launcher/NativeBuildFlags.ps1 @@ -208,13 +208,14 @@ function Get-MkwThirdPartySourceFingerprint([string]$ThirdPartyDirectory) { SHA-256 over runtime/third_party, the vendored sources behind the prebuilt package. The precompiled Crypto++ archive is linked while first-party TUs compile against the same headers, so a workspace whose vendored tree moved on must not consume archives harvested from an older - one (same reasoning as the aurora fingerprint below). Unlike that scan this hashes hidden files - too, since Build-Installer stages this tree with Copy-Item -Force. Returns '' when absent. + one (same reasoning as the aurora fingerprint below), skipping dot-paths by name the same way. + Returns '' when absent. #> if ([string]::IsNullOrWhiteSpace($ThirdPartyDirectory)) { return '' } if (-not (Test-Path -LiteralPath $ThirdPartyDirectory -PathType Container)) { return '' } $root = [IO.Path]::GetFullPath($ThirdPartyDirectory).TrimEnd('\') - $files = Get-ChildItem -LiteralPath $root -Recurse -File | + $files = Get-ChildItem -LiteralPath $root -Recurse -File -Force | + Where-Object { -not ($_.FullName.Substring($root.Length + 1) -split '\\' | Where-Object { $_.StartsWith('.') }) } | Sort-Object { $_.FullName.Substring($root.Length + 1).Replace('\', '/') } $sha = [Security.Cryptography.SHA256]::Create() try { @@ -245,13 +246,13 @@ function Get-MkwAuroraSourceFingerprint([string]$AuroraDirectory) { (Join-Path $root 'extern') + '\', (Join-Path $root 'build') + '\' ) - # Hidden files are skipped deliberately: Build-Installer.ps1 stages this tree - # with Copy-Item -Recurse (no -Force), so they never reach the payload and - # hashing them would make the two sides disagree by construction. - $files = Get-ChildItem -LiteralPath $root -Recurse -File | + # Dot-paths (the submodule's .git pointer) are skipped by name, not by the hidden attribute: + # the payload zip drops that attribute, so the installed side would otherwise hash them. + $files = Get-ChildItem -LiteralPath $root -Recurse -File -Force | Where-Object { $full = $_.FullName - -not ($excludedPrefixes | Where-Object { $full.StartsWith($_, [StringComparison]::OrdinalIgnoreCase) }) + -not ($excludedPrefixes | Where-Object { $full.StartsWith($_, [StringComparison]::OrdinalIgnoreCase) }) -and + -not ($full.Substring($root.Length + 1) -split '\\' | Where-Object { $_.StartsWith('.') }) } | Sort-Object { $_.FullName.Substring($root.Length + 1).Replace('\', '/') } $sha = [Security.Cryptography.SHA256]::Create() diff --git a/Launcher/build-appimage.sh b/Launcher/build-appimage.sh index 3cb9b3c..6280cf2 100755 --- a/Launcher/build-appimage.sh +++ b/Launcher/build-appimage.sh @@ -182,7 +182,7 @@ cp "$workspace/Launcher/local-build.sh" "$workspace/Launcher/build-cache.sh" "$a # index, so it is extracted from exactly the bundled runtime sources. echo "Extracting the runtime native index..." "$appdir/usr/bin/translator-cli" emit-native-index \ - --project "$appdir/workspace/projects/mkwii/recomp.yml" \ + --native-source-dir "$appdir/workspace/runtime/src" \ --out "$appdir/workspace/runtime/native-index.json" [[ -f "$appdir/workspace/runtime/native-index.json" ]] || { echo "build-appimage.sh: the native index was not written" >&2; exit 1; } diff --git a/Launcher/macos/build-setup-pkg.command b/Launcher/macos/build-setup-pkg.command index 9038b2d..396d6f2 100755 --- a/Launcher/macos/build-setup-pkg.command +++ b/Launcher/macos/build-setup-pkg.command @@ -153,7 +153,7 @@ done # The translation identity (build-cache.sh) covers the runtime's native registrations through this # index, so it is extracted from exactly the packaged runtime sources. if [[ "$host_arch" == arm64 ]]; then host_translator=$translator_arm64; else host_translator=$translator_x86_64; fi -"$host_translator" emit-native-index --project "$resources/workspace/projects/mkwii/recomp.yml" \ +"$host_translator" emit-native-index --native-source-dir "$resources/workspace/runtime/src" \ --out "$resources/workspace/runtime/native-index.json" || fail 'the runtime native index could not be extracted' [[ -f "$resources/workspace/runtime/native-index.json" ]] || fail 'the runtime native index was not written' mkdir -p "$resources/workspace/Launcher/macos"