bootc-base-imagectl: support extending package list

The current custom base image flow of rebuilding a "built-in" image with
custom repos and then adding your own content separate is reasonable,
but it would be nice if one could augment the list of packages to
install in that initial build rather than as a separate transaction.

Then, you don't have to cleanup after dnf and `/var` content, re-inject
repo definitions, and refetch repo metadata. It also allows building
container images with additional packages without `dnf` necessarily
being in the package set.

We don't want to leak rpm-ostree implementation details, nor do we want
to invent a new format. So just add support for a `--install` arg and a
generic `--args-file` to pass arguments via a file.

We then generate a new treefile on the fly to extend the `packages`
list.
This commit is contained in:
Jonathan Lebon 2025-05-09 15:36:39 -04:00
parent 6b0b047624
commit 64f4963fc3
No known key found for this signature in database
2 changed files with 36 additions and 4 deletions

View file

@ -5,7 +5,10 @@ FROM quay.io/fedora/fedora-bootc:rawhide as repos
# This is intentionally a locally built image
FROM localhost/fedora-bootc as builder
RUN --mount=type=bind,from=repos,src=/,dst=/repos,rw /usr/libexec/bootc-base-imagectl build-rootfs --manifest=standard/manifest /repos /target-rootfs
RUN --mount=type=bind,from=repos,src=/,dst=/repos,rw <<EORUN
echo -e '--install\nltrace' > args.txt
/usr/libexec/bootc-base-imagectl --args-file args.txt build-rootfs --manifest=standard/manifest /repos /target-rootfs
EORUN
# This pulls in the rootfs generated in the previous step
FROM scratch
@ -15,6 +18,8 @@ set -xeuo pipefail
. /usr/lib/os-release
test "$ID" = fedora
rpm -q ltrace
# And install a package
dnf -y install strace
dnf clean all