Files
gen1recomp/scripts/lib/fetch.sh
T
Shane McGovern ca90a89d68 Ship pinned modern LuaJIT in the aarch64 Linux builds
The linux-arm64 AppImage, the SBC PortMaster zip and the RG34XXSP zip
shipped LuaJIT 2.1.0-beta3 (2017): Debian bullseye's libluajit-5.1-dev for
the AppImage, PortMaster's love_11.5 runtime library for the zips. With
the JIT enabled, beta3 segfaulted 3/3 runs on a TrimUI Brick; LuaJIT v2.1
commit c6ffc141 ran a 26-minute JIT-on soak without a crash.

- Build LuaJIT c6ffc141 from a sha256-pinned tarball in a digest-pinned
  debian:bullseye (glibc 2.31) with the same apt sources as the AppImage
  builder; compile with PREFIX=/usr so no build path is baked into
  package.path, stage-install, and verify before use.
- AppImage: compile it inside the builder instead of libluajit-5.1-dev,
  bundle it with jit/*.lua and its license; cache keys include the LuaJIT
  commit, recipe hash and Dockerfile hash.
- PortMaster zips: replace libs.aarch64/libluajit-5.1.so.2 with the pinned
  build, pin the PortMaster runtime to commit 715f50fd with sha256 checks
  (rg34xxsp followed main), ship LuaJIT-COPYRIGHT, verify the finished zip.
- verify_luajit.sh gates every package: version string, not beta, aarch64
  ELF, /usr module path, max GLIBC <= 2.31; offline selftests cover it and
  the PortMaster helpers.
- CI/release build LuaJIT once on an arm64 runner and pass it to the zip
  jobs via GEN1RECOMP_LUAJIT_LIB.

The JIT stays off by default (LÖVE's jitsetup disables it on arm/arm64).
POKEPORT_JIT=1 needs stability testing on H700, RK3566 and A133P devices
before it can be enabled by default.
2026-10-10 19:37:08 +01:00

64 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Sourceable download/hash/container helpers. No side effects on source.
# The caller must define say, warn and fail.
# Print SHA-256 hex digest of PATH. Prefers sha256sum, falls back to shasum
# (same order-agnostic pair scripts/switch/common.sh uses).
sha256_file() {
local path="$1"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$path" | awk '{print $1}'
elif command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$path" | awk '{print $1}'
else
fail "need sha256sum or shasum (install coreutils)"
fi
}
# download_pinned URL DEST EXPECTED_SHA256
#
# A cache hit is only trusted if it still hashes to the pin: a download
# truncated by a network drop would otherwise be reused forever, which is the
# same trap scripts/build.sh guards for the win64 zip and the x86_64 AppImage.
download_pinned() {
local url="$1" dest="$2" want="$3" got=""
if [ -f "$dest" ]; then
got="$(sha256_file "$dest")"
if [ "$got" = "$want" ]; then
return 0
fi
warn "cached $(basename "$dest") has the wrong digest, re-downloading"
rm -f "$dest"
fi
say "downloading $(basename "$dest")"
# --retry-all-errors because plain --retry skips TLS handshake failures,
# which is how xiph.org drops these tarballs; the pin below still gates it.
# curl < 7.71 lacks the flag and rejects it, so it is only passed if offered.
local retry_all=()
# No grep -q: it would exit early and SIGPIPE curl, which pipefail reports.
if curl --help all 2>/dev/null | grep -- --retry-all-errors >/dev/null; then
retry_all=(--retry-all-errors)
fi
curl -fL --retry 5 --retry-delay 2 ${retry_all[@]+"${retry_all[@]}"} --progress-bar \
"$url" -o "$dest.tmp" || fail "download failed: $url"
got="$(sha256_file "$dest.tmp")"
[ "$got" = "$want" ] || fail "$(printf '%s\n expected %s\n got %s' \
"checksum mismatch for $(basename "$dest")" "$want" "$got")"
mv "$dest.tmp" "$dest"
}
# Echo the container runtime to use: docker, else podman.
container_runtime() {
if [ -n "${GEN1_CONTAINER_RUNTIME:-}" ]; then
printf '%s' "$GEN1_CONTAINER_RUNTIME"
return 0
fi
if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
printf 'docker'
elif command -v podman >/dev/null 2>&1; then
printf 'podman'
else
return 1
fi
}