forked from Ports/goldeneye-pc-port
build(release): fall back to 7z / Compress-Archive when zip is absent (#20)
A stock MSYS2 MINGW64 shell ships neither `zip` nor `unzip`, so `tools_pc/bundle-win.sh` failed at the packaging step for a local release build (the M-45 handoff's documented v0.1.0 cut path). CI is unaffected (it `pacman -S zip unzip`, so the `zip` branch is still taken). Fallback order: zip -> 7z on PATH -> "C:\Program Files\7-Zip\7z.exe" -> powershell Compress-Archive. Verified end-to-end: bundle builds, unpacks to a clean dir, prepare-assets runs, ge007.x86_64.exe boots -level_09 to frame 2100+ crash-free.
This commit is contained in:
1 parent
368062e319
commit
ed6e677d06
1 file changed
+22
-4
+22
-4
@@ -118,10 +118,28 @@ if [ "$BYTES" -gt "$LIMIT" ]; then
|
||||
fi
|
||||
|
||||
# --- zip + checksum --------------------------------------------------
|
||||
( cd dist && rm -f "${NAME}.zip" "${NAME}.zip.sha256" \
|
||||
&& zip -qr "${NAME}.zip" "$NAME" \
|
||||
&& sha256sum "${NAME}.zip" > "${NAME}.zip.sha256" )
|
||||
# Prefer InfoZIP `zip`; fall back to 7-Zip or PowerShell Compress-Archive so a
|
||||
# stock MSYS2 MINGW64 shell (which ships neither `zip` nor `unzip`) still works.
|
||||
zip_dir() { # $1 = archive name, $2 = dir to add (both relative to dist/)
|
||||
if command -v zip >/dev/null 2>&1; then
|
||||
( cd dist && zip -qr "$1" "$2" )
|
||||
elif command -v 7z >/dev/null 2>&1; then
|
||||
( cd dist && 7z a -tzip -bso0 -bsp0 "$1" "$2" >/dev/null )
|
||||
elif [ -x "/c/Program Files/7-Zip/7z.exe" ]; then
|
||||
( cd dist && "/c/Program Files/7-Zip/7z.exe" a -tzip -bso0 -bsp0 "$1" "$2" >/dev/null )
|
||||
elif command -v powershell >/dev/null 2>&1; then
|
||||
( cd dist && powershell -NoProfile -Command \
|
||||
"Compress-Archive -Force -Path '$2' -DestinationPath '$1'" )
|
||||
else
|
||||
echo "error: need one of: zip, 7z, or powershell to package the bundle" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
( cd dist && rm -f "${NAME}.zip" "${NAME}.zip.sha256" )
|
||||
zip_dir "${NAME}.zip" "$NAME"
|
||||
( cd dist && sha256sum "${NAME}.zip" > "${NAME}.zip.sha256" )
|
||||
|
||||
echo "==> dist/${NAME}.zip ($(du -h "dist/${NAME}.zip" | cut -f1))"
|
||||
cat "dist/${NAME}.zip.sha256"
|
||||
( cd dist && unzip -l "${NAME}.zip" ) 2>/dev/null || find "$OUT" -type f | sed "s#^dist/##" | sort
|
||||
( cd dist && unzip -l "${NAME}.zip" ) 2>/dev/null \
|
||||
|| find "$OUT" -type f | sed "s#^dist/##" | sort
|
||||
Reference in new issue
Block a user