packaging: exclude qemu-system-aarch64w, strip ARM64/restore binaries, enable zstd --long=27 [skip ci]

This commit is contained in:
千川白浪 committed 2026-12-05 00:54:31 -07:00
1 parent 4121508711
commit 1aa6a2f701
2 files changed
+21 -5

No files matched your search

@@ -101,7 +101,9 @@ function Write-Utf8([string]$path, [string]$text) {
function New-TarZst([string]$parent, [string]$name, [string]$archive) {
$tar = Join-Path $TempRoot "$name.tar"
Invoke-Native 'tar.exe' @('-cf', $tar, '-C', $parent, $name)
Invoke-Native $zstd @('-T0', "-$ZstdLevel", '-q', '-f', $tar, '-o', $archive)
# --long=27 (128 MiB window) deduplicates shared QEMU code across x86_64 and aarch64
# binaries while staying within default zstd CLI and Go decoder window limits.
Invoke-Native $zstd @('-T0', '--long=27', "-$ZstdLevel", '-q', '-f', $tar, '-o', $archive)
Remove-Item -LiteralPath $tar -Force
}
@@ -10,23 +10,27 @@ param(
$ErrorActionPreference = 'Stop'
$programs = @('bin/reims-ctl.exe', 'bin/reims-util.exe', 'qemu/bin/qemu-system-x86_64.exe',
'qemu/bin/qemu-img.exe', 'qemu/bin/reims-vgpu-compile.exe')
# Additional executables that may be built alongside x64 (e.g. ARM64 guest support).
# Strip their debug info into the detached symbols archive whenever present.
$optionalPrograms = @('qemu/bin/qemu-system-aarch64.exe', 'qemu/bin/reims-restore.exe')
$allStripped = $programs + $optionalPrograms
# Omit only the paths tested with the x64 launcher. Keep new upstream files,
# in particular dynamically loaded video drivers, ROMs, and license notices.
$tools = @('bin/qemu-system-x86_64w.exe', 'bin/elf2dmp.exe', 'bin/qemu-edid.exe',
'bin/qemu-io.exe', 'bin/qemu-nbd.exe', 'bin/qemu-storage-daemon.exe')
$tools = @('bin/qemu-system-x86_64w.exe', 'bin/qemu-system-aarch64w.exe', 'bin/elf2dmp.exe',
'bin/qemu-edid.exe', 'bin/qemu-io.exe', 'bin/qemu-nbd.exe', 'bin/qemu-storage-daemon.exe')
foreach ($file in Get-ChildItem -LiteralPath $QemuDir -Recurse -Force -File) {
$rel = [IO.Path]::GetRelativePath($QemuDir, $file.FullName).Replace('\', '/')
if ($rel -in $tools) { continue }
if ($rel -match '^share/edk2-(aarch64|riscv64|loongarch64)-(code|vars)\.fd$' -or
$rel -match '^share/firmware/\d+-edk2-(aarch64|riscv64|loongarch64)\.json$') { continue }
if ("qemu/$rel" -in $programs) { continue }
if ("qemu/$rel" -in $allStripped) { continue }
$dest = Join-Path $BundleDir "qemu/$rel"
[void][IO.Directory]::CreateDirectory((Split-Path -Parent $dest))
Copy-Item -LiteralPath $file.FullName -Destination $dest
}
foreach ($rel in $programs) {
function Copy-StrippedBinary([string]$rel) {
$src = if ($rel.StartsWith('qemu/')) { Join-Path $QemuDir $rel.Substring(5) }
else { Join-Path $CargoBin (Split-Path -Leaf $rel) }
$dest = Join-Path $BundleDir $rel
@@ -38,5 +42,15 @@ foreach ($rel in $programs) {
& $Objcopy --strip-debug "--add-gnu-debuglink=$debug" $src $dest | Out-Null
if ($LASTEXITCODE) { throw "Stripping $src failed ($LASTEXITCODE)" }
}
foreach ($rel in $programs) {
Copy-StrippedBinary $rel
}
foreach ($rel in $optionalPrograms) {
$src = Join-Path $QemuDir $rel.Substring(5)
if (Test-Path -LiteralPath $src -PathType Leaf) {
Copy-StrippedBinary $rel
}
}
# The packer hashes these final, stripped bytes for manifest.json.
$programs