Commit graph

108 commits

Author SHA1 Message Date
Simon de Vlieger
4d9cf723fd main: rename output to format
We had a chat about this and we feel that `format` is less ambiguous a
name for this argument.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-02-27 10:58:11 +00:00
Simon de Vlieger
58aa0cf87b main: rename basedir -> base-dir
Rename the `basedir` argument to be consistent with `output-dir`
by hyphenation.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-02-27 10:58:11 +00:00
Michael Vogt
2e741a70ad main: add build --with-buildlog
This commit adds a new `--with-buildlog` option that will automatically
create a buildlog in the output directory.
2025-02-25 12:08:51 +00:00
Lukas Zapletal
6dd8515801 main: simplify upload error handling 2025-02-18 09:49:16 +00:00
Michael Vogt
bc5be2ba8a main: add --force-repo flag
This commit adds an `--force-repo` flag that can be used
to replace all the base repositories with a base url to
a repository. This is useful for testing but also dangerous
as it will not do any checks and happily use a fedora-42 repository
for centos-8 depsolving.

This will make the use-case of the koji builder easier and is
also something that the `build` tool in `images` supports.
2025-02-13 11:31:06 +00:00
Michael Vogt
e2aeecec8e repos: make clearer why newRepoRegistry is a var
This commit reworks the `newRepoRegistry` func so that its easier
to see that it is a variable so that it can be overriden by the
tests. In the tests we want to use the `testrepos` we get from
images and in the real implementation we want to use the full
repo loader with search-paths and extra repos.
2025-02-12 12:57:27 +01:00
Michael Vogt
a11e124133 main: add new --extra-repo flag
This commit adds a  new flag `--extra-repo` that can be used
to point to a repository url that is added to the base
repositories when depsolving. Note that *no* gpg checking
will be performed for such repos as there is no way to
add gpg-keys (yet) via this mechanism.

This means that with a repo created with e.g. `createrepo_c` like
```console
$ mkdir repo
$ (cd repo && dnf download hello)
$ createrepo_c ./repo
```
and a blueprint like:
```toml
[[packages]]
name = "hello"
```
a manifest is generated that gets hello from this local repo:
```console
$ image-builder  --extra-repo file:$(pwd)/repo manifest qcow2 --distro centos-9 --blueprint ./bp.toml |jq|grep hello
          "path": "hello-2.12.1-5.fc41.x86_64.rpm",
```
Note that this is part of the base repositories so anything with a
higher version number will get pulled from the extra-repo, even
system libraries or kernels. Note also that this repository does
not become part of the image so after the image build all rpms
from there are not updated (unless of course the normal repos
have higher versions of them).

Note as well that there is no safeguard right now against adding
extra repos for the wrong version of the distro, i.e. one could
add an extra repo build against/for fedora-42 on a fedora-40 image
which most likely will break with bad depsolve errors. But that
is okay, this option is meant for advanced users and testing.
2025-02-12 12:57:21 +01:00
Michael Vogt
25f21a3205 main: add upload support directly to build
This commit adds support to upload the build image directly to
the target cloud. Currently only ami/AWS is supported.

If the cloud specific configuration is given at the commandline
and the image type is a cloud image the cloud upload will happen
automatically (just like with bib). Incomplete upload config is
an error.
2025-02-11 13:38:04 +01:00
Michael Vogt
e41377b82a main: add new upload command
This commit adds a new `upload` command that can be used to
upload a raw image to the cloud. Currently only AWS is
supported but as images adds more clouds to the uploader interfac
we can easily expand more.

The cloud is currently detected via the file extension, that
mapping probably should also go into the `images` library.
2025-02-11 13:38:04 +01:00
Michael Vogt
0678d8ddfd main: update for new reporegistry.New() api (c.f. pr#1179)
This commit updates ibcli for the new API in images for the
`reporegistry.New()`. The main incompatible change is that the
`/repositories` part is not longer automatically added inside
the library so we need to add it on the call-site.

This needs https://github.com/osbuild/images/pull/1179
2025-02-10 20:40:56 +01:00
Michael Vogt
0a3c642772 go.mod: update to get the latest progress fixes from bib
This commit updates the `progress` package to get the latest
fixes, most notably
https://github.com/osbuild/bootc-image-builder/pull/820
2025-02-10 11:46:55 +01:00
Simon de Vlieger
036de52a39
describeimg: typo in describe output
`os_vesion` -> `os_version`

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-02-06 20:00:49 +01:00
Michael Vogt
7c6db68c98 main: add -v,--verbose switch that enables verbose build logging
This commit adds a new `-v,--verbose` switch that enables verbose
build logging.

Closes: https://github.com/osbuild/image-builder-cli/issues/112
2025-02-05 09:36:38 +00:00
Michael Vogt
19ef77337a main: reset the terminal properly on SIGINT,SIGTERM
This commit fixes the issue that on `CTRL-C` (SIGINT) the progress
is not properly cleared. It also catches SIGTERM for good measure.

No test right now as this is hard to test automatically :/

Closes: https://github.com/osbuild/image-builder-cli/issues/123
2025-02-04 13:11:11 +00:00
Michael Vogt
24dc23ac3b main: fix auto-detected distro that is non-visible, tweak order
This commit fixes the issue that the auto-detect distro is not
visible in the progress message. It also tweaks the order of
the message to show:
```
Building manifest for <distro>-<img-type>
```
to be more conistent.

Closes: https://github.com/osbuild/image-builder-cli/issues/121
2025-02-04 12:21:13 +00:00
Michael Vogt
3c2e8dd9af cmd: add new describe-image command
This commit adds a new `describe-image` comamnd that contains
the details about the given image type. The output is yaml as
it is both nicely human readable and also machine readable.

Note that this version carries an invalid yaml header on
purpose to avoid people replying on the feature for scripts
before it is stable.

The output looks like this:
```yaml
$ ./image-builder describe-image rhel-9.1 tar
@WARNING - the output format is not stable yet and may change
distro: rhel-9.1
type: tar
arch: x86_64
os_vesion: "9.1"
bootmode: none
partition_type: ""
default_filename: root.tar.xz
packages:
  include:
    - policycoreutils
    - selinux-policy-targeted
    - selinux-policy-targeted
  exclude:
    - rng-tools
```

Thanks to Ondrej Budai for the idea and the example.
2025-01-31 10:57:50 +00:00
Michael Vogt
c590c38d4f main: silence all logrus logging for now
This commit silences logrus logging for now by just dicarding
everything from it. The rational is that the underlying libraries
produce a lot of output, e.g. every build currently results in
```console
$ image-builder build qcow2
WARN[0000] Failed to load consumer certs: no consumer key found
...
```
which is confusing to our users. What is worse is that containers
also uses logrus so we can get random warnings without context
from there too. Until we have a way to filter log messages this
seems to be the most practical way.

We can add `--verbose` or `--debug` later to enable these kinds
of messages.
2025-01-30 17:30:31 +00:00
Michael Vogt
0f0815d268 main: tweak the help of manifest and build
This commit tweaks the help output for the manifest and build
commands to make clear that only the image type is a required
argument but the rest can be overriden via extra flags.

Thanks to Achilleas for noticing.
2025-01-29 20:50:47 +00:00
Michael Vogt
f46ca14f85 image-builder: update TestBuildIntegrationErrors tests
This commit updates the tests for the error reporting. Since
we are now using the new "progress" module we can no longer
directly mock osStderr. So this now uses the new testutil
helper `CaptureStdio`.

Note also that the behavior of `verbose` and `term` is slightly
different - for backward compatibility in `verbose` mode the
stderr from osbuild is directly connected to the caller stderr.

For term mode this is not done to prevent spurious message from
leaking into the terminal progress and the full error is available
from the actual go error as captured output.
2025-01-29 15:21:33 +00:00
Michael Vogt
1198c73102 main: add progress support via bibs code
This commit add progress reporting similar to what `bib` is doing.
It imports the progress from `bootc-image-builder` for now. There
is an open PR for moving this to images but there are some
concerns about moving it there so for now we just use bib.
This is not too bad because eventually bib and ibcli will merge.
2025-01-29 15:21:33 +00:00
Simon de Vlieger
af0fa97403 manifest: slightly clean up directory creation
Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-29 11:56:14 +00:00
Simon de Vlieger
34de7d7ce5 build: directory creation
This now precreates the directory as it's possible that the directory
doesn't exist yet at this point; see #94.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-29 11:56:14 +00:00
Michael Vogt
98e4bebcfa image-builder: drop internal manifestgen in favor of images
This commit drops the internal `manifestgen` package in favor
of using the version in `images` now that
https://github.com/osbuild/images/pull/1153 is merged.
2025-01-27 10:14:53 +00:00
Ondřej Budai
5d1be8bbb1 cmd/image-builder: fix typos in cobra descs 2025-01-27 08:46:32 +00:00
Michael Vogt
222d42dc1c test: consolidate the build argument tests into a single table
This commit puts the build argument tests into a single table to
cosolidate them a bit.
2025-01-25 11:08:01 +00:00
Florian Schüller
b4815631a3 cmd/image-builder/main: fix typo in --filter help 2025-01-24 14:05:17 +00:00
Florian Schüller
3f881601fc cmd/image-builder/main: improve wording of --blueprint help
When reading `--blueprint string`, I briefly thought it might
also be possible to put a whole blueprint content as string
into image-builder-cli argument.
This wording should avoid misunderstandings.
2025-01-24 14:00:54 +00:00
Simon de Vlieger
ebba957fad test: add combi test sbom/manifest
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-20 15:42:21 +00:00
Simon de Vlieger
613f56e7d2 image-builder: slight cleanup
Remove all slice operations.

Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-20 15:42:21 +00:00
Simon de Vlieger
585d349d0f image-builder: --extra-artifacts split
Split out `--extra-artifacts` into `--with-sbom` and `--with-manifest`.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-20 15:42:21 +00:00
Simon de Vlieger
ee38c45122 image-builder: rename --store to --cache
Closes #77.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-20 15:42:21 +00:00
Michael Vogt
0580eb1106 main: add --extra-artifacts=manifest
This commit adds support for `--extra-artifacts=manifest`. If
that is given as part of the build an extra artifacts called
`<img-name>.osbuild-manifest.json` will be created in the
output directory.

Closes: https://github.com/osbuild/image-builder-cli/issues/42
2025-01-20 14:12:30 +00:00
Michael Vogt
c4357b3bfa build: introduce buildOptions 2025-01-20 14:12:30 +00:00
Simon de Vlieger
0eb6c5e262 image-builder: newline in error message
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-20 06:55:24 +00:00
Michael Vogt
cc2d1ac692 main: add --output-dir option
This commit adds a new `--output-dir` option to override the
default output directory for the generated artifacts.

Note that this can also be used together with `manifest` when
extra artifacts (like the sbom) is requested.
2025-01-19 21:57:14 +00:00
Michael Vogt
d485bc3a44 ibcli: add new --extra-artifacts option with sbom support
This commit adds an option --extra-artifacts that can be
used to generate extra artifacts during the build or manifest
generation. Initially supported is `sbom` (but `manifest` is
planned too).

To use it run `--extra-artifacts=sbom` and it will generate
files like `centos-9-qcow2-x86_64.image-os.spdx.json` in
the output directory next to the generate runable artifact.

Closes: https://github.com/osbuild/image-builder-cli/issues/46
2025-01-19 21:57:14 +00:00
Michael Vogt
db7cad2239 main: tweak TestBuildIntegrationErrors
We do not need to pass a blueprint in this test.
2025-01-19 21:57:14 +00:00
Michael Vogt
687f69bb76 main: make "--use-librepo" the default
This commit switches the default to librepo. We do not have many
users yet so this is a great place to test the new librepo
functionality. It also is much more stable for fedora/centos
systems that often have flaky mirrors.

This also bumps the minimum required version of osbuild.
2025-01-17 13:29:01 +00:00
Michael Vogt
44f27108b9 ibcli: introduce/use manifestOptions struct
This commit adds a new manifestOptions struct that is passed
to generateManifest. to cleanup the signature of generateManifest().

This can then also be used to carry a new e.g. `--rpmmd/--cachedir`
option.
2025-01-17 13:29:01 +00:00
Michael Vogt
f8ffa8a258 main: add experimental --use-librepo to support librepo downloads
This commit switches to the librepo enabled `images` library via:
```
go mod -replace github.com/osbuild/iamges=github.com/mvo5/images@librepo-sources-osbuild1974
```
which in turn needs osbuild PR#1974.

With that it then adds a new `--use-librepo` switch that will
enable librepo based downloading so that people can play with
the new backend.
2025-01-17 13:29:01 +00:00
Simon de Vlieger
ff62775628 cmd: exactly 1 arg
Since we only accept one image type (for now) we only need to accept
exactly one argument.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-17 08:57:36 +00:00
Simon de Vlieger
0c255f2bdb cmd: fix usage
We don't pass `[blueprint]` positionally anymore.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-17 08:57:36 +00:00
Simon de Vlieger
c1c60a3c77 cmd: --blueprint
Moves the blueprint argument to a named argument; freeing up space to
later be able to pass in multiple image types. This also slightly
simplifies the case where we're building without a blueprint available.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-16 12:31:13 +00:00
Michael Vogt
8f94516779 main: add ostree integration
This commit adds integration for the ostree options. It is modelled
loosely after weldr-client/composer-cli and the
```
start-ostree --{ref,parent,url}
```
and uses
```
--ostree-{ref,parent,url}
```

A simple smoke test is provided that uses fedora-iot. Ideas welcome
for an easier way :)
2025-01-10 14:37:47 +00:00
Michael Vogt
fb56109048 cmd: drop TestListImagesOverrideDatadir
With the new build-in repos this test is no longer relevant. We
need to look into a different way to test overrides but just
providing an empty datadir will no longer work so drop that.
2025-01-10 08:30:28 +00:00
Michael Vogt
ffc676e3d0 main: help golang-ci to find the "main" symbol in the tests 2025-01-10 08:30:28 +00:00
Michael Vogt
80cadaf291 repos: lookup <buildin>, /{etc,usr/share}/image-builder/repositories
This commit switches the default repositories to use the build-in
ones from images PR#1112. It is still possible to override using
`/etc/image-builder` and `/usr/share/image-builder` or `--datadir`.

This is implicitly tested via the container test that no longer
includes the files from osbuild-composer in the container.
2025-01-09 16:17:50 +00:00
Michael Vogt
f89342a1bd ibcli: use /var/cache/image-builder/store as default for --store
This commit follows a suggestion from Ondrej to add a better
default for `--store`: /var/cache/image-builder/store.

This is nice as it will give users automatic caching and makes
the container also nicer.
2024-12-19 11:35:15 +00:00
Michael Vogt
b3f9fb88f1 main: add new --store argument to image-builder build
This commit adds a new `--store` flag to the `image-builder build`
command. This is used to specify a osbuild store directory to
store the intermediate build tree for faster rebuilding. It is
also useful for the container version of `image-builder-cli` to
allow mapping the users store into the container.
2024-12-19 08:49:26 +00:00
Michael Vogt
e5b3ccd6ed cmd: add new build command
This commit adds the `build` command. It takes the same flags as
`manifest` and will build the specified image.
2024-12-16 14:59:08 +00:00