Commit graph

108 commits

Author SHA1 Message Date
robojerk
ee02c74250 did stuff 2025-08-26 10:33:28 -07:00
Michael Vogt
5e24db6def image-builder: use manifest.{Build,Payload}Pipelines
With the new images library changes to move the pipeline
roles out of the image types into the manifest we need
to tweak osbuild-composer to use the new way of getting
the payload and build pipelines.

This commit implements that new method based on the
manifest instead of the image type. See images pr#1766
for the rational of the change.
2025-08-19 15:20:19 +00:00
Michael Vogt
75f24bbd2a main: fix --extra-repos support when cross building
This commit fixes the issue that --extra-repo are not added
correctly to the repo registry when doing cross arch building.
The issue is that they get added early at the reporegistry
level and because we don't know yet what arch will be used
it was initially only added to the host arch. This was
fine before we supported cross-arch building.

But now that we do support cross-arch building this is
of course an issue and produces subtle bugs. This commit
is the "easy" fix, the extra repos are just added to for
all architectures. This may not be right but because they
are optional its the reponsibility of the user to provide
the right ones. Eventually we should probably be smarter
here and move extra repo support into manifestgen but
that requires changes in images and an images release so
this is good enough for now.

Thanks to Simon de Vlieger for reporting this.
2025-08-19 15:18:58 +00:00
Michael Vogt
5fb17b967e image-builder: use github.com/osbuild/blueprint
Drop using the "images" library blueprint types and use the ones
from github.com/osbuild/blueprint/pkg/blueprint instead.

This also moves to the images library to v0.172.0 and the blueprints
library to v1.12.0 as this is required for this to work.
2025-08-07 16:56:35 +00:00
Michael Vogt
6169260dcd image-builder: update upload API to match latest images
This commit updates the upload API to match the latest
version in the images library.
2025-08-07 10:29:39 +00:00
Michael Vogt
e8b52d7a31 main: add --ignore-warnings cmdline option
This commit adds a new `--ignore-warnings` that can be used to
make warnings not an error when `ibcli` runs.
2025-07-17 06:45:30 +00:00
Michael Vogt
ad20533d87 testutil: rename Calls() -> CallArgsList() for clarity
The current MockCmd.Calls() is a bit ambiguous so follow the example
of pytest here and rename to the cleaner CallArgsList() that
captures more closely what the helper is actually doing.
2025-07-17 06:44:29 +00:00
Michael Vogt
bb45b89d84 testutil: remove unnecessary testutil.MockCmd.Restore()
While looking over the code I noticed that the `Restore()` helper
is not needed (and arguably wrong as it does not reset PATH).
We already use `t.TempDir()` and `t.Setenv()` as part of the
command setup so manually cleanup is not neccessary (and is today
even incomplete). So YAGNI and we can remove Restore().
2025-07-17 06:44:29 +00:00
Simon de Vlieger
3021afb9f7 main: --version includes git commit
Include the commit of the build (if available in the build environment),
also include the version of `images` in the build; if available.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-07-15 08:50:19 +00:00
Tomáš Hozza
57e8468390 Test/main: don't rely on EOL RHEL 8.9 in tests
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-07-09 06:52:47 +00:00
Tomáš Hozza
8d0d7106c5 Always set rhsm.Facts when generating manifests
Make sure that images built by ibcli have correct rhsm.Facts set for
distributions that set it (this is handled by the distro definition, not
by the caller of the manifest generator).

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-07-09 06:52:47 +00:00
Tomáš Hozza
49c87afb33 cmd/describe: fix describing of '*-simplified-installer' images
The  '*-simplified-installer' images require the installation device
to be specified as a BP customization to serialize their Manifest.
The 'describe' command was not setting those, which resulted in errors
when describing such image types.

Set a dummy installation device BP customization for image types with
their name ending with '-simplified-installer', to enable describing
of such images.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-06-23 18:31:27 +00:00
Tomáš Hozza
44ef682ca1 cmd/describe: fix describing of OSTree images
OSTree images require additional arguments to serialize their Manifest.
The 'describe' command was not setting those, which resulted in errors
when describing such image types.

Set the required minimum OSTree arguments to dummy values to enable
describing of such images.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-06-23 18:31:27 +00:00
Tomáš Hozza
8040fee0d4 cmd/describe: test that all images can be described
Add an unit test to verify that the `describe` command can describe all
image types. I've recently ran into issue when describing ostree-based
and `*-simplified-installer` image types.

Add new dependecy for working with YAML - sigs.k8s.io/yaml.

This is what we will probably converge to, since our currently used YAML
library is unmaintained.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-06-23 18:31:27 +00:00
Michael Vogt
dd13153b8b upload: try to auto-detect the upload arch from the filename
This is another convenience feature for the `image-builder upload`
command: when we do not know the target architecture try to
guess it from the filename. This is not perfect but it will
help a lot of users and should be fine until the day we go
and inspect the image.
2025-06-07 12:29:18 +00:00
Michael Vogt
03613a3fb3 upload: warn the user if no --arch flag is passed on upload
This mitigates the issue that a `image-builder upload` command
currently does not know the target architecture of the image
it uploads.
2025-06-07 12:29:18 +00:00
Michael Vogt
2c017fc630 upload: default to boot-mode uefi-preferred when unset
When using `image-builder upload --to=aws` we do not know
the bootmode. Ideally we would introspect the image for
the boot mode but that is not trivial right now.

So for now just default to platform.BOOT_HYBRID which
translated to `uefi-preferred` in the AWS API calls
which should offer the widest compatbility and should
fix the issue that aarch64 does not boot currently
when uploaded via ibcli.
2025-06-07 12:29:18 +00:00
Michael Vogt
62bf88cc62 bib: pass the boot-mode to AWS when doing combined build/upload
This commit passes the boot mode to AWS when doing a combined
build/upload. Here we know what boot mode to use and we can
pass it easily.

This also adds a "XXX" to think about how to handle what to
do when uploading a pre-existing image where we do not know
the boot mode.
2025-06-07 12:29:18 +00:00
Michael Vogt
2996bbc0d1 image-builder: fix cross-arch uploading
This commit fixes the cross-arch uploading in the most simple
case by reading the `--arch` when `image-builder build --upload`
is used. Note that this is not a complete fix as it will not
take boot mode into account nor will it (by default) DTRT when
`image-builder upload` is used on a previously build images
for a different architecture.

Thanks to `FrostyX` for reporting the issue.
2025-06-07 12:29:18 +00:00
Simon de Vlieger
26bf19373a test/main: update types used
Image types were renamed [1] in images for the Fedora distribution.
While aliases were left behind for compatibility those are not used
when directly requesting manifests it seems.

Let's rename them to their canonical names.

[1]: 65194a4bf

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-05-28 08:19:05 +00:00
Simon de Vlieger
33f7822c28 test/main: update registrations test
There was previously a bug in the Insights client configuration stage
which omitted a key [1]. A testcase hardcoded this invalid format. Let's
update it to the expected value.

[1]: 389b629ce2

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-05-28 08:19:05 +00:00
Simon de Vlieger
89ce20101b test/main: no more fedora-40
Fedora 40 was removed from `images` as it is EOL, we can no longer use
it in our test cases. Bump to Fedora 42.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-05-28 08:19:05 +00:00
Lukas Zapletal
392a04fd12 refactor: use standard logger instead of logrus 2025-05-12 18:21:37 +00:00
Lukas Zapletal
4c9f2b4ba4 manifest: use Sync instead of Close 2025-04-24 06:18:10 +00:00
Michael Vogt
c829e60649 manifest: handle "close()" errors in sbomWriter()
This commit adds error handling for the `f.Close()` errors when
we write the SBOM. Errors on close for RW fds are rare but we
should handle them so we return the result of `f.Close()` now
when returning in sbomWriter(). We still keep the `defer f.Close()`
to ensure we do not leak file descriptors when e.g. `io.Copy()`
fails. In the "happy" case f is closed without an error and
then the defer f.Close() runs and will error with "ErrClosed"
but we can ignore that.

An alternative implementaiton might be:
```golang
func sbomWriter(outputDir, filename string, content io.Reader) (err error) {
	...
	f, err := os.Create(p)
	if err != nil {
		return err
	}
	defer func() { err = errors.Join(err, f.Close()) }()
	...
	return nil
}
```
no super strong opinion here.

Thanks to Flo for finding this issues!
2025-04-23 06:46:39 +00:00
Tomáš Hozza
1a2f4be378 Add unit test for describe-image
Add a unit test for testing that providing only the required command
line arguments produces expected output.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-04-17 13:20:55 +00:00
Michael Vogt
aecbe5928a main: add new --registrations options
This new flag allows to add a file with registration data. This
is meant to eventually hold all sort of registrations like
ansible or satelite but initially only contains the redhat
subscription. Currently only JSON is supported.

It looks like:
```json:
{
  "redhat": {
    "subscription": {
      "activation_key": "ak_123",
      "organization": "org_123",
      "server_url": "server_url_123",
      "base_url": "base_url_123",
      "insights": true,
      "rhc": true,
      "proxy": "proxy_123"
    }
  }
}
```

This is not part of the blueprint (today) because its more
ephemeral than the things we usually put into the blueprint.

This allows us to build images that are immediately registered. It
also keeps our options open in the future. If we move to a new
blueprint format where we support multiple blueprints and also
ephemeral data like this the "registrations" flag just becomes an
alias for "--blueprint".
2025-04-17 13:17:24 +00:00
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
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
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
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
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
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
02461ac2a3 main: allow seed setting
Allow users to define the seed that's used for manifest generation.
Regenerating an image with a given seed leads to the same manifest
(provided depsolving does the same).

The seed is normally mostly used to generate random filesystem UUIDs.

This will need a bunch of documentation in a follow up since the use
cases are meant to be advanced but it can really speed up multi-type and
rebuilds of the same image.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-03-31 17:31:12 +00:00
Michael Vogt
d00e76ced1 main: tweak handling of --output-name to avoid adding double extensions
This commit tweaks the handling of the `--output-name` option so
that is a name with the same extension as the image is passed that
is just silently ignored. Its a common issue that first time
users run:
```console
$ image-builder build --output-name foo.qcow2 qcow2
```
which currently leads to a foo.qcow2.qcow2. With this commit
the expected "foo.qcow2" will appear.
2025-03-27 14:03:11 +00:00
Michael Vogt
d4c31389a9 main: show output directory content after image build
This commit adds the content of the output directory when a
build is finished. This is a convenient feature to make it easier
for the users.

Thanks to Simon for suggesting this!
2025-03-27 13:21:43 +00:00
Michael Vogt
fe713a0995 main: tweak how ibcli determines if bootstraping is needed
This simplifies the way that ibcli determines if the manifest
needs a bootstrap stage or not. The logic is simple:
- when doing `image-builder manifest` we never include one
- when doing `image-builder build --arch` we add one if the
  target arch and host arch differ

Instead of passing a callback this is now just a simple bool
option. Thanks to Achilleas for suggesting this.

Co-Authored-by: Achilleas Koutsou <achilleas@koutsou.net>
2025-03-27 08:42:49 +00:00
Michael Vogt
8e6a6673f5 main: auto-cross build for foreign architectures 2025-03-25 11:58:24 +00:00
Simon de Vlieger
e7b9fbff1e ibcli: don't split outputfilename
A small test for a basename that includes dotted parts (as used by for
example Fedora's buildsystem).

Also some code changes to make this test pass, it seems that SBOM base
was determined based on some other filename which is now no longer
relevant?

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-03-14 14:47:36 +00:00
Michael Vogt
b51d1f983a image-builder: use testutil.Chdir() in TestBuildIntegrationHappy 2025-03-14 14:47:36 +00:00
Michael Vogt
ccb4269b62 ibcli: add new --output-name flag
This commit adds a new `--output-name` flag that will rename
the resulting artifact after it was build. All auxillary artifacts
like buildlog, sbom etc are also name based on the same basename.

See also https://github.com/osbuild/images/pull/1039 for how
this could be simpler (especially the fake osbuild).

Closes: https://github.com/osbuild/image-builder-cli/issues/43
2025-03-14 14:47:36 +00:00
Michael Vogt
8635a22ad9 main: skip arch checks onIMAGE_BUILDER_EXPERIMENTAL=bootstrap
This commit skips the arch checks if the experimental "bootstrap"
option is used. The main use-case of this option is to bootstrap
a foreign architecture so just assume that and skip arch checks
when set.

This allows to write:
```
$ IMAGE_BUILDER_EXPERIMENTAL=bootstrap=ghcr.io/mvo5/fedora-buildroot:41 \
   ./image-builder build --arch=riscv64 minimal-raw --distro=fedora-41
```
and do a riscv64 cross arch build.
2025-03-12 18:10:46 +00:00
Michael Vogt
06e73caec1 main: show "success" message with output dir when build finishes
This commit adds a "success" message that also contains the output
dir when the build finishes.

Thanks to SimonS for suggesting this!
2025-03-12 17:03:59 +00:00
Michael Vogt
c3ca146161 main: fix creating output dir for --with-buildlog
Trivial fix for the missing `mkdir()` call when `--with-buildlog`
is specified (and the matching test update).
2025-03-07 13:17:10 +00:00