Add PROJECT=ubuntu-test-iso for fast end-to-end ISO testing

Builds a real Ubuntu ISO in ~2-3 minutes (vs 30-60 for production)
by keeping the package set minimal (casper + linux-generic only) and
using lz4 squashfs compression.

Design:
- Two-pass layered build (PASSES_TO_LAYERS=true):
  - base: installs casper
  - base.generic (LIVE_PASSES): installs linux-generic, triggers
    update-initramfs with CASPER_GENERATE_UUID=1 to embed UUID
- No package pool (POOL_SEED_NAME=), no universe, amd64 only
- SQUASHFS_COMP=lz4 (~10x faster than xz); create_squashfs() now
  respects ${SQUASHFS_COMP:-xz} so all other projects are unaffected
- Germinate is skipped (only add_package is used, no add_task/pool)

New files:
- live-build/ubuntu-test-iso/hooks/01-test-iso.chroot_early
- live-build/ubuntu-test-iso/hooks/02-test-iso-kernel.binary

Modified:
- live-build/functions: honour $SQUASHFS_COMP in create_squashfs()
- live-build/gen-iso-ids: add ubuntu-test-iso -> Ubuntu-Test-ISO
- live-build/auto/config: IMAGEFORMAT, fs, COMPONENTS, germinate
  skip, SQUASHFS_COMP default + per-project override, project block,
  write SQUASHFS_COMP to config/common, lxd exclusion, hook copying

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
michael.hudson@canonical.com 2026-02-22 22:27:15 +13:00
parent 9861d393aa
commit 04e2aea648
No known key found for this signature in database
GPG Key ID: 80E627A0AB757E23
5 changed files with 70 additions and 15 deletions

View File

@ -390,7 +390,7 @@ if [ -z "${IMAGEFORMAT:-}" ]; then
;; ;;
esac esac
;; ;;
ubuntu-server:live|ubuntu-mini-iso:|ubuntu-core-installer:*) ubuntu-server:live|ubuntu-mini-iso:|ubuntu-test-iso:|ubuntu-core-installer:*)
IMAGEFORMAT=plain IMAGEFORMAT=plain
;; ;;
esac esac
@ -426,7 +426,7 @@ case $IMAGEFORMAT in
ubuntu-server:live|ubuntu-core-installer:*) ubuntu-server:live|ubuntu-core-installer:*)
touch config/universe-enabled touch config/universe-enabled
;; ;;
ubuntu-mini-iso:) ubuntu-mini-iso:|ubuntu-test-iso:)
fs=none fs=none
;; ;;
*) *)
@ -636,7 +636,7 @@ case $PROJECT in
esac esac
case $PROJECT in case $PROJECT in
ubuntu-mini-iso) ubuntu-mini-iso|ubuntu-test-iso)
COMPONENTS='main' COMPONENTS='main'
;; ;;
edubuntu|ubuntu-budgie|ubuntucinnamon|ubuntukylin) edubuntu|ubuntu-budgie|ubuntucinnamon|ubuntukylin)
@ -653,7 +653,14 @@ case $SUBPROJECT in
;; ;;
esac esac
if ! [ -e config/germinate-output/structure ]; then case $PROJECT in
ubuntu-test-iso)
# ubuntu-test-iso uses only add_package (not add_task) and has no
# pool, so germinate output is never needed.
touch config/germinate-output/structure
;;
*)
if ! [ -e config/germinate-output/structure ]; then
echo "Running germinate..." echo "Running germinate..."
if [ -n "$COMPONENTS" ]; then if [ -n "$COMPONENTS" ]; then
GERMINATE_ARG="-c $(echo $COMPONENTS | sed -e's/ \+/,/g')" GERMINATE_ARG="-c $(echo $COMPONENTS | sed -e's/ \+/,/g')"
@ -661,7 +668,9 @@ if ! [ -e config/germinate-output/structure ]; then
(cd config/germinate-output && germinate --no-rdepends --no-installer \ (cd config/germinate-output && germinate --no-rdepends --no-installer \
-S $SEEDMIRROR -m $MIRROR -d $SUITE,$SUITE-updates \ -S $SEEDMIRROR -m $MIRROR -d $SUITE,$SUITE-updates \
-s $FLAVOUR.$SUITE $GERMINATE_ARG -a ${ARCH_VARIANT:-$ARCH}) -s $FLAVOUR.$SUITE $GERMINATE_ARG -a ${ARCH_VARIANT:-$ARCH})
fi fi
;;
esac
# ISO build configuration. These defaults are overridden per-project below. # ISO build configuration. These defaults are overridden per-project below.
# #
@ -674,6 +683,9 @@ MAKE_ISO=no
# - "server-ship-live" for Ubuntu Server (includes server-specific packages) # - "server-ship-live" for Ubuntu Server (includes server-specific packages)
# - "" (empty) for images without a pool, like Ubuntu Core Installer # - "" (empty) for images without a pool, like Ubuntu Core Installer
POOL_SEED_NAME=ship-live POOL_SEED_NAME=ship-live
# SQUASHFS_COMP: compression algorithm for squashfs images. lz4 is ~10x
# faster than xz and useful for test builds that don't need small images.
SQUASHFS_COMP=xz
# Common functionality for layered desktop images # Common functionality for layered desktop images
common_layered_desktop_image() { common_layered_desktop_image() {
@ -1179,6 +1191,24 @@ case $PROJECT in
esac esac
;; ;;
ubuntu-test-iso)
OPTS="${OPTS:+$OPTS }--bootstrap-flavour=minimal"
OPTS="${OPTS:+$OPTS }--linux-packages=none --initramfs=none"
KERNEL_FLAVOURS=none
BINARY_REMOVE_LINUX=false
MAKE_ISO=yes
POOL_SEED_NAME=
SQUASHFS_COMP=lz4
PASSES_TO_LAYERS=true
add_package base casper
add_package base.generic linux-virtual
LIVE_PASSES="base.generic"
case $ARCH in
amd64) ;;
*) echo "ubuntu-test-iso only supports amd64"; exit 1 ;;
esac
;;
ubuntu-base|ubuntu-oci) ubuntu-base|ubuntu-oci)
OPTS="${OPTS:+$OPTS }--bootstrap-flavour=minimal" OPTS="${OPTS:+$OPTS }--bootstrap-flavour=minimal"
;; ;;
@ -1408,6 +1438,7 @@ if [ -n "$PASSES" ]; then
fi fi
echo "MAKE_ISO=\"$MAKE_ISO\"" >> config/common echo "MAKE_ISO=\"$MAKE_ISO\"" >> config/common
echo "POOL_SEED_NAME=\"$POOL_SEED_NAME\"" >> config/common echo "POOL_SEED_NAME=\"$POOL_SEED_NAME\"" >> config/common
echo "SQUASHFS_COMP=\"$SQUASHFS_COMP\"" >> config/common
if [ -n "$NO_SQUASHFS_PASSES" ]; then if [ -n "$NO_SQUASHFS_PASSES" ]; then
echo "NO_SQUASHFS_PASSES=\"$NO_SQUASHFS_PASSES\"" >> config/common echo "NO_SQUASHFS_PASSES=\"$NO_SQUASHFS_PASSES\"" >> config/common
fi fi
@ -1443,7 +1474,7 @@ rm -fv /etc/ssl/private/ssl-cert-snakeoil.key \
EOF EOF
case $PROJECT in case $PROJECT in
ubuntu-cpc|ubuntu-core|ubuntu-base|ubuntu-oci|ubuntu-wsl|ubuntu-mini-iso) ubuntu-cpc|ubuntu-core|ubuntu-base|ubuntu-oci|ubuntu-wsl|ubuntu-mini-iso|ubuntu-test-iso)
# ubuntu-cpc gets this added in 025-create-groups.chroot, and we do # ubuntu-cpc gets this added in 025-create-groups.chroot, and we do
# not want this group in projects that are effectively just chroots # not want this group in projects that are effectively just chroots
;; ;;
@ -1531,7 +1562,7 @@ fi
case $PROJECT:${SUBPROJECT:-} in case $PROJECT:${SUBPROJECT:-} in
ubuntu-cpc:*|ubuntu-server:live|ubuntu:desktop-preinstalled| \ ubuntu-cpc:*|ubuntu-server:live|ubuntu:desktop-preinstalled| \
ubuntu-wsl:*|ubuntu-mini-iso:*|ubuntu:|ubuntu:dangerous|ubuntu-oem:*| \ ubuntu-wsl:*|ubuntu-mini-iso:*|ubuntu-test-iso:*|ubuntu:|ubuntu:dangerous|ubuntu-oem:*| \
ubuntustudio:*|edubuntu:*|ubuntu-budgie:*|ubuntucinnamon:*|xubuntu:*| \ ubuntustudio:*|edubuntu:*|ubuntu-budgie:*|ubuntucinnamon:*|xubuntu:*| \
ubuntukylin:*|ubuntu-mate:*|ubuntu-core-installer:*|lubuntu:*) ubuntukylin:*|ubuntu-mate:*|ubuntu-core-installer:*|lubuntu:*)
# Ensure that most things e.g. includes.chroot are copied as is # Ensure that most things e.g. includes.chroot are copied as is

View File

@ -408,7 +408,7 @@ create_squashfs() {
squashfs_file="$2" squashfs_file="$2"
config_dir="$PWD/config" config_dir="$PWD/config"
(cd $rootfs_dir && (cd $rootfs_dir &&
mksquashfs . $squashfs_file -no-progress -xattrs -comp xz \ mksquashfs . $squashfs_file -no-progress -xattrs -comp "${SQUASHFS_COMP:-xz}" \
-ef "$config_dir/squashfs-exclude-files") -ef "$config_dir/squashfs-exclude-files")
} }

View File

@ -42,6 +42,7 @@ project_to_capproject_map = {
"ubuntu-core-installer": "Ubuntu-Core-Installer", "ubuntu-core-installer": "Ubuntu-Core-Installer",
"ubuntu-mate": "Ubuntu-MATE", "ubuntu-mate": "Ubuntu-MATE",
"ubuntu-mini-iso": "Ubuntu-Mini-ISO", "ubuntu-mini-iso": "Ubuntu-Mini-ISO",
"ubuntu-test-iso": "Ubuntu-Test-ISO",
"ubuntu-oem": "Ubuntu OEM", "ubuntu-oem": "Ubuntu OEM",
"ubuntu-server": "Ubuntu-Server", "ubuntu-server": "Ubuntu-Server",
"ubuntu-unity": "Ubuntu-Unity", "ubuntu-unity": "Ubuntu-Unity",

View File

@ -0,0 +1,8 @@
#!/bin/sh
set -eu
mkdir -p "etc/initramfs-tools/conf.d"
cat > etc/initramfs-tools/conf.d/casperize.conf <<EOF
export CASPER_GENERATE_UUID=1
EOF

View File

@ -0,0 +1,15 @@
#!/bin/sh
# Copy kernel/initrd artifacts for isobuilder to consume.
# The MAKE_ISO flow in auto/build expects ${PREFIX}.kernel-* and
# ${PREFIX}.initrd-* files. With --linux-packages=none live-build won't
# create them, so we do it here (mirroring ubuntu-mini-iso's approach).
# This hook runs for every pass; exit early when the kernel isn't present.
set -eu
[ -e chroot/boot/vmlinuz ] || exit 0
[ -e chroot/boot/initrd.img ] || exit 0
PREFIX="livecd.${PROJECT}"
cp chroot/boot/vmlinuz "${PREFIX}.kernel-generic"
cp chroot/boot/initrd.img "${PREFIX}.initrd-generic"