Commit graph

264 commits

Author SHA1 Message Date
Michael Vogt
e3d23aa5ad test: fix missing conversion of a test blueprint to toml
This commit fixes the issue that a test blueprint was not converted
from json to TOML. This was not caught in CI apparently because
our test container misses createrepo_c.
2025-04-10 10:26:01 +00:00
Florian Schüller
e8e0d9c4e8 doc/00-installation: Add link to package details
There should be a link to the package details, not only
the reference to the main fedora page.
2025-04-09 15:14:41 +00:00
Simon de Vlieger
6f883c1407 doc: mention root perms for build
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-09 08:18:20 +00:00
Simon de Vlieger
ea1a42773a doc: document manifest
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-09 08:18:20 +00:00
Simon de Vlieger
1a85fc9248 doc: document describe
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-09 08:18:20 +00:00
Simon de Vlieger
11bf725453 doc: document build --arch
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-09 08:18:20 +00:00
Michael Vogt
f06b07c247 main: add disk customization to blueprint smoke test
Adding the disk customization to the blueprint test helps to
ensure that strict TOML checking works as expected. There was
a (brief) regression because manifest generation with disk
toml was not tested.
2025-04-09 05:32:45 +00:00
Michael Vogt
a2f71ad44c Reapply "blueprintload: enable strict checking for toml"
This reverts commit f25b5e325e.
2025-04-09 05:32:45 +00:00
Michael Vogt
7fbae14142 go.mod: bump version of github.com/osbuild/blueprint 2025-04-09 05:32:45 +00:00
Michael Vogt
c5f0f62ed2 go.mod: bump image version
This gives us the improved error reporting from dnfjson from
PR#1393
2025-04-09 05:32:45 +00:00
Simon de Vlieger
a893c2316e ci: release into epel-9-next
Instead of directly releasing to epel-9 we should release into
epel-9-next and do manual merges/releases when/if RHEL and/or CentOS
catch up with our dependencies.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-08 14:26:53 +00:00
Simon de Vlieger
9847b44619 main: describe non-hidden
The describe format has become quite useful, we should list it in the
help page.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-08 10:05:13 +00:00
Simon de Vlieger
5057bd4791 main: hide completion command
The `completion` command doesn't need to be quite so discoverable. Let's
have only actual subcommands listed and mention this in (future)
documentation instead.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-08 08:38:23 +00:00
Simon de Vlieger
c99aa91265 main: describe auto-detect distro
Other commands such as `manifest`, and `build` auto detect the
distribution if none is given. `describe` is the odd one out that
requires `--distro`. Let's also autoselect there.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-08 08:38:19 +00:00
Simon de Vlieger
274a75387b main: rename list-images to list
Rename the `list-images` command to `list`. We don't have `-image(s)` in
our other subcommands so this is for consistency.

We keep a `list-images` alias behind for compatibility reasons.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-08 07:34:20 +00:00
Simon de Vlieger
a963712152 main: also eat depsolve warnings in manifest
Let's consume the depsolve warnings everywhere, including during
manifest generation.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-08 07:27:35 +00:00
Simon de Vlieger
77498d99c8 deps: bump osbuild version
New images requires newer osbuild.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-08 07:27:35 +00:00
Simon de Vlieger
ad9943e99d main: eat depsolve warnings
When running `image-builder` warnings are emitted during manifest
generation. Depending on the definitions or customizations packages
can be excluded from groups which leads to:

```
No match for group package "dracut-config-rescue"
```

Interspersing with normal output. Let's pass along another byte buffer
for the warnings from manifest generation to be written into.

Note that this also needs plumbing [1] to land in `images` first.

[1]: https://github.com/osbuild/images/pull/1384

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-08 07:27:35 +00:00
Simon de Vlieger
bda86863ff deps: update images to main
Pull in the `main` branch from images to ensure we have the support
needed for eating warnings.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-08 07:27:35 +00:00
Simon de Vlieger
412fe34b41 main: rename describe-image to describe
Leaves behind a compatibility alias.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-04-04 07:02:28 +00:00
Michael Vogt
0f348301d9 main: add base partition table to describe-image
This commit adds the (base) partition table to the `describe-image`
command. It needs https://github.com/osbuild/images/pull/1376

It currently looks like:
```yaml
$ image-builder describe-image qcow2 --distro fedora-41
@WARNING - the output format is not stable yet and may change
distro: fedora-41
...
partition_table:
  uuid: D209C89E-EA5E-4FBD-B161-B461CCE297E0
  type: gpt
  partitions:
    - size: 1048576
      type: 21686148-6449-6E6F-744E-656564454649
      bootable: true
      uuid: FAC7F1FB-3E8D-4137-A512-961DE09A5549
    - size: 209715200
      type: C12A7328-F81F-11D2-BA4B-00A0C93EC93B
      uuid: 68B2905B-DF3E-4FB3-80FA-49D1E773AA33
      payload:
        type: vfat
        uuid: 7B77-95E7
        label: EFI-SYSTEM
        mountpoint: /boot/efi
        fstab_options: defaults,uid=0,gid=0,umask=077,shortname=winnt
        fstab_passno: 2
    - size: 524288000
      type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
      uuid: CB07C243-BC44-4717-853E-28852021225B
      payload:
        type: ext4
        label: boot
        mountpoint: /boot
        fstab_options: defaults
    - size: 2147483648
      type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
      uuid: 6264D520-3FB9-423F-8AB8-7A0A8E3D3562
      payload:
        type: ext4
        label: root
        mountpoint: /
        fstab_options: defaults
```
2025-04-03 17:25:16 +00:00
Michael Vogt
1d2095f09e go.mod: update to latest version of images to get PR#1376 2025-04-03 17:25:16 +00:00
Tomáš Hozza
1b6ecf9012 SPEC: bump the minimum required osbuild version
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-04-02 20:57:17 +00:00
Tomáš Hozza
724ffd4a77 GH Action: check the SPEC osbuild/images deps minimum version
Add a check which leverages the osbuild/images@check-spec-deps-action
action to check that the SPEC files requires at least the minimum
versions for dependencies specified by the `osbuild/images`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-04-02 20:57:17 +00:00
schutzbot
a5994eb570 Post release version bump
[skip ci]
2025-04-02 08:22:29 +00:00
Michael Vogt
958f95f634 progress: set --cache-max-size in osbuild
This commit allows controlling the `osbuild --cache-max-size`
option. By default it will set the cache to 20GiB but allows
this to be controlled by the user.

Thanks to Simon for raising this.
2025-04-01 11:30:44 +00:00
Brian C. Lane
2cfe043f5e main: Add a --version flag to show the build version
This embeds the version at build time and displays it when passed the
--version flag.
2025-04-01 06:50:24 +00:00
Simon de Vlieger
63bb56e12d import: refer to pkg
Change the progress imports to refer to `pkg/progress` inside this
repository as it was imported from `bootc-image-builder`.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-03-31 19:42:59 +00:00
Simon de Vlieger
f4bbd3e048 import: move bib files to correct path
Moves the files imported from `bootc-image-builder` directly under `pkg`
so they can be imported in reverse. Also fix up any import paths at the
same time.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-03-31 19:42:59 +00:00
Michael Vogt
7ac659490c progress: add new BuildLog option
This commit adds a new `BuildLog` option to the `OSBuildOptions`
that can be used to generate a streamed buildlog (e.g. to a file
or a websocket).

This will be used in `ibcli` with a new `--with-buildlog` option.
2025-03-31 19:42:59 +00:00
Michael Vogt
a875a16309 progress: add progress.OSBuildOptions struct
This commit adds a `OSBuildOptions` struct that can be used to
pass (optional) options to the `progress.RunOSBuild()` helper.

This make it easier to expand with more options.
2025-03-31 19:42:59 +00:00
Michael Vogt
e51a56b084 progress: stop building when osbuild status cannot be parsed
This commit changes the progress parser (again) to deal with
errors from the osbuild json progress scanner. On errors we
will now exit right away and potentially kill osbuild but
provide an error message that hints how to workaround the
issue.

The original code assumed we get transient errors like json
decode issues. However it turns out that this is not always
the case, some errors from a bufio.Scanner are unrecoverable
(like ErrTooBig) and trying again just leads to an endless
loop. We can also not "break" and wait for the build to finish
because that would appear like the progress is broken
forever and we would still have to report an error (just
much later).
2025-03-31 19:42:59 +00:00
Michael Vogt
75407ea511 progress: tweak how os.Stderr is mocked
This commit changes the way `os.Stderr` is mocked so that higher
level consumes of the libary can use helpers can replace os.Stderr
(like `testutil.CaptureStdio()` is doing). The existing approach
assigns the "real" os.Stderr to osStderr so early that it cannot
be changed later.
2025-03-31 19:42:59 +00:00
Michael Vogt
3e7ebe81c4 progress: fix missing build log output on errors in progress
This commit fixes a silly mistake from PR#810. The issue is that
in #810 we started to collect the osbuild stdout/stderr so that
we can show crashes from osbuild or other unexpected output.

However when a stage fails this is reported via the json progress
and not directly on stdout/stderr - this was missed when #810
was done.

This commit does a short term fix by collecting the buildlog again
and showing it in the error and also updates the test to be more
realistic. However we really need a test that actually tests
the real behavior, ideally a real osbuild run with a stage error
so that we can be sure we capture this (criticial!) functionality.
2025-03-31 19:42:59 +00:00
Michael Vogt
0e1a0f8ace progress: do not return if osbuild status json reading fails
This commit tweaks an issue that potentially an incorrect status
from osbuild would fail the build with a bad error message and
without us getting the full buildlog.
2025-03-31 19:42:59 +00:00
Michael Vogt
655b6bbd0f progress: tweak progress error reporting
This commit adds catpure of os.Std{out,err} when running osbuild so
that we capture the error log and can display it as part of
an error from osbuild, e.g. when osbuild itself crashes.

This gives us more accurate error reporting if anything fails
during the osbuild building.
2025-03-31 19:42:59 +00:00
Michael Vogt
9ac654a7b1 progress: move from an internal package to external
This commit makes the previously internal `progress` package an
external API. The is the result of the discussion in images
PR#1150 where we decided that the progress module is not a great
fit for the "images" library.

We want to share this code between bootc-image-builder and
image-builder-cli now. In the future we will also want to
use it in the `worker-executor` in `osbuild-composer` to
parse the stream data from `osbuild`.

We plan to merge bootc-image-builder and image-builder-cli
medium term so importing code from bootc-image-buider in
image-builder cli is not that stange.

When we (longer-term) use this code the `worker-executor`
we will need to think about this again and maybe put it
back into images. However this commit unblocks us without
making anything worse.
2025-03-31 19:42:59 +00:00
Simon de Vlieger
6d0927c2f9 import: move bib files to correct path
Moves the files imported from `bootc-image-builder` to the appropriate
path under `pkg/` so they can be imported reverse. Also fix up the
import paths that are in these files to refer to their new locations.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-03-31 18:19:33 +00:00
Gianluca Zuccarelli
441d408aee bib: deprecate the --local flag
Pulling container images before building would break in the case of
authenticated images on podman machine, since the auth file lives on the
host and not podman machine and won't know about it.

This commit deprecates the `--local` flag and warns users when it is
passed to the CLI so that this won't break things for anyone who might
already be using the flag. This change means that the user will have to
ensure that the container is pulled to the local container store before
initiating the build.

Co-authored-by: Ondřej Budai <obudai@redhat.com>
2025-03-31 18:19:33 +00:00
bstrausser
c74c402d74 bib/internal/setup: use fake podman binary for testing
Create a mock podman executable script and add it at the top of PATH.
Use it to generate output for the container tag validation.
2025-03-31 18:19:33 +00:00
bstrausser
3cd7df7b13 bib: change octal literal prefix
Use `0o` instead of just `0` for better readability.
2025-03-31 18:19:33 +00:00
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