summaryrefslogtreecommitdiff
path: root/build-arm64.sh
diff options
context:
space:
mode:
authorHibby <hibby@debian.org>2026-06-26 21:52:33 +0100
committerHibby <hibby@debian.org>2026-06-26 21:52:33 +0100
commit4dfeca51f9dcad91edd255198272e4aa640f4e47 (patch)
tree25aaa0a82557f5275375aa44f4bcb129a6b0ccce /build-arm64.sh
parent1232c9ca398de19ce1ed31337bffd98d4c7e69aa (diff)
arm64: keep sudo alive, reclaim work/ space, prune old images
- Prime sudo and run a background keep-alive so the post-build chown no longer blocks on a hidden password prompt after the long build expires the credential cache. - Remove the multi-GB pi-gen work/ tree once the image is in deploy/. - Prune deploy/ to the newest 2 dated images on every run.
Diffstat (limited to 'build-arm64.sh')
-rwxr-xr-xbuild-arm64.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/build-arm64.sh b/build-arm64.sh
index 1061f9d..43c3bfc 100755
--- a/build-arm64.sh
+++ b/build-arm64.sh
@@ -49,6 +49,16 @@ else
# ---- RUN YOUR PI-GEN BUILD HERE ----
# Adjust this to your actual invocation
+ # Prime sudo and keep the credential cache alive for the whole run. The
+ # pi-gen build runs for far longer than sudo's default timeout, so without
+ # this the later chown would silently block on a password prompt that has
+ # been redirected into the logfile.
+ log_step "arm64: priming sudo credentials"
+ sudo -v
+ ( while true; do sudo -n true; sleep 60; kill -0 "$$" 2>/dev/null || exit; done ) &
+ SUDO_KEEPALIVE_PID=$!
+ trap 'kill "$SUDO_KEEPALIVE_PID" 2>/dev/null || true' EXIT
+
log_step "arm64: running pi-gen build"
pushd "$PI_GEN_DIR" >/dev/null
sudo CLEAN=1 ./build.sh >> "$LOGFILE" 2>&1
@@ -72,9 +82,19 @@ else
mv "$IMG" "$FINAL_IMG" >> "$LOGFILE" 2>&1
IMG_FILE="$FINAL_IMG"
+
+ # The image is safely in deploy/ now; reclaim the huge pi-gen work tree.
+ log_step "arm64: cleaning pi-gen work directory"
+ clean_pi_gen_work "$PI_GEN_DIR" >> "$LOGFILE" 2>&1
fi
# -----------------------------
+# 2b) Retention: keep newest 2 local images
+# -----------------------------
+log_step "arm64: pruning old local images (keeping newest 2)"
+prune_old_images "$BUILD_DIR" 2 >> "$LOGFILE" 2>&1
+
+# -----------------------------
# 3) Transfer IMG to main server
# -----------------------------
log_step "arm64: transferring $(basename "$IMG_FILE") to $REMOTE:$REMOTE_DIR"