Commit graph

339 commits

Author SHA1 Message Date
Tomáš Hozza
f4fa09abf3 FIXUP: .packit.yaml: fix issues when building SRPM
Packit needs golang to be installed when we build SRPM, because we need
to vendor code to generate the archive.

Moreover, we need to vendor code to be able to modify SPEC port upstream
clone to include bundled code.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-19 14:45:01 +00:00
Florian Schüller
89fec6d5d0 Makefile: assure bundle info in spec file
The release artifact should contain the spec file including the
bundle information.
2024-12-19 14:45:01 +00:00
Tomáš Hozza
b870c404a5 Add initial Packit configuration
For now, Packit should trigger COPR buils for PRs and merges to the
`main` branch.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-19 14:45:01 +00:00
Tomáš Hozza
f1b09b91a9 Makefile/release_artifacts: print the archive path
Packit needs expects the archive path to be printed when specifying a
custom action to build the archive. See [0].

[0] https://packit.dev/docs/configuration/actions#create-archive

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-19 14:45:01 +00:00
Florian Schüller
50c79f154d Makefile: support for make release_artifacts
Supports to package `vendor/` directory
which is not part of the repository.
2024-12-19 14:45:01 +00:00
Simon de Vlieger
60c22e3214 package: spec file
Provide a spec file for `image-builder-cli`. The spec file is based on
`osbuild-composer`'s spec file except it is simplified as (some)
usecases would currently cloud the intent of the specfile. We can add
back RHEL conditionals when/if we start shipping and building for RHEL.

Some tools from `osbuild-composer` are also included; most notably the
one that generates bundled dependencies from vendored modules.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2024-12-19 14:45:01 +00:00
Simon de Vlieger
cdf627389e ci: dependabot
As we've now vendored our dependencies let's enable dependabot in the
same way we use it in our other Go projects.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2024-12-19 14:45:01 +00:00
Simon de Vlieger
38af61d633 ci: enable aarch64 container builds
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2024-12-19 14:26:40 +00:00
Michael Vogt
119e8fcffa workflow: run tests as part of the merge group
This commit adds the missing `merge_group` to the pytest and go
test workflows.

Note that I added `types: [ "checks_requested" ]` (just like we
have for the container.yaml) but I'm not actually sure about it,
the GH docs are a bit unclear to me here, it seems they suggest
to keep this generic but then the example explicitly uses `type`
(I'm probably overthinking this fwiw).

[1] https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#merge_group
2024-12-19 12:08:08 +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
083c220f0a test: move to centos-9 for the smoke test
This commit moves the smoke test from fedora-41 to centos-9. The
reason is that it seems the fedora mirrors in general are a bit
more flaky so /hopefully/ the centos one will help.

The real fix of course is to retry different mirrors on failure,
we will need to look into librepo integration in osbuild (again)
for this (hopefully soon!).
2024-12-19 11:33:13 +00:00
Michael Vogt
f631a16976 workflow: rename all .yml files to .yaml
The original `go.yml` got added via some GH automation. But we
are not MSDOS and we can affort more than 3 chars for a file
extension - so this commit renames all .yml to .yaml which is
what we use everywhere else.
2024-12-19 11:32:37 +00:00
Michael Vogt
058e3d6832 manifestgen: use temporary cache dir if no cacheDir is given
This commit creates a temporary directory for the defaultDepvolver()
if no cacheDir is given. This ensures that we do not clutter the
current working directory with `platform:foo` cache directories
that `solver.Depvolve()` creates.

Note that this is only tested indirectly via the integration test
in `test_container.py:test_container_builds_image()` that checks
that the output directory is clean.
2024-12-19 08:49:26 +00:00
Michael Vogt
cc4a730381 github: add new pytest based integration test run workflow
This commit adds a new workflow that runs the new `pytest` based
integration tests inside GH actions. It also extracts a common
`testdeps.yml` reusable workflow so that we do not duplicate the
package list of test dependencies.
2024-12-19 08:49:26 +00:00
Michael Vogt
e7d8a39fcf test: add minimal test for container based building of images
This commit adds a smoke test that builds the ibcli container
and runs a fedora-41 raw-minimal build to double check that
the container based building actually works.

Thanks to Ondrej for suggesting this.
2024-12-19 08:49:26 +00:00
Simon de Vlieger
fad02336b3 ci: build container
Automatically build the container for `image-builder-cli` and upload it
to `ghcr.io`. This builds only for x86 initially.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2024-12-19 08:49:26 +00:00
Michael Vogt
5aa75ec1c1 Containerfile: initial version
This commit adds an initial Containerfile to build an `image-builder`
container.

Use all the DNF commands together and add a cleaning command to the end
of it. This makes fewer layers and keeps the image size slightly
smaller.

Co-authored-by: Simon de Vlieger <supakeen@redhat.com>
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2024-12-19 08:49:26 +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
Michael Vogt
ce8dd45821 testutil: new package to test run osbuild run functionality
This commit adds a new testutil.MockCommand() helper that will
mock a command in $PATH to allow easier testing of e.g. the
`image-builder-cli build` comamnd that will invoke osbuild.
2024-12-16 14:59:08 +00:00
Simon de Vlieger
ea7b58bd5c chore: README blurbs
Add the common blurb(s) that are on all Image Builder project READMEs.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2024-12-16 09:13:47 +00:00
Simon de Vlieger
312b24925f chore: LICENSE
Provide the common license (Apache) that is used for Image Builder
projects.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2024-12-16 09:13:44 +00:00
Michael Vogt
4b8bff8404 cmd: rework argument handling
This commit tweaks the argument handling based on the suggestion
by Achilleas and Ondrej (thanks!). Now it takes
```console
$ image-builder manifest qcow2 ./path/to/blueprint
...
$ image-builder manifest --arch s390x --distro centos-9 qcow2
...
```
If no arch is specified the hostname arch is used. If no distro
is specified in either the blueprint or the commandline it is
auto-detected based on the host.

Note that if the distro from the comandline and the blueprint
diverge an error is raised. We can relax this rule and just
add precedence, e.g. commandline always overrides the blueprint
but ideally we would have a clear use-case here so we start
conservative and can always relax this rule later (the inverse
is much harder).

This means it is no longer copy/paste friendly from `list-images`
by default but instead we can provide a new
`list-images --output=shell` option that outputs in exactly the
format that `image-builder [manifest|build]` need.
2024-12-16 07:54:45 +00:00
Michael Vogt
0d06eedd26 image-builder: add integration test for container resolving
This commit adds an integration test for the container resolving
when generating a manifest. This is sadly quite indirect right now
because `manifestgen` needs some more support from `images` and
the `distro_test` code there (that will hopefully come soon(ish)).
2024-12-16 07:54:45 +00:00
Michael Vogt
05ef9502e4 cmd: add blueprint support to manifest
This commit adds support to pass a blueprint to the manifest
generation.
2024-12-16 07:54:45 +00:00
Michael Vogt
f242005672 internal: add new blueprintload package
This commit provides a `blueprintload` package that can be used
to load blueprints from json/toml from a path. This will be used
in `bootc-image-builder` and `image-builder-cli` and should
eventually be merged into `images`.
2024-12-16 07:54:45 +00:00
Michael Vogt
830528fa15 cmd: implement manifest command
This commit implements the `manifest` command for `image-builder`.
It will generate an osbuild manifest based on the given inputs,
e.g.:
```
$ ./image-builder manifest centos-9 qcow2
{"version":"2","pipelines":[{"name":"build","runner":",...
```

Note that there is an integration test but because of the depsolve
it will be slow. It will be skipped when doing `go test -short`.
2024-12-16 07:54:45 +00:00
Michael Vogt
ea61ef593f pkg: add new manifestgen package
This commit adds a new generic `manifestgen` package that can be
used to generate osbuild manifests. It works on a higher level
then the low-level `manifest` package from `images` and provides
plugable resolvers and a streamlined API.

This package is meant to be moved to the `images` library eventually.
2024-12-16 07:54:45 +00:00
Michael Vogt
5a6ee5c1ca pkg: add new manifesttest package with test helpers
This commit adds a new `manifesttest` that helps sharing code
when testing generated osbuild manifests.
2024-12-16 07:54:45 +00:00
Michael Vogt
8ae5b98d9d HACKING.md: add basic documentation for the development
This commit adds a basic HACKING.md that explains the bare mimimum
to get started, including `go test -short` to skip the expensive
tests.

Contains also a drive-by rename of the test dependency install
for the GH action.
2024-12-16 07:54:45 +00:00
Michael Vogt
e9e8dc5256 filters: add new getOneImage() helper for manifest/build
This commit adds a helper to find exactly a single image from a
given disto/type/arch description. This will be used in `manifest`,
`build` and potentially more. It is meant to support copy/paste
from the `image-builder list-images` output, so: "distro:centos-9"
is support just like "centos-9" (same for distro/imgType/arch).
2024-12-16 07:54:45 +00:00
Florian Schüller
7f9936acc9 go.mod: upgrade golang.org/x/crypto
Upgrade golang.org/x/crypto due to
https://github.com/osbuild/image-builder-cli/security/dependabot/1
2024-12-12 18:48:50 +00:00
Michael Vogt
6d978ddc20 main: list-images takes no args (just --filter)
Tiny commit to error if extra arguments are passed to list-images.
Only `--filter` is supported there currently.
2024-12-03 13:12:22 +00:00
Michael Vogt
99bd43e7d4 README: document install, prerequists and list-images
This commit adds some examples and how to use to the README.
2024-11-29 10:52:28 +00:00
Michael Vogt
2719f3f727 list-images: add --datadir override for e.g. custom repositories
This commit adds a `--datadir` override that allows overriding
the default search paths for e.g. the custom repositories. In
practise only repository overrides are supported because that
is the only data stored there.
2024-11-29 08:30:30 +00:00
Michael Vogt
56f9c6969c workflow: update to work with the images dependencies
This commit updates the GH workflow file to install the required
dependencies to build the images library.
2024-11-28 09:53:08 +00:00
Michael Vogt
7a838332c8 main: initial version of image-builder with basic --list-images
This commit adds the new `image-builder` binary. This binary is
meant to build images from the CLI without the need to setup a
daemon. The main use-case is CI/CD and admins running this in
scripts or ad-hoc. The CLI should be pleasant to use.

This first commit adds the `list-images` command which is a thin
wrapper around functionality from the `osbuild/images` library.

It will list all buildable images by default and can be trimmed
down further via `--filter` which supports the filtering from
the `images` library, see https://github.com/osbuild/images/pull/1015

It also supports `--output` which will output the result in the
given format. Currently "text" and "json" are supported.

Note that this will not work on it's own yet, it will need an
installed image-builder to get the repositories. This will need
to get fixed via either:
1. a dependency package for `ibuilder` that carries all the repos
2. a shared repo that contains the repos
3. using go:embed to get them (see images#1038)
2024-11-28 09:53:08 +00:00
Michael Vogt
12d60a9c74
workflow: add trivial go workflow based on default template 2024-11-18 10:26:22 +01:00
Michael Vogt
c718759dea README.md: initial draft 2024-11-12 09:47:16 +01:00