diff options
| author | Hibby <hibby@Hibbys-MacBook-Air.local> | 2026-05-04 22:43:33 -0500 |
|---|---|---|
| committer | Hibby <hibby@Hibbys-MacBook-Air.local> | 2026-05-04 22:43:33 -0500 |
| commit | cedd87d90a1c948d22f13ae1654a2fa06c9d2f39 (patch) | |
| tree | 6d3d8325ab4a34c532a23be43eccfb83bf308929 | |
| parent | c47d8437b7be5144b7cf72fd7d5789a3d34383b5 (diff) | |
Simplify live-build cleanup and ISO selection
| -rwxr-xr-x | build.sh | 45 |
1 files changed, 11 insertions, 34 deletions
@@ -10,11 +10,12 @@ OUTPUT_DIR="/opt/livebuild/output" AMD64_DIR="$OUTPUT_DIR/amd64" ARM64_DIR="$OUTPUT_DIR/arm64" REMOTE_TARGET="hibby@hibbian.org:/var/www/download/" -LOGFILE="${TIMESTAMP}-build-amd64.log" +LOGFILE_BASENAME="${TIMESTAMP}-build-amd64.log" FINAL_NAME="${TIMESTAMP}-Hibbian-amd64.iso" LIVE_BUILD_SUCCESS_GRACE_SECONDS="${LIVE_BUILD_SUCCESS_GRACE_SECONDS:-300}" SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) +LOGFILE="$SCRIPT_DIR/$LOGFILE_BASENAME" cd "$SCRIPT_DIR" # shellcheck source=build-helpers.sh @@ -26,50 +27,30 @@ run_build() { mkdir -p "$WORKDIR" "$OUTPUT_DIR" "$AMD64_DIR" "$ARM64_DIR" if has_today_build "$AMD64_DIR" "amd64.iso"; then - echo "✔ Build already exists for today — skipping build" + log_step "Build already exists for today; skipping build" generate_links_notes run_stats return 0 fi - echo "No build for today — proceeding..." + log_step "No build for today; proceeding" ensure_git_repo_updated "$REPO_URL" "$WORKDIR/config" "$LOGFILE" cd "$WORKDIR/config" + echo "Cleaning previous live-build state..." >> "$LOGFILE" + sudo lb clean --purge >> "$LOGFILE" 2>&1 + # Run live-build config echo "Running lb config..." >> "$LOGFILE" lb config >> "$LOGFILE" 2>&1 - echo "Cleaning previous live-build binary output..." >> "$LOGFILE" - sudo lb clean --binary >> "$LOGFILE" 2>&1 - # Build (must be root) echo "Running lb build..." >> "$LOGFILE" - remove_existing_work_isos - BUILD_MARKER=$(mktemp "$WORKDIR/config/.hibbian-build-start.XXXXXX") - touch "$BUILD_MARKER" run_live_build log_step "lb build complete; starting post_build" post_build - rm -f "$BUILD_MARKER" -} - -remove_existing_work_isos() { - local stale_isos=() - - mapfile -t stale_isos < <(find . -maxdepth 1 -type f -name '*.iso' -print 2>/dev/null | sort) - - if (( ${#stale_isos[@]} == 0 )); then - return 0 - fi - - log_step "removing ${#stale_isos[@]} stale ISO(s) before live-build" - - for iso in "${stale_isos[@]}"; do - rm -f "$iso" - done } run_live_build() { @@ -117,6 +98,7 @@ run_live_build() { fi if (( status != 0 )); then + log_step "lb build failed with exit status $status" return "$status" fi } @@ -130,18 +112,13 @@ post_build() { log_step "post_build: entering $WORKDIR/config" cd "$WORKDIR/config" - log_step "post_build: finding ISO produced by this build" - - if [[ -n "${BUILD_MARKER:-}" && -f "$BUILD_MARKER" ]]; then - mapfile -t iso_candidates < <(find . -maxdepth 1 -type f -name '*.iso' -newer "$BUILD_MARKER" -printf '%T@ %p\n' 2>/dev/null | sort -nr | cut -d' ' -f2-) - else - mapfile -t iso_candidates < <(find . -maxdepth 1 -type f -name '*.iso' -newermt "$TIMESTAMP 00:00:00" -printf '%T@ %p\n' 2>/dev/null | sort -nr | cut -d' ' -f2-) - fi + log_step "post_build: finding live-build ISO" + mapfile -t iso_candidates < <(find . -maxdepth 1 -type f -name '*.iso' -print 2>/dev/null | sort) ISO="${iso_candidates[0]:-}" if [[ -z "$ISO" ]]; then - echo "ERROR: live-build did not produce an ISO; refusing to publish a stale image" >> "$LOGFILE" + echo "ERROR: live-build did not produce an ISO" >> "$LOGFILE" exit 1 fi |
