feat(container): add finalize-rootfs subcommand for building base images#2100
Open
andrewdunndev wants to merge 1 commit intobootc-dev:mainfrom
Open
feat(container): add finalize-rootfs subcommand for building base images#2100andrewdunndev wants to merge 1 commit intobootc-dev:mainfrom
andrewdunndev wants to merge 1 commit intobootc-dev:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces the finalize-rootfs and post-chroot-cleanup commands to the bootc CLI, enabling the transformation of a standard dnf --installroot output into a bootc-compatible layout. The implementation includes logic for managing toplevel symlinks, converting /var contents to tmpfiles.d entries, relocating the rpmdb, and injecting configuration for dracut, ostree, and systemd. Review feedback suggests simplifying the directory removal logic when replacing directories with symlinks and moving a use statement to the top of the file to follow Rust conventions.
167c6b6 to
ba53ea3
Compare
Add bootc container finalize-rootfs and bootc container post-chroot-cleanup subcommands that transform a dnf --installroot rootfs into a bootc-compatible layout without requiring rpm-ostree. Transforms: toplevel symlinks, /var->tmpfiles.d, rpmdb relocation, config injection (prepare-root.conf, dracut.conf.d, kernel install.conf). Validated end-to-end: Fedora 42 image boots to login in 41s, bootc status works, reboot succeeds, 12/12 lint checks pass. Signed-off-by: Andrew Dunn <andrew@dunn.dev>
ba53ea3 to
37972b2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
bootc container finalize-rootfsandbootc container post-chroot-cleanup-- a way to build bootc base images using only dnf and standard tools, without rpm-ostree compose.Motivation
Building bootc base images currently requires rpm-ostree compose. This PR extracts the minimal set of filesystem transforms that rpm-ostree compose applies and implements them as bootc subcommands, making bootc self-sufficient for base image creation.
The existing
bootc containernamespace already has precedent for build-time operations that modify the rootfs (ukify,export).finalize-rootfsfits the documented purpose: "Operations which can be executed as part of a container build."Related: #215
What it does
Two new subcommands under
bootc container:finalize-rootfs <path> [--check]: Applies ostree filesystem layout transforms to adnf --installrootoutput -- toplevel symlinks, /var cleanup + tmpfiles.d generation, rpmdb relocation, config injection (prepare-root.conf, dracut.conf.d, kernel install.conf, dnf5 config, bootc install config, systemd presets).post-chroot-cleanup <path> [--check]: Cleans artifacts left by chroot operations (dracut, systemctl preset-all, bootupd) -- /var re-pollution, rpmdb WAL/SHM files, /run and /tmp contents.Both support
--checkfor dry-run reporting.Testing
Built a Fedora 42 base image from scratch on a GCP VM (n2-standard-4, Fedora 42, nested virt for KVM). Full build + boot cycle with no rpm-ostree at any point.
Build pipeline
Results
Boot test (QEMU + KVM)
bootc status output
ostree and systemd status
Boot log (ostree/switch-root sequence)
Reboot test
System rebooted cleanly. Second login prompt confirmed. Full boot -> login -> bootc status -> reboot -> login cycle validated.