Files
rollcall/images/build-rootfs.sh
T
Ilker ManapandClaude Fable 5.1 7fe7c26e22
CI / agent (push) Successful in 3s
CI / site (push) Successful in 3s
CI / go (push) Failing after 36s
Stateless (Warewulf-style) provisioning: profiles, node pools, overlays, dnsmasq export, compute image
Profiles bind a RAM-booted root image to overlay templates; assigning a
machine allocates a node name and management IP, writes the per-MAC PXE
entry with a per-node token and exports static leases for dnsmasq. Nodes
pull rendered overlays (hosts, slurm.conf from inventory, gres.conf, SSH
host key, munge key) through rollcall-overlay.service; the runtime refresh
timer is the heartbeat. Adds the compute-debian13 image definition and a
generic live-build root image script, CLI and web UI for profiles/assign.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-27 02:00:14 +01:00

56 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# Build a stateless (RAM-booted) root image with live-build.
#
# build-rootfs.sh <image-name>
#
# Reads images/<image-name>/{packages.list,hook.chroot,includes/} and writes
# <IMAGES_DIR>/<image-name>/{vmlinuz,initrd.img,filesystem.squashfs}, which
# rollcall serves under /images/<image-name>/ and pxelinux loads via TFTP.
set -euo pipefail
NAME=${1:?image name}
SRC=$(cd "$(dirname "$0")" && pwd)/$NAME
[ -d "$SRC" ] || { echo "no such image definition: $SRC" >&2; exit 1; }
IMAGES_DIR=${IMAGES_DIR:-/srv/rollcall/images}
BUILD=${BUILD:-/srv/rollcall/build-$NAME}
MIRROR=${MIRROR:-http://deb.debian.org/debian}
DIST=${DIST:-trixie}
AUTHKEYS=${AUTHKEYS:-/home/ilker/.ssh/authorized_keys}
OUT=$IMAGES_DIR/$NAME
mkdir -p "$BUILD" "$OUT"
cd "$BUILD"
if [ -d config ]; then lb clean --purge >/dev/null 2>&1 || true; rm -rf config; fi
lb config \
--distribution "$DIST" --architectures amd64 \
--archive-areas "main contrib non-free non-free-firmware" \
--mirror-bootstrap "$MIRROR" --mirror-binary "$MIRROR" \
--binary-images iso-hybrid --bootloaders syslinux \
--debian-installer none --memtest none \
--firmware-chroot true --firmware-binary false \
--apt-recommends false \
--bootappend-live "boot=live components" \
--linux-flavours amd64 \
--iso-volume "$NAME" --iso-application "rollcall $NAME" \
--cache-packages true --cache-indices false >/dev/null
install -m 0644 "$SRC/packages.list" "config/package-lists/$NAME.list.chroot"
mkdir -p config/includes.chroot config/hooks/live
if [ -d "$SRC/includes" ]; then cp -a "$SRC/includes/." config/includes.chroot/; fi
if [ -r "$AUTHKEYS" ]; then
install -d -m 0700 config/includes.chroot/root/.ssh
install -m 0600 "$AUTHKEYS" config/includes.chroot/root/.ssh/authorized_keys
fi
if [ -f "$SRC/hook.chroot" ]; then install -m 0755 "$SRC/hook.chroot" "config/hooks/live/0100-$NAME.hook.chroot"; fi
echo "=== lb build $NAME started $(date)"
lb build 2>&1 | tee "$BUILD/build.log" | grep -E "^P: (Begin|Build)|^E:" || true
for f in vmlinuz initrd.img filesystem.squashfs; do
src=$(ls binary/live/$f* 2>/dev/null | head -1)
[ -n "$src" ] || { echo "missing $f in binary/live (see $BUILD/build.log)" >&2; exit 1; }
install -m 0644 "$src" "$OUT/$f.new" && mv -f "$OUT/$f.new" "$OUT/$f"
done
ls -la "$OUT"
echo "=== done $(date)"