Commit graph

14 commits

Author SHA1 Message Date
bstrausser
2a89cb6739 bib/internal/setup: validate container tags early
Check that the container has the expected bootc tags early and fail if
they are missing.
2025-03-31 18:19:33 +00:00
Michael Vogt
4fa4ad34a0 bib: detect missing qemu-user early
This commit checks early if cross architecture building support via
`qemu-user-static` (or similar tooling) is missing and errors in
a more user friendly way.

Note that there is no integration test right now because testing
this for real requires mutating the very global state of
`echo 0 > /proc/sys/fs/binfmt_misc/qemu-aarch64`
which would make the test non-parallelizable and even risks
failing other cross-arch tests running on the same host (because
binfmt-misc is not namespaced (yet)).
2025-03-31 18:19:33 +00:00
Michael Vogt
b3ef264353 bib: simplify getContainerSize()
The getContainerSize() was not using some of the modern go helpers.
So let's use `exec.Command().Output()` and introduce a new
`util.OutputErr()` helper that will be able to also show stderr to
the user if the Output() call returns an error.
2025-03-31 18:19:33 +00:00
Colin Walters
9b280f0ba3 setup: Simplify container-storage mounted check
I ran into the `--local` option not working at least in my
setup with the current container image (which for some reason
hasn't been updated, and predates the latest tip commit
which talks about btrfs)

On this current test system (MacOS + podman 5 + default podman-machine)
things do work with the tip commit.

However...I don't quite understand the need to *both* try to
run `systemd-detect-virt` *and* parse `/proc/self/mountinfo`.

(BTW, the logic for `insideContainer` was really confusing me because
 it only returned `true` if we were *not* in a container...I wonder
 if that was really intentional?)

Anyways, I think the goal here is just a friendly direct error
message if it doesn't look like the mount is there, which we can
do by just checking for the file path.  If it isn't mounted
from the host then nothing will be there.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-03-31 18:19:33 +00:00
Michael Vogt
2f0d81288a setup: deal with btrfs subvolumes when checking mapped storage
When the container storage is checked it may come from a btrfs
subvolume. In /proc/self/mountinfo this looks like:
```
1364 1345 0:33 /root/var/lib/containers/storage /var/lib/containers/storage rw,relatime - btrfs /dev/mapper/luks-1356123c-c7b9-1bd7-a8bf-e13d4cbb5500 rw,seclabel,compress=zstd:1,ssd,discard=async,space_cache,subvolid=257,subvol=/root
```
as a quick fix just compare the suffix of the root instead of the
full path.

Thanks for Ondrej!
2025-03-31 18:19:33 +00:00
Michael Vogt
280f7626d5 bib: check /var/lib/containers/storage when using "--local"
Ensure to error early when the user is not passing the required
```
-v /var/lib/containers/storage:/var/lib/containers/storage
```
when doing a local build.
2025-03-31 18:19:33 +00:00
Michael Vogt
1bfb930266 test: add test that ensure disk space is doubled
Ensure that the disk size of a container is taken into account
when the image is generated. The current heuristic is that we
just double the container size.

The test will not build an image just generate a manifest and
check that the image file is generated with the expected size.
2025-03-31 18:19:33 +00:00
Colin Walters
2d95d34bb6 Ensure root_t label for /store
The way osbuild works is to synthesize a filesystem tree in the
store, then copy it to the disk.  This ensures the label for the
store is `root_t` which ends up being the labeling for
the "infrastructure" bits in the `/ostree` repository in the
target root.

This in turn is blocking a lot of things.

Closes: https://github.com/osbuild/bootc-image-builder/issues/149
2025-03-31 18:19:33 +00:00
Michael Vogt
1ea8e87fad bib: tweak EnsureEnvironment() based on the feedback from Colin 2025-03-31 18:19:33 +00:00
Michael Vogt
4fa198c18d bib: mount devtmpfs inside the container too
This ensures that the new `partscan` feature in osbuild works. By
default the containers only have a static snapshot of /dev on a
tmpfs. This means that anything later added by losetup will be
missing inside the container.

It also means that https://github.com/osbuild/osbuild/pull/1468
can be reverted.
2025-03-31 18:19:33 +00:00
Colin Walters
bff341cb0b Rename utils -> util
Per style.
2025-03-31 18:19:33 +00:00
Colin Walters
3c717fde11 Add and use a helper to run subprocess
In most cases e.g. we do want to show stdout/stderr, and
it's handy to have a debug log when we're running
a subprocess.

While we're here, switch to just forking `cp` in
the setup code.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-03-31 18:19:33 +00:00
Colin Walters
214fcda30e Validate that we're in rootful podman
As this is a footgun that multiple people have run into.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-03-31 18:19:33 +00:00
Colin Walters
402c3955b9 Move some helpers into modules
For functional clarity.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-03-31 18:19:33 +00:00