Commit graph

21 commits

Author SHA1 Message Date
Jonathan Lebon
a49b16e3ff
bootc-base-imagectl: add --repo
This is analogous to the dnf option of the same name, available in both
dnf4 and dnf5. It has the same semantics as rpm-ostree's `repos` key, so
we can map it directly.

This will make it easier in CoreOS-land to inject our own repos and
control enablement declaratively rather than have to fiddle with repo
files directly. Note also that the `config-manager` dnf plugin is not
installed by default in the base bootc image, and I would rather not
have to install that for each compose.
2025-07-21 15:51:27 -04:00
Jonathan Lebon
4eb52e5483
bootc-base-imagectl: add --nobody-99 for use with --sysusers
The `nobody` user/group is special and can't be driven from a sysusers
dropin because Fedora's systemd has a compiled-in default value
for naming the overflow user that same name and that always takes
precedence.

The problem is that due to legacy and cargo-culting, we have to deal
with a bunch of systems with the `nobody` user set to 99:99 that we
can't just ignore. We need to migrate those, but for now at least to
make `--sysusers` usable in these environments, let's add a new hidden
`--nobody-99` option which defines _only_ that entry in the hardcoded
passwd/group. This _is_ respected by systemd-sysusers.

See also: https://github.com/coreos/fedora-coreos-tracker/issues/1201
See also: https://github.com/systemd/systemd/issues/7717
2025-07-15 14:32:42 -04:00
Jonathan Lebon
8545b42242
bootc-base-imagectl: add --sysusers
This allows users to opt out of the hardcoded passwd/group files we
carry here in favour of making sysusers entries canonical.

This is especially useful with the `--add-dir` option, which allows
injecting user-owned sysusers entries to e.g. define more users or to
fixate normally floating UIDs from packages.

This uses the new `sysusers` knob in rpm-ostree. For more details, see:
https://github.com/coreos/rpm-ostree/pull/5427
2025-07-14 12:13:08 -04:00
Jonathan Lebon
7229926c02
bootc-base-imagectl: support --install packages with spaces
Those are more like package requests than package names, so things like
`foo > 1.0` should be supported.

Pass the install arguments through `shlex.quote`.
2025-06-19 20:01:50 -04:00
Jonathan Lebon
72209c6c1c
bootc-base-imagectl: sort imports 2025-06-19 20:01:28 -04:00
Colin Walters (Red Hat)
00d7084d74 Merge branch 'pr/minor-tweaks' into 'main'
Various tweaks as part of RHCOS container-native path work

See merge request fedora/bootc/base-images!209
2025-06-18 17:55:41 +00:00
Jonathan Lebon
87eae9910e
bootc-base-imagectl: support hidden manifests, hide minimal-plus
We don't currently want the minimal-plus target to be user-facing. It's
intended only for other Fedora variants.

Let's support "hidden" manifests by having their names end in
`.hidden.yaml`. Then, make `minimal-plus` hidden.

I considered instead having them start with `.` to match
well-established semantics, but I don't like either that this hides them
from an `ls` in the git repo (or even with `-a`, puts them higher up
whereas I want it to be close to `minimal.yaml`).

I also considered leveraging the existing symlink hiding semantics, but
it also felt awkward to rename a file and add a symlink to it just for
the purpose of hiding it.
2025-06-17 15:46:08 -04:00
Jonathan Lebon
c2ff52a7cf
bootc-base-imagectl: simplify manifest path logic
The `if os.path.isdir(args.manifest)` bit dates from the introduction
of this script, but doesn't really work. I suspect the intent here was
to abstract over some manifests being top-level YAML files and others
being directories).

Except that:
1. The script didn't actually check the right path. It's checking
   `$PWD/{args.manifest}` instead of `$MANIFESTDIR/{args.manifest}`.
2. `list` doesn't have the equivalent logic to look for `manifest.yaml`
   files in subdirectories.
3. Nowadays, there is both a e.g. `standard.yaml` _and_ a
   `standard/manifest.yaml` directory. The established semantic there
   AIUI is that the top-level manifests are opinionated for a specific
   OS (Fedora/CentOS/RHEL), whereas the directories are shared across
   all of those.

So let's just nuke support for the directory path.
2025-06-17 15:32:25 -04:00
Jonathan Lebon
f4df7f6e15
bootc-base-imagectl: add --no-docs
This just connects to the `documentation` treefile key currently but is
essentially equivalent to dnf's `--no-docs` flag.
2025-06-16 14:07:24 -04:00
Jonathan Lebon
9d39775e6a
bootc-base-imagectl: be compatible with Python 3.9
RHEL 9 ships Python 3.9 which doesn't seem to know about
`delete_on_close`. Just use `delete` instead.
2025-06-12 15:33:55 -04:00
Jonathan Lebon
8372951aa9
bootc-base-imagectl: support passing symlink to --add-dir
This is the setup in RHCOS, where some of the overlays are actually
symlinks to overlays in the f-c-c submodule.
2025-06-12 15:32:29 -04:00
Jonathan Lebon
e3b9fbd6ba
bootc-base-imagectl: support injecting directories
Right now, the expectation for adding unpackaged content in a custom
base image flow is to do it after the main compose. The problem however
is that sometimes you want that content to affect the main compose
itself, so doing it afterwards is not sufficient.

The primary use case for this is sysusers.d dropins where you need
to make sure that sysusers in scriptlets don't pick UIDs/GIDs already
reserved on target client systems.

One way to work around this is to synthesize an RPM that ships the
dropin, and then ensure that it somehow runs as early as possible in the
transaction. This is doable but obviously quite a hack.

Enable this instead by adding a generic `--add-dir` switch which then
just translates to `ostree-layers` in the override manifest.

The dnf equivalent would be to first install e.g. `filesystem` and
`setup`, add files to the rootfs, and then install all the other
packages.

See also discussions in https://github.com/coreos/rpm-ostree/pull/5354.
2025-06-03 22:05:06 -04:00
Dusty Mabe
4f66e09337
base-imagectl: support --cachedir
As far as I can tell --cachedir was used prior to bootc-base-imagectl
being introduced in c89b6f4. Let's add the --cachedir option to
bootc-base-imagectl, but we won't use it in our Containerfile yet
because we need to wait for [1] to land in an rpm-ostree release.

This is useful today for people hacking away locally.

[1] https://github.com/coreos/rpm-ostree/pull/5391
2025-05-20 17:45:34 -04:00
Jonathan Lebon
64f4963fc3
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.
2025-05-14 15:13:23 -04:00
Dusty Mabe
ef5e95d5bd
whitespace changes to appease downstream CI
The prow/validate job does some various whitespace checks and
was complaining about these so I guess I'll try to make it happy:

```
 [+] Found files with whitespace at the end of line
./fedora-coreos-config/fedora-bootc/.gitlab-ci.yml
./fedora-coreos-config/fedora-bootc/bootc-base-imagectl.md
./fedora-coreos-config/fedora-bootc/fedora-iot.yaml
./fedora-coreos-config/fedora-bootc/iot/manifest.yaml

[+] Found files with missing empty line at end of file
./fedora-coreos-config/fedora-bootc/bootc-base-imagectl
./fedora-coreos-config/fedora-bootc/fedora-iot.yaml
./fedora-coreos-config/fedora-bootc/iot/manifest.yaml
```
2025-05-09 12:52:16 -04:00
Colin Walters
78462e6c13 base-imagectl: Drop experimental from compose-rootfs
It's stable in 2025.6 which is hopefully going to ship
in Fedora 41 soon and is already in C10S and C9S.
2025-03-19 16:35:44 -04:00
Colin Walters
ccb2c22ecb imagectl: Update mode for / if needed
This works around https://github.com/coreos/rpm-ostree/pull/5322
so we can ship the fix faster.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-03-04 17:31:56 -05:00
Colin Walters
55a8191604 imagectl: Add rechunk verb
This fronts the functionality currently implemented in rpm-ostree,
for the same reason as we have `build-rootfs`; the functionality
may move elsewhere in the future.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-28 15:15:59 -05:00
Colin Walters
3f39d107e1 imagectl: Copy symlinks as symlinks for manifests
This fixes using `defaults.yaml` as a link, which we don't
want to list with the `list` verb.
2025-02-27 19:52:27 -05:00
Colin Walters
cb36bccf74 imagectl: Default source-root to /
While "cross builds" and using a separate repos container can
feel very clean (instead of mutating the builder container)
it's actually much closer to our default intention to support building
a new version of the base image from the image itself.

So make the source root optional (i.e. it defaults to `/`).

This will improve the default UX, but also more specifically
will fix the issue that cachi2 breaks the separate source root flow.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-25 16:37:40 -05:00
Colin Walters
c89b6f4298 Introduce bootc-base-imagectl
- Embed the manifests into the container image
- Add bootc-base-imagectl which is a tightly controlled frontend
  to execute on those manifests.

For now, we don't attempt to rework how we build the standard
image to actually look like `dnf install`, but we show that
it can work.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-25 08:27:20 -05:00