Commit graph

920 commits

Author SHA1 Message Date
Michael Vogt
d068c6d91f dnfjson: detect/error if no repositories are defined
This commit adds an error message if no repositories are
defined in the dnfjson query. We had the issue in
https://github.com/osbuild/bootc-image-builder/issues/922
that in a RHEL bootc-container no repositories are defined.

Here the error is quite confusing, as it complains about
error marking packages which is technically correct but
hides the root of the problem.

With this detect we can construct a more useful error
message in the higher layers.
2025-05-12 20:51:57 +02:00
schutzbot
0e10c05172 Post release version bump
[skip ci]
2025-05-07 08:35:21 +00:00
Michael Vogt
549136b1b0 tools: drop requirement for module_platform_id from request
The PLATFORM_ID got retired from fedora-43 [0] and it
seems like it was always kinda optional. So lets make
it optional for real to avoid failing to build fedora-43
images.

[0] https://fedoraproject.org/wiki/Changes/Drop_PLATFORM_ID
2025-05-07 10:28:47 +02:00
Brian C. Lane
59fe07a6ab solver: Call update_cache
DNF apparently doesn't check the expiration time on the cache unless you
call this first. It may help improve issues with the cache being out of
sync.

Internally dnf checks the mtime of the main repomd.xml file when using
baseurl, and it checks the hash values when using metalink so this
should not result in any noticeable extra slowdowns when things are
fresh.
2025-05-05 13:56:54 +03:00
Brian C. Lane
d3dc07886c solver: Use load_repos instead of update_and_load_enabled_repos
The old function has been deprecated by dnf5, use load_repos directly
and only load the available repos (the ones osbuild has setup), not the
system repos.

Fixes #2080
2025-04-25 17:16:13 -07:00
schutzbot
025c8dd51d Post release version bump
[skip ci]
2025-04-23 08:33:27 +00:00
schutzbot
50a6f2733e Post release version bump
[skip ci]
2025-04-16 13:57:25 +00:00
schutzbot
912a1130cf Post release version bump
[skip ci]
2025-04-09 08:35:18 +00:00
Michael Vogt
f52aeb0676 osbuild: add experimental flag debug-qemu-user
This commit adds support for more debug for `qemu-user` options.
When settings:
```
$ sudo IMAGE_BUILDER_EXPERIMENAL=debug-qemu-user bootc-image-builder ...
```
extra debug will be printed. This hopefully helps to track down
the root cause of
https://github.com/podman-desktop/extension-bootc/issues/1475
2025-04-03 10:49:06 +02:00
Michael Vogt
ba0d9df68e util: add new util.experimentalflags.get_{bool,string} helpers
This commit adds two new helpers:
- util.experimentalflags.get_bool()
- util.experimentalflags.get_string()
similar to what we added in the images library in PR:
https://github.com/osbuild/images/pull/1248

The idea is that we provide experimentalflags for osbuild via
an environment like `OSBUILD_EXPERIMENTAL` and for those we
make no API promises. This will be initially used for better
debug of qemu-user.
2025-04-03 10:49:06 +02:00
schutzbot
7b843dc83e Post release version bump
[skip ci]
2025-04-01 13:54:43 +00:00
schutzbot
140abb03b0 Post release version bump
[skip ci]
2025-03-26 08:33:10 +00:00
schutzbot
8daf928b62 Post release version bump
[skip ci]
2025-03-12 08:33:19 +00:00
Tomáš Hozza
551d1f4ef2 sbom/spdx: always use license ref IDs as is
Always return License ref IDs as is, if used as package license,
regardless if license_expression package is available. This will prevent
wrapping them again as extracted license info and generating yet another
license ref ID.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-27 13:31:19 +01:00
Tomáš Hozza
a07431bb34 osbuild-depsolve-dnf: allow passing custom license index db file
Allow passing a custom license index db file for SBOM generation by
specifying it in the solver configuration.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-27 13:31:19 +01:00
Tomáš Hozza
a3428e282d sbom/spdx: use compliant license expressions
Introduce a new class `SpdxLicenseExpressionCreator`, responsible for
converting license texts extracted from packages, into an SPDX-compliant
license expressions. If the `license_expression` Python package is
available on the system, it is used to determine the license text
extracted from a package is a valid SPDX license expression. If it is,
it's returned as is back to the caller. If it is not, or of the package
is not available on the system, the license text is wrapped in a
`ExtractedLicensingInfo` instance.

The `SpdxLicenseExpressionCreator` object keeps track of all generated
`ExtractedLicensingInfo` instances and de-duplicates them based on the
license text. This means that if two packages use the same
SPDX-non-compliant license text, they will be wrapped by an
`ExtractedLicensingInfo` instance with the same `LicenseRef-` ID.

The reason for fallback when `license_expression` package is not
available is that it is not available on RHEL and CentOS Stream. This
implementation allows us to ship the functionality in RHEL and
optionally enabling it by installing `license_expression` from a 3rd
party repository. In any case, the generated SBOM document will always
contain valid SPDX license expressions.

Extend unit tests to cover the newly added functionality.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>

FIXUP: sbom/spdx: use compliant license expressions

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-27 13:31:19 +01:00
Tomáš Hozza
aaa6d8ec84 sbom/spdx2/model: support ExtractedLicensingInfo
Extend the SPDX v2 model to support referencing extracted licensing
information, which is either not in the SPDX license list or can't be
expressed by the SPDX-compliant license expression.

Cover the new functionality by unit tests.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-27 13:31:19 +01:00
schutzbot
39bfe3ce2d Post release version bump
[skip ci]
2025-02-26 08:32:13 +00:00
Michael Vogt
b22cbd3298 monitor: limit the amount of data sent in JSONSeqMontior.result()
This commit limits the output in the json pipeline to a "reasonable"
length. We ran into issues (e.g. [0]) from a combination of a stage
that produce tons of output (dracut, ~256 kb, see issue#1976) and
the consumer ("images" osbuild/monitor.go) that used a golang scanner
with a max default buffer of 64kb before erroring. So limit it
here.

The stage result from via json is mostly for information and any error
will most likely at the end. Plus consumers can collect the individual
log lines on their own if desired via the "log()" messages that are
stream in "real-time" with the added benefit that e.g. timestamps
can be added to the logs etc.

[0] https://issues.redhat.com/browse/RHEL-77988
2025-02-18 10:36:59 +01:00
schutzbot
6f69be6897 Post release version bump
[skip ci]
2025-02-12 08:30:17 +00:00
Simon de Vlieger
b2ec2cd5ee Revert "ostree: introduce optional subpath feature"
This reverts commit 3bb5bedd8e as it
introduces problems in the caching system used by `osbuild` [1]

[1]: https://github.com/osbuild/osbuild/issues/2009
2025-02-11 17:39:45 +01:00
Lukas Zapletal
3bb5bedd8e ostree: introduce optional subpath feature 2025-02-10 20:17:36 +01:00
schutzbot
33fd0bd183 Post release version bump
[skip ci]
2025-02-04 10:34:47 +00:00
Michael Vogt
035781ea1c osbuild: add a mutex to the _jsonseq() writer
This commit fixes a race/threading issue with the way the monitor
works. The osbuild monitor can be called from multiple threads,
e.g. in buildroot.py:run() monitor.log() is called but also
in host.py:_stdout_ready(). This can lead to out-of-order writes
when many messages need to be processed.

We did not notice this so far because we were lucky and also
log was just used for information. But now it is used to transmit
the jsonseq data which means out-of-order communication results
in broken json.

Closes: https://github.com/osbuild/image-builder-cli/issues/110
2025-01-30 20:08:53 +01:00
schutzbot
d925c26501 Post release version bump
[skip ci]
2025-01-29 08:30:14 +00:00
Simon de Vlieger
b6acd240f7 depsolve: remove nevra field
The NEVRA field accidentally made it into the public API. It shouldn't
be as it is not used downstream and in fact breaks downstream.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-23 20:07:12 +01:00
Simon de Vlieger
ffcafb390d depsolve: relax the module naming requirement
Remove the requirement for `:` in the name which would have been
selected by the fronted, instead asking dnf "is this a module?".

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-22 18:03:21 +01:00
Simon de Vlieger
4337cd9595 solver/dnf4: structured data
Instead of returning the string contents of the module configuration
file let's return some more structured data so the resulting file can be
written with a stage.

Note that we don't do the same for the fallback file as we are only
provided this as a YAML blob and unparsing it to then immediately
reparse it again is counterproductive.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-22 18:03:21 +01:00
Simon de Vlieger
52b4ba7e63 depsolve: use modules-in-package-specs
This changes the depsolver to expect modules inside the normal
`package-specs` instead of having a separate `module-install-specs`.

Modules passed to a "normal" `dnf install` must start with an `@` and
contain a `:`. This is up to the user to pass correctly.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-22 18:03:21 +01:00
Simon de Vlieger
0c0580a570 solve/modularity: path + data
Return path and data separately so we have less logic in `images`.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-22 18:03:21 +01:00
Simon de Vlieger
983518042a modularity: handle profiles
We now keep track of enabled profiles and also handle the case where no
profile is selected.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-22 18:03:21 +01:00
Simon de Vlieger
6e9fb7dd6a modularity: depsolving
The commit implements modularity for the dnf4 dependency solver.

The dependency solver now takes two new keys per transaction:
`module-install-specs` and `module-enable-specs`, each of which is a
list of module specifications.

When modules are used and packages for them are installed a new
dictionary is returned in the response where each key is the name of an
enabled module and the value are the contents of the module
configuration and the module failsafe file that DNF needs in the
resulting system.

These values can be used by consumers of the dependency solver, such as
`images`, to create the appropriate inline sources and copy stages.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-22 18:03:21 +01:00
Achilleas Koutsou
1a529d78a9 osbuild/cli: prefer --cache over --store
Make primary name of the cache/store argument 'cache'.  Let's start
preferring it.
2025-01-21 11:35:16 +01:00
Achilleas Koutsou
db7867833a osbuild/cli: mention sources in cache/store help
The cache/store directory is also used to keep sources.  Mention that in
the description of the option.
2025-01-21 11:35:16 +01:00
Achilleas Koutsou
c31443f45b osbuild/cli: add --cache as an alias for --store
The name 'cache' is more recognisable and conveys the purpose of the
option just as well (if not better) than 'store'.
Also, the option that controls the size of this directory is called
'cache-max-size', so we're already referring to it as a cache.
2025-01-21 11:35:16 +01:00
schutzbot
dbfeae4110 Post release version bump
[skip ci]
2025-01-15 08:31:15 +00:00
Michael Vogt
154abafae8 osbuild: tweak build() to be mypy clean
This commit tweaks build() to be mypy clean without the need to
call assert. This drops the map() and instead we use the existing
dict-like access of the manifest to get the pipeline. In practise
this should not happen but lets be prepared.

Note that a small tweak for the error is needed to make it clear
what is happening.

Thanks to Simon for raising this.
2025-01-14 14:33:28 +01:00
Michael Vogt
d6aca23709 osbuild: make {Build,Download}Result as_dict() explicit
This commit makes the returns of the of {Build,Download}Result.as_dict()
explicit. Ideally this would just be a dataclass and dataclass.asdict()
but because we need to support python3.6 this is not possible today.
2025-01-14 14:33:28 +01:00
Michael Vogt
c27c32be0e osbuild: add result error reporting for sources
This commit adds error reporting from source download errors
to the monitor. It reuses the `BuildResult` for symmetry but
we probably want to refactor this a bit to make source handling
a bit more similar to stages.
2025-01-14 14:33:28 +01:00
Michael Vogt
5ba7cadd8b monitor: include build_result in jsonseq monitor streaming
In order to avoid having to rely on the output of `osbuild --json`
when using `--progress=JSONSeqMonitor` the monitor needs to include
the `osbuild.pipeline.BuildResult` for each individual stage.

This commit adds those to the montior.
2025-01-14 14:33:28 +01:00
Michael Vogt
2cb57f0ed8 osbuild: describe the result Manifest.build() and Stage.run()
This commit adds mypy annotations and a docstring to make it
easier to trace the result value of an osbuild run.
2025-01-14 14:33:28 +01:00
Brian C. Lane
28e74f6c9b Add support for using librepo to download packages
Using a metalink or mirrorlist along with the package paths and
checksums allows them to be reliably downloaded even when mirrors are
not all in sync. It will retry with a new mirror until it succeeds, or
has tried all of the mirrors.
2025-01-14 08:19:16 +01:00
Tomáš Hozza
8463394d2c util/path: add join_abs() to join potentially absolute paths
It turned out that in many cases, stages need to join two absolute
paths, the pipeline tree path and the path on a booted system. However,
the standard `os.path.join()` function can't handle such situation as
just prepending the root to the subsequent paths.

Add a new helper function, which is able to join any paths together,
regardless if any of them is absolute or not. If the root is not
absolute, the result will be made absolute to the filesystem root `/`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-06 11:53:46 -08:00
schutzbot
08d0b657ee Post release version bump
[skip ci]
2024-12-18 20:00:01 +00:00
Michael Vogt
25d3656068 util,test: add test for new shlex based os-release parsing
This commit adds a tiny unit test for the new `shlex` based
os-release parsing and tweaks the error message in a small
and non-functional way (just because it's slightly nicer
for a user). The test checks for three keys NAME which is
quoted with `"`, ID which is not quoted and OSTREE_VERSION
which is quoted with `'`.
2024-12-04 14:54:00 -05:00
Renata Ravanelli
07d4f6955d util/osrelease.py: Replaced string stripping with shlex.split()
- Replaced string stripping with `shlex.split()` to properly
handle values in the os-release file;
- This ensures cleaner and more accurate key-value assignments,
follwing a broader set of shell-like parsing rules;
- Add os-release file for Fedora CoreOS 40 for testing.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2024-12-04 14:54:00 -05:00
Dusty Mabe
f4b899873b osbuild/remoteloop: add more loop device options
This adds lock, partscan, read_only, sector_size to _create_device()
similar to make_loop() from devices/org.osbuild.loopback.
2024-12-04 16:30:55 +01:00
schutzbot
b1f16e9ab4 Post release version bump
[skip ci]
2024-12-04 08:32:12 +00:00
Renata Ravanelli
458df8695f util/chroot: Add support for custom directory bind mounts
- Add optional bind_mounts parameter to __init__ method;
 - Enhanced methods to accept an optional `bind_mounts`.
This allows for more flexible for configurations when setting
up bind mounts.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2024-12-03 15:22:40 +01:00
Tomáš Hozza
f1c43ae5bd util/sbom/spdx: rename {,s}bom_pkgset_to_spdx2_doc()
Rename the function for consistency reason. The parent package is named
SBOM (originally BOM).

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-12-02 23:24:39 +01:00