mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 01:46:18 -05:00
Two parallel live-build configs (debian-live-config/ for the installer
ISO and wrolpi-portable/ for the Live USB) carry the same chroot hook
with subtly different fixes — the portable side had accumulated the
better implementation (npm build, SHA-pinned blobs, dynamic Postgres
version, partition-by-start-sector, controller.yaml sentinel, autologin,
branding). This commit folds those improvements into debian-live-config/
and retires wrolpi-portable/.
The Postgres data + config directories now bind-mount to
/media/wrolpi/config/postgresql/{data,config} regardless of deployment
shape (Live USB, Calamares-installed system with external drive,
Calamares-installed system with no external drive). Result: pulling
a WROLPi external drive from one host and plugging into another
brings the entire indexed library along — no re-indexing. Previously
the DB lived on /mnt/persistence/postgresql-{data,config} on Portable
and on /var/lib/postgresql (root) everywhere else; moving a drive
required rebuilding the DB on the new host.
Single wrolpi-bootstrap.{sh,service} replaces wrolpi-portable-bootstrap.
The script detects deployment by probing for a live-boot medium mount:
present → Live (create persistence partition if missing); absent →
Installed (skip partition step; Postgres bind-mount and cluster init
still run). --debian-installer is dropped from lb config; Calamares
will land in a follow-up commit as the graphical installer.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
141 lines
5.5 KiB
Bash
Executable file
141 lines
5.5 KiB
Bash
Executable file
#!/bin/bash
|
|
# Build the WROLPi Debian Live + installer ISO.
|
|
#
|
|
# Output: an iso-hybrid image that boots into a full WROLPi system on any
|
|
# x86 PC. Users can run WROLPi directly off the USB (persistence partition
|
|
# created on first boot) or install to disk via the Calamares launcher on
|
|
# the desktop. Calamares wiring lands in phase 2; phase 1 ships the
|
|
# live-only flow.
|
|
#
|
|
# https://live-team.pages.debian.net/live-manual/html/live-manual/index.en.html
|
|
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
BUILD_DIR=/var/tmp/wrolpi-build-debian
|
|
|
|
Help() {
|
|
echo "Build WROLPi Debian Live ISO image."
|
|
echo
|
|
echo "Syntax: build.sh [-h] [-b BRANCH]"
|
|
echo "options:"
|
|
echo "h Print this help."
|
|
echo "b Build from this git BRANCH (default: 'release')."
|
|
echo
|
|
}
|
|
|
|
BRANCH="release"
|
|
while getopts ":hb:" option; do
|
|
case $option in
|
|
h) Help; exit ;;
|
|
b) BRANCH="${OPTARG}" ;;
|
|
*) echo "Error: Invalid option"; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
# Get version from the target git branch (not local checkout) so output
|
|
# filename matches actual content. Strip whitespace so stray newlines or
|
|
# spaces in version.txt do not corrupt the lb config metadata strings.
|
|
VERSION=$(curl -sL "https://raw.githubusercontent.com/lrnselfreliance/wrolpi/${BRANCH}/wrolpi/version.txt" | tr -d '[:space:]')
|
|
if [ -z "${VERSION}" ]; then
|
|
echo "ERROR: Could not fetch version from branch '${BRANCH}'"
|
|
exit 1
|
|
fi
|
|
echo "Building WROLPi version: ${VERSION} from branch: ${BRANCH}"
|
|
|
|
# Re-execute this script if it wasn't called with sudo.
|
|
if [ $EUID != 0 ]; then
|
|
sudo "$0" "$@"
|
|
exit $?
|
|
fi
|
|
|
|
# Clear out old builds. Strip immutable flag from blob files first — the
|
|
# chroot hook applies chattr +i to /opt/wrolpi-blobs/*; without removing
|
|
# that here, rm -rf leaves them behind and the next lb build's
|
|
# chroot_includes_after_packages rsync fails with "Operation not permitted"
|
|
# trying to overwrite them.
|
|
if [ -d "${BUILD_DIR}" ]; then
|
|
find "${BUILD_DIR}" -path '*/opt/wrolpi-blobs/*' -type f -exec chattr -i {} + 2>/dev/null || true
|
|
rm -rf "${BUILD_DIR}"
|
|
fi
|
|
mkdir -p "${BUILD_DIR}"
|
|
cd "${BUILD_DIR}" || (echo "Work directory must exist" && exit 1)
|
|
set -e
|
|
|
|
# Pure live config — no --debian-installer flags. The graphical installer
|
|
# (Calamares) is added in phase 2 as a package + desktop launcher rather
|
|
# than via lb's --debian-installer mechanism. noswap prevents the live
|
|
# system from activating swap partitions found on the host machine's
|
|
# internal disks.
|
|
lb config \
|
|
--binary-images iso-hybrid \
|
|
--mode debian \
|
|
--architectures amd64 \
|
|
--linux-flavours amd64 \
|
|
--distribution bookworm \
|
|
--archive-areas "main contrib non-free non-free-firmware" \
|
|
--updates true \
|
|
--security true \
|
|
--apt-recommends false \
|
|
--firmware-binary true \
|
|
--firmware-chroot true \
|
|
--win32-loader false \
|
|
--checksums sha512 \
|
|
--clean \
|
|
--color \
|
|
--linux-packages "linux-image linux-headers" \
|
|
--memtest memtest86+ \
|
|
--bootappend-live "boot=live components quiet splash noswap persistence persistence-storage=filesystem persistence-media=removable persistence-label=persistence live-config.username=wrolpi live-config.user-fullname=WROLPi live-config.hostname=wrolpi" \
|
|
--iso-volume "WROLPi v${VERSION}" \
|
|
--iso-application "WROLPi v${VERSION}" \
|
|
--iso-preparer WROLPi \
|
|
--iso-publisher https://wrolpi.org
|
|
|
|
rsync -a "${SCRIPT_DIR}/config" "${BUILD_DIR}/"
|
|
|
|
# Write branch config for hook script.
|
|
mkdir -p "${BUILD_DIR}/config/includes.chroot/opt/wrolpi-blobs"
|
|
echo "${BRANCH}" > "${BUILD_DIR}/config/includes.chroot/opt/wrolpi-branch"
|
|
|
|
# Cache directory for downloaded blobs (persists across builds).
|
|
BLOB_CACHE="${SCRIPT_DIR}/files"
|
|
mkdir -p "${BLOB_CACHE}"
|
|
|
|
# Download map fonts (skip if cached).
|
|
if [ ! -f "${BLOB_CACHE}/map-fonts.tar.gz" ]; then
|
|
echo "Downloading map fonts..."
|
|
mkdir -p /tmp/map-fonts-dl
|
|
curl -fsSL https://github.com/protomaps/basemaps-assets/archive/refs/heads/main.tar.gz \
|
|
| tar -xz --strip-components=1 -C /tmp/map-fonts-dl basemaps-assets-main/fonts
|
|
tar -czf "${BLOB_CACHE}/map-fonts.tar.gz" -C /tmp/map-fonts-dl fonts
|
|
rm -rf /tmp/map-fonts-dl
|
|
fi
|
|
[[ -f "${BLOB_CACHE}/map-fonts.tar.gz" && -s "${BLOB_CACHE}/map-fonts.tar.gz" ]] || \
|
|
(echo "ERROR: Failed to download map fonts!" && exit 1)
|
|
|
|
# Download map overview (skip if cached).
|
|
if [ ! -f "${BLOB_CACHE}/map-overview.pmtiles" ]; then
|
|
echo "Downloading map overview..."
|
|
curl -fsSL https://wrolpi.nyc3.cdn.digitaloceanspaces.com/maps/map-overview.pmtiles \
|
|
-o "${BLOB_CACHE}/map-overview.pmtiles"
|
|
fi
|
|
[[ -f "${BLOB_CACHE}/map-overview.pmtiles" && -s "${BLOB_CACHE}/map-overview.pmtiles" ]] || \
|
|
(echo "ERROR: Failed to download map overview!" && exit 1)
|
|
|
|
# Copy cached blobs into the live image.
|
|
cp "${BLOB_CACHE}/map-fonts.tar.gz" "${BUILD_DIR}/config/includes.chroot/opt/wrolpi-blobs/"
|
|
cp "${BLOB_CACHE}/map-overview.pmtiles" "${BUILD_DIR}/config/includes.chroot/opt/wrolpi-blobs/"
|
|
|
|
# pipefail so an lb build failure isn't masked by tee's success exit code.
|
|
set -o pipefail
|
|
time nice -n 18 lb build 2>&1 | tee "${SCRIPT_DIR}/build.log"
|
|
set +o pipefail
|
|
|
|
grep "9999-wrolpi.hook.chroot completed" "${SCRIPT_DIR}/build.log" >/dev/null 2>&1 || (echo "build hook failed!" && exit 1)
|
|
|
|
cp "${BUILD_DIR}"/*iso "${SCRIPT_DIR}/" || (echo "Build failed. No ISOs were found!" && exit 1)
|
|
chmod 644 "${SCRIPT_DIR}"/*iso
|
|
chown "${SUDO_UID:-1000}:${SUDO_GID:-1000}" "${SCRIPT_DIR}"/*iso
|
|
DEST="${SCRIPT_DIR}/WROLPi-v${VERSION}-amd64.iso"
|
|
[ -f "${DEST}" ] && (echo "Removing conflicting ISO" && rm "${DEST}")
|
|
mv "${SCRIPT_DIR}"/*.iso "${DEST}"
|
|
|
|
echo "Build has completed. ISO output ${DEST}"
|