diff options
| author | Hibby <hibby@Hibbys-MacBook-Air.local> | 2026-04-26 10:29:42 -0500 |
|---|---|---|
| committer | Hibby <hibby@Hibbys-MacBook-Air.local> | 2026-04-26 10:29:42 -0500 |
| commit | eec33b38dd978522a5b87945f1d09100dbaa2061 (patch) | |
| tree | 085d8daefbf72e1508793cf443ebf80e7dac2fe9 | |
| parent | 0b9c299f4a05ac5c01bfde398d0c26aca2276904 (diff) | |
Include arm64 build file
| -rwxr-xr-x | build-arm64.sh | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/build-arm64.sh b/build-arm64.sh new file mode 100755 index 0000000..7aa93c7 --- /dev/null +++ b/build-arm64.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env bash +set -euo pipefail + +# ----------------------------- +# Config +# ----------------------------- +BUILD_DIR="$PWD/pi-gen/deploy" +REMOTE="live-build@builder.hibbian.org" +REMOTE_DIR="/opt/livebuild/output/arm64" + +TODAY=$(date +%Y-%m-%d) +IMG_NAME="${TODAY}-Hibbian-arm64.img" +ZIP_NAME="${TODAY}-Hibbian-arm64.img.zip" + +# ----------------------------- +# Helpers +# ----------------------------- +has_today_local() { + for f in "$BUILD_DIR"/"$IMG_NAME"; do + [[ -e "$f" && -s "$f" ]] && return 0 + done + return 1 +} + +get_local_img() { + for f in "$BUILD_DIR"/"$IMG_NAME"; do + [[ -e "$f" && -s "$f" ]] && { echo "$f"; return 0; } + done + return 1 +} + +has_today_remote() { + ssh "$REMOTE" " + for f in $REMOTE_DIR/$ZIP_NAME; do + [ -e \"\$f\" ] && [ -s \"\$f\" ] && exit 0 + done + exit 1 + " +} + +# ----------------------------- +# 1) Remote check (authoritative) +# ----------------------------- +if has_today_remote; then + echo "✔ arm64 build already exists on main server — skipping build + transfer" + + ssh "$REMOTE" "/opt/livebuild/build.sh stats" + exit 0 +fi + +# ----------------------------- +# 2) Local check (reuse) +# ----------------------------- +if has_today_local; then + echo "✔ Using existing local image" + IMG_FILE="$(get_local_img)" +else + echo "No local image — running pi-gen..." + + # ---- RUN YOUR PI-GEN BUILD HERE ---- + # Adjust this to your actual invocation + + pushd "$PWD/pi-gen" >/dev/null + sudo CLEAN=1 ./build.sh + popd >/dev/null + sudo chown -R "$USER:$USER" "$BUILD_DIR" + + # Find newest image + IMG="$(ls -t "$BUILD_DIR"/*.img 2>/dev/null | head -n 1 || true)" + + if [[ -z "$IMG" ]]; then + echo "ERROR: No image produced" + exit 1 + fi + + FINAL_IMG="$BUILD_DIR/$IMG_NAME" + + mv "$IMG" "$FINAL_IMG" + + IMG_FILE="$FINAL_IMG" +fi + +# ----------------------------- +# 3) Transfer IMG to main server +# ----------------------------- +echo "Transferring $(basename "$IMG_FILE")..." +rsync -avz "$IMG_FILE" "$REMOTE:$REMOTE_DIR/" + +# ----------------------------- +# 4) Remote: zip + checksum + publish +# ----------------------------- +echo "Triggering remote packaging + publish..." + +ssh "$REMOTE" " + set -e + + cd $REMOTE_DIR + + IMG='$IMG_NAME' + ZIP='$ZIP_NAME' + + if [ -f \"\$IMG\" ]; then + echo 'Generating checksum for IMG...' + sha256sum \"\$IMG\" > \"\$IMG.sha256\" + + echo 'Updating checksum symlink...' + ln -sfn \"\$IMG.sha256\" hibbian-latest.img.sha256 + + echo 'Zipping image...' + zip -q \"\$ZIP\" \"\$IMG\" + + echo 'Updating ZIP symlink...' + ln -sfn \"\$ZIP\" hibbian-latest.img.zip + + echo 'Removing raw image...' + rm -f \"\$IMG\" + fi +" + +echo "✔ Done" |
