Files
bananarchy/prepare-release.sh
T
Luxferre 9fc82fb7d8 Harden prepare-release.sh beatles boot validation and archive creation
- Normalize target aliases and decouple boot-lk2nd-nokia-beatles-display.img rebuilds from rebuild-image.sh so a missing lk2nd image does not rebuild the verified raw image
- Run check-beatles-bootimg.py, sync-beatles-bootfs.py --check, and display_lk2nd_is_current before archiving nokia-beatles
- Remove pre-existing release directories and .zip files before packing both boot-bananarchy-nokia-beatles.img and boot-lk2nd-nokia-beatles-display.img, and guard in check-rebuild.sh
2026-11-11 14:59:02 +02:00

70 lines
2.2 KiB
Bash
Executable File

#!/bin/sh
# Release archive builder for Bananarchy
set -eu
RAW_TARGET="${1:-nokia-argon}"
case "$RAW_TARGET" in
nokia-argon|argon) BA_TARGET="nokia-argon" ;;
nokia-beatles|beatles) BA_TARGET="nokia-beatles" ;;
nokia-tough|nokia-coconut|tough|coconut) BA_TARGET="nokia-tough" ;;
nokia-sparkler|sparkler) BA_TARGET="nokia-sparkler" ;;
nokia-leo|leo) BA_TARGET="nokia-leo" ;;
*)
echo "Usage: $0 [nokia-argon|nokia-beatles|nokia-tough|nokia-sparkler|nokia-leo]" >&2
exit 1
;;
esac
BA_REBUILD="${BA_REBUILD:-0}"
BA_VER="$(./scripts/version.sh --print)"
BA_CODENAME="$(./scripts/version.sh --print-codename)"
RELDIR="bananarchy-${BA_TARGET}-${BA_VER}-${BA_CODENAME}"
DISPLAY_IMAGE="images/boot-lk2nd-nokia-beatles-display.img"
BOOT_IMAGE="images/boot-bananarchy-nokia-beatles.img"
display_lk2nd_is_current() {
python3 scripts/check-lk2nd-beatles.py \
--image "$DISPLAY_IMAGE" \
--patch bootloader/lk2nd/nokia-beatles.patch \
--expect-fastboot 0 --expect-display 1 >/dev/null 2>&1
}
NEED_REBUILD=0
if [ ! -f "images/bananarchy-${BA_TARGET}.img" ]; then
NEED_REBUILD=1
fi
if [ "$BA_TARGET" = "nokia-beatles" ] && [ ! -f "$BOOT_IMAGE" ]; then
NEED_REBUILD=1
fi
if [ "$BA_REBUILD" = "1" ] || [ "$NEED_REBUILD" = "1" ]; then
./rebuild-image.sh "$BA_TARGET" --mkinitfs
fi
# The default 2720 lk2nd image must contain the low-bit reboot cookie, or
# "Reboot to loader" cannot return to the visible Fastboot menu. Rebuild it
# separately so a missing lk2nd binary does not invalidate a verified raw image.
if [ "$BA_TARGET" = "nokia-beatles" ] && \
{ [ "$BA_REBUILD" = "1" ] || ! display_lk2nd_is_current; }; then
./scripts/build-lk2nd-beatles.sh
fi
if [ "$BA_TARGET" = "nokia-beatles" ]; then
python3 scripts/check-beatles-bootimg.py
python3 scripts/sync-beatles-bootfs.py --check --raw-image "images/bananarchy-${BA_TARGET}.img"
display_lk2nd_is_current
fi
rm -rf "$RELDIR" "${RELDIR}.zip"
mkdir -p "$RELDIR"
cp "images/bananarchy-${BA_TARGET}.img" "$RELDIR/"
if [ "$BA_TARGET" = "nokia-beatles" ]; then
cp "$BOOT_IMAGE" "$RELDIR/"
cp "$DISPLAY_IMAGE" "$RELDIR/"
else
cp bootloader/lk2nd-msm8909.img "$RELDIR/"
fi
zip -9r "${RELDIR}.zip" "$RELDIR"
rm -rf "$RELDIR"
echo "Release $BA_VER ($BA_CODENAME) for $BA_TARGET packed into ${RELDIR}.zip"