From fc09d06e73fc0025746d12d43c6631aeccbe125e Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 18 Nov 2025 13:59:57 -0500 Subject: [PATCH] build-sys: Always install initramfs module Now that we've cut over to always building + installing via an (RPM) package in our build system, we need to always install the dracut module. Signed-off-by: Colin Walters --- Makefile | 13 +++---------- .../dracut/usr/lib/dracut.conf.d/10-bootc-base.conf | 4 ++-- contrib/packaging/bootc.spec | 3 ++- contrib/packaging/install-rpm-and-setup | 9 +++++---- crates/initramfs/dracut/module-setup.sh | 4 +++- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 083d9cb1..daffe519 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,9 @@ install: if [ "$$ID" = "fedora" ] || [[ "$$ID_LIKE" == *"fedora"* ]]; then \ install -D -m 0755 -t $(DESTDIR)/$(prefix)/lib/bootc contrib/scripts/fedora-bootc-destructive-cleanup; \ fi + install -D -m 0644 -t $(DESTDIR)/usr/lib/systemd/system crates/initramfs/*.service + install -D -m 0755 target/release/bootc-initramfs-setup $(DESTDIR)/usr/lib/bootc/initramfs-setup + install -D -m 0755 -t $(DESTDIR)/usr/lib/dracut/modules.d/51bootc crates/initramfs/dracut/module-setup.sh # Run this to also take over the functionality of `ostree container` for example. # Only needed for OS/distros that have callers invoking `ostree container` and not bootc. @@ -76,16 +79,6 @@ install-ostree-hooks: ln -sf ../../../bin/bootc $(DESTDIR)$(prefix)/libexec/libostree/ext/$$x; \ done -# Install code in the initramfs, off by default except in builds from git main right now -# Also the systemd unit hardcodes /usr so we give up the farce of supporting $(prefix) -install-initramfs: - install -D -m 0644 -t $(DESTDIR)/usr/lib/systemd/system crates/initramfs/*.service - install -D -m 0755 target/release/bootc-initramfs-setup $(DESTDIR)/usr/lib/bootc/initramfs-setup - -# Install initramfs files, including dracut module -install-initramfs-dracut: install-initramfs - install -D -m 0755 -t $(DESTDIR)/usr/lib/dracut/modules.d/51bootc crates/initramfs/dracut/module-setup.sh - # Install the main binary, the ostree hooks, and the integration test suite. install-all: install install-ostree-hooks install -D -m 0755 target/release/tests-integration $(DESTDIR)$(prefix)/bin/bootc-integration-tests diff --git a/baseimage/dracut/usr/lib/dracut.conf.d/10-bootc-base.conf b/baseimage/dracut/usr/lib/dracut.conf.d/10-bootc-base.conf index 221f2efd..5352cb20 100644 --- a/baseimage/dracut/usr/lib/dracut.conf.d/10-bootc-base.conf +++ b/baseimage/dracut/usr/lib/dracut.conf.d/10-bootc-base.conf @@ -3,5 +3,5 @@ # (really hostonly=no should be the default if dracut detects that # it's in a container or so) hostonly=no -# We require ostree in the initramfs -add_dracutmodules+=" ostree " +# We require ostree and our own module in the initramfs +add_dracutmodules+=" ostree bootc " diff --git a/contrib/packaging/bootc.spec b/contrib/packaging/bootc.spec index 114cd514..83043d34 100644 --- a/contrib/packaging/bootc.spec +++ b/contrib/packaging/bootc.spec @@ -125,7 +125,7 @@ export SYSTEM_REINSTALL_BOOTC_INSTALL_PODMAN_PATH=%{system_reinstall_bootc_insta # Container build: use cargo directly with cached dependencies export CARGO_HOME=/var/roothome/.cargo cargo build -j%{_smp_build_ncpus} --release %{?with_rhsm:--features rhsm} \ - --bin=bootc --bin=system-reinstall-bootc \ + --bin=bootc --bin=system-reinstall-bootc --bin=bootc-initramfs-setup \ %{?with_tests:--bin tests-integration} make manpages %else @@ -200,6 +200,7 @@ fi %{_bindir}/bootc %{_prefix}/lib/bootc/ %{_prefix}/lib/systemd/system-generators/* +%{_prefix}/lib/dracut/modules.d/51bootc/ %if %{with ostree_ext} %{_prefix}/libexec/libostree/ext/* %endif diff --git a/contrib/packaging/install-rpm-and-setup b/contrib/packaging/install-rpm-and-setup index 5eb382b1..449072e9 100755 --- a/contrib/packaging/install-rpm-and-setup +++ b/contrib/packaging/install-rpm-and-setup @@ -10,10 +10,11 @@ rpm -Uvh --oldpackage "${RPM_DIR}"/*.rpm rm -f "${RPM_DIR}"/*.rpm # Regenerate initramfs if we have initramfs-setup -if [ -x /usr/lib/bootc/initramfs-setup ]; then - kver=$(cd /usr/lib/modules && echo *) - env DRACUT_NO_XATTR=1 dracut -vf /usr/lib/modules/$kver/initramfs.img $kver -fi +kver=$(cd /usr/lib/modules && echo *) +# DRACUT_NO_XATTR=1 is the default in newer base images, and +# we have --add bootc here until the change to add the module in base +# images lands. +env DRACUT_NO_XATTR=1 dracut --add bootc -vf /usr/lib/modules/$kver/initramfs.img $kver # Only in this containerfile, inject a file which signifies # this comes from this development image. This can be used in diff --git a/crates/initramfs/dracut/module-setup.sh b/crates/initramfs/dracut/module-setup.sh index 39dfe238..2e5187df 100755 --- a/crates/initramfs/dracut/module-setup.sh +++ b/crates/initramfs/dracut/module-setup.sh @@ -3,7 +3,9 @@ installkernel() { instmods erofs overlay } check() { - require_binaries /usr/lib/bootc/initramfs-setup || return 1 + # We are never installed by default; see 10-bootc-base.conf + # for how base images can opt in. + return 255 } depends() { return 0