74 lines
2.8 KiB
Bash
Executable file
74 lines
2.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Ensure that the live ISO is always up-to-date with any changes to the
|
|
# installer, CLI, desktop QML, or live scripts.
|
|
#
|
|
# If the ISO does not exist or if any source input is newer than the ISO,
|
|
# this script rebuilds the static binaries and repacks the fresh ISO.
|
|
set -euo pipefail
|
|
|
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
iso_path="${PHOEBUS_ISO:-$repo_root/installer/live/phoebus-installer-amd64.iso}"
|
|
|
|
is_stale=0
|
|
|
|
if [[ ! -f "$iso_path" ]]; then
|
|
is_stale=1
|
|
reason="ISO file does not exist ($iso_path)"
|
|
else
|
|
# Find any input newer than the ISO
|
|
newer_file="$(find \
|
|
"$repo_root/installer-rs/crates" \
|
|
"$repo_root/installer-rs/Cargo.toml" \
|
|
"$repo_root/installer-rs/Cargo.lock" \
|
|
"$repo_root/installer/live/desktop" \
|
|
"$repo_root/installer/live/build.sh" \
|
|
"$repo_root/installer/live/livefs-hook.sh" \
|
|
"$repo_root/installer/live/live-packages.list" \
|
|
"$repo_root/installer/live/install-help.txt" \
|
|
-newer "$iso_path" 2>/dev/null | head -n 1 || true)"
|
|
|
|
if [[ -n "$newer_file" ]]; then
|
|
is_stale=1
|
|
reason="newer input detected: $newer_file"
|
|
fi
|
|
fi
|
|
|
|
if [[ "$is_stale" -eq 0 && "${FORCE_REBUILD:-0}" != "1" ]]; then
|
|
echo "Live ISO is up to date: $iso_path"
|
|
exit 0
|
|
fi
|
|
|
|
echo "======================================================================"
|
|
echo "Live ISO needs rebuild (${reason:-forced rebuild})"
|
|
echo "Rebuilding static binaries and packaging fresh live ISO..."
|
|
echo "======================================================================"
|
|
|
|
# 1. Build fresh static release binaries
|
|
echo ">> Compiling static phoebus-installer and sys..."
|
|
(
|
|
cd "$repo_root/installer-rs"
|
|
RUSTFLAGS="-C target-feature=+crt-static" \
|
|
cargo build --release -p phoebus-installer --bins --target x86_64-unknown-linux-gnu
|
|
)
|
|
|
|
# 2. Build live ISO with rootfs reuse (fast repack with latest binaries & desktop)
|
|
echo ">> Rebuilding live ISO ($iso_path)..."
|
|
(
|
|
cd "$repo_root"
|
|
PHOEBUS_REUSE_ROOTFS=1 bash "$repo_root/installer/live/build.sh"
|
|
)
|
|
|
|
# 3. Synchronize host HTTP server payload if running
|
|
serve_dir="/home/dominic/vmlab/serve"
|
|
if [[ -d "$serve_dir" ]]; then
|
|
echo ">> Updating local server payload in $serve_dir..."
|
|
target_rel="$repo_root/installer-rs/target/x86_64-unknown-linux-gnu/release"
|
|
cp -f "$target_rel/phoebus-installer" "$serve_dir/phoebus-installer" 2>/dev/null || true
|
|
cp -f "$target_rel/sys" "$serve_dir/sys" 2>/dev/null || true
|
|
(cd "$repo_root/installer/live/desktop" && tar czf "$serve_dir/desktop.tar.gz" *) 2>/dev/null || true
|
|
fi
|
|
|
|
echo "======================================================================"
|
|
echo "Live ISO is now fresh and matches all current source changes!"
|
|
echo "ISO: $iso_path ($(du -h "$iso_path" | cut -f1))"
|
|
echo "======================================================================"
|