#!/bin/bash # Build a stateless (RAM-booted) root image with live-build. # # build-rootfs.sh # # Reads images//{packages.list,hook.chroot,includes/} and writes # //{vmlinuz,initrd.img,filesystem.squashfs}, which # rollcall serves under /images// 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)"