From 1906a44413cf8130e3ce99dad43a7e4711c2c53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Sun, 10 May 2026 19:04:06 +0200 Subject: [PATCH] image-builder: support building extension images without /sbin/init check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extension images (e.g. the CoCo guest components extension) are not full root filesystems -- they contain only the binaries and configuration that get bind-mounted into the real rootfs at boot. The existing check_rootfs() validation requires /sbin/init and systemd, which are not present in extension images. Add a SKIP_ROOTFS_CHECK environment variable that, when set to "yes", bypasses the check_rootfs() call. Forward the variable into the container environment when using the Docker-based build path so it works in both direct and containerised invocations. Signed-off-by: Fabiano FidĂȘncio Assisted-by: Cursor --- tools/osbuilder/image-builder/image_builder.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/osbuilder/image-builder/image_builder.sh b/tools/osbuilder/image-builder/image_builder.sh index 5d98c98aff..490edde19c 100755 --- a/tools/osbuilder/image-builder/image_builder.sh +++ b/tools/osbuilder/image-builder/image_builder.sh @@ -179,6 +179,7 @@ build_with_container() { --env NSDAX_BIN="${nsdax_bin}" \ --env SKIP_DAX_HEADER="${SKIP_DAX_HEADER}" \ --env MEASURED_ROOTFS="${MEASURED_ROOTFS}" \ + --env SKIP_ROOTFS_CHECK="${SKIP_ROOTFS_CHECK:-no}" \ --env SELINUX="${SELINUX}" \ --env DEBUG="${DEBUG}" \ --env ARCH="${ARCH}" \ @@ -456,6 +457,12 @@ setup_selinux() { } setup_systemd() { + # Extension content images (e.g. the gpu extension) carry no /etc and are not + # bootable systemd rootfses, so there is nothing to set up here. + if [[ ! -d "${mount_dir}/etc" ]]; then + info "No /etc in rootfs; skipping systemd machine-id setup" + return 0 + fi info "Creating empty machine-id to allow systemd to bind-mount it" touch "${mount_dir}/etc/machine-id" } @@ -715,8 +722,10 @@ main() { exit $? fi - if ! check_rootfs "${rootfs}" ; then - die "Invalid rootfs" + if [[ "${SKIP_ROOTFS_CHECK:-no}" != "yes" ]]; then + if ! check_rootfs "${rootfs}" ; then + die "Invalid rootfs" + fi fi local skip_dax="${SKIP_DAX_HEADER:-no}"