diff options
| author | Hibby <hibby@debian.org> | 2026-06-26 21:52:33 +0100 |
|---|---|---|
| committer | Hibby <hibby@debian.org> | 2026-06-26 21:52:33 +0100 |
| commit | 4dfeca51f9dcad91edd255198272e4aa640f4e47 (patch) | |
| tree | 25aaa0a82557f5275375aa44f4bcb129a6b0ccce /build-helpers.sh | |
| parent | 1232c9ca398de19ce1ed31337bffd98d4c7e69aa (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-helpers.sh')
| -rwxr-xr-x | build-helpers.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/build-helpers.sh b/build-helpers.sh index d51ac21..0e52735 100755 --- a/build-helpers.sh +++ b/build-helpers.sh @@ -753,6 +753,34 @@ run_sync() { echo "Sync complete" } +clean_pi_gen_work() { + # pi-gen leaves a multi-GB "work/" tree behind after a build (one subdir per + # stage, each containing a full rootfs). The only artifacts we keep live in + # deploy/, so wipe everything else the build generated to reclaim disk. + # work/ is created by the sudo build, so it is root-owned. + local pi_gen_dir="$1" + + if [[ -d "$pi_gen_dir/work" ]]; then + echo "Removing pi-gen work directory: $pi_gen_dir/work" + sudo rm -rf "$pi_gen_dir/work" + fi +} + +prune_old_images() { + # Keep the newest N dated images in a directory, deleting older ones along + # with their sidecar checksum files. Filenames are expected to start with a + # YYYY-MM-DD date so the glob never matches "hibbian-latest"-style symlinks. + local dir="$1" + local keep="${2:-2}" + + mapfile -t images < <(ls -t "$dir"/[0-9][0-9][0-9][0-9]-*.img 2>/dev/null) + + for image in "${images[@]:$keep}"; do + echo "Removing old image: $(basename "$image")" + rm -f "$image" "$image.sha256" + done +} + extract_date() { local name="$1" |
