Commit graph

3512 commits

Author SHA1 Message Date
Achilleas Koutsou
2e45963aed test: add rpm stage test for boot_root
Add a stage build test for the boot_root option of the org.osbuild.rpm
stage.  The test defined two manifests that both install the
kernel-uki-virt kernel but differ in the value of the boot_root option.
The diff shows the effect of the value on the install location of the
kernel.
2025-03-13 13:47:43 +01:00
Achilleas Koutsou
305a54f1a2 stages/rpm: add new kernel_install_env options
Add support for setting environment variables for kernel-install and its
plugins.  These can be used to control the behaviour of kernel-install
during the kernel rpm installation.  Currently, we only add support for
$BOOT_ROOT, which we need to control the path where the kernel should be
installed.

Normally, kernel-install scripts will detect the correct path based on
the filesystem layout, specifically the ESP path.  However, during our
installation the filesystem is not yet set up, so with this option, we
can control the installation path based on the location we know the ESP
will be mounted in the final image.

This is a very similar override to what we do with the
org.osbuild.fix-bls stage.

The stage option is added under a kernel_install_env object so we can
potentially support more of the known env vars in the future.
2025-03-13 13:47:43 +01:00
Achilleas Koutsou
7be822d6e9 stages/rpm: set encoding for subprocess.run()
Printing 'owner' in an fstring triggers the mypy warning 'str-bytes-safe'

  Error: If x = b'abc' then f"{x}" or "{}".format(x) produces "b'abc'",
  not "abc".

We can't yet use the nicer run() argument, 'text=True', because we still
target the RHEL 7 build root which only has Python 3.6 and 'text' was
introduced in Python 3.7.
2025-03-13 13:47:43 +01:00
schutzbot
8daf928b62 Post release version bump
[skip ci]
2025-03-12 08:33:19 +00:00
Achilleas Koutsou
f2ab07cf85 stages/grub2.inst: grub2-mkimage in tmpdir
Use a temporary directory for the output of grub2-mkimage.

This makes the stage clean up the grub2-core.img from the build root
after its done.  It also has the nice side-effect that unit tests that
call the stage are independent.  Previously, a bug in the stage *might*
have been missed if a certain configuration of the stage was not
creating the grub2-core.img.  One unit test could create an image at the fixed path
(/var/tmp/grub2-core.img) and then another one could call the stage with
the buggy configuration but the `shutil.copyfile()` call at the end of
the stage would succeed because it would find the image from the
previous stage run.

To accommodate for this change, the unit test with the mocked run call
is adjusted to intercept the random tmp output path and use it to create
a fake file for the stage to succeed.
2025-03-08 02:30:32 +01:00
Michael Vogt
dc24a131e9 stages: add mock test for grub-mkimage for regression test
This commit adds a test that mocks subprocess.run() so that we
can regression test the arguments passed to "grub-mkimage".

This is a regression test for
https://github.com/osbuild/osbuild/issues/2037
2025-03-08 02:30:32 +01:00
Achilleas Koutsou
67070cc316 stages/grub2.inst: fix format for non-x86_64 image
When writing the grub2 core image, the format should be set based on the
platform.  This was accidentally changed to be `i386-pc` for all
platforms except when building ISOs.

Set the format to the platform and only change it to `i386-pc-eltorito`
when building ISOs.
2025-03-08 02:30:32 +01:00
Simon de Vlieger
563153ac6f tools: support zstd in image-info
We have images that are zstd-compresed now so `image-info` needs to be
able to deal with them.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-03-07 16:00:57 +01:00
schutzbot
9b72d9ee50 schutzfile: Update snapshots to 20250304 2025-03-07 16:00:57 +01:00
schutzbot
c08271120a Schutzfile: Update images dependency ref to latest 2025-03-07 16:00:57 +01:00
Achilleas Koutsou
b347c38179 test: extend systemd.unit.create stage test
Extend the manifest for the systemd.unit.create stage to create one of
each type of systemd unit currently supported.
2025-03-04 20:34:43 +01:00
Achilleas Koutsou
30d8a16e41 stages/systemd.unit.create: support .swap units
Add support for .swap systemd units.
2025-03-04 20:34:43 +01:00
Achilleas Koutsou
8b2ae24de9 stages: add .socket to systemd.unit.create test
Add .socket unit tests and replace the second .mount example with a
.socket example in the systemd.unit.create stage tests.
2025-03-04 20:34:43 +01:00
schutzbot
a287d90d8e schutzfile: Update snapshots to 20250301 2025-03-03 09:07:45 +01:00
Tomáš Hozza
8f4813e273 Test/tools/depsolve: reword function doc text
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-27 17:44:44 +01:00
Tomáš Hozza
6c9c314b48 CI: update osbuild-ci container to latest-202502250751
The main reason is that it comes with license_expression python package
needed for newly added SBOM test cases.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-27 13:31:19 +01: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
35993fe256 tools/test/depsolve/SBOM: test solver config with custom license db
Extend the depsolve SBOM test case to also cover the case when a custom
license DB file is provided.

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
99a7047173 tools/osbuild-depsolve-dnf: extend default config with loaded
Instead of completely overriding the default solver configuration with
the one loaded from a file, just extend the default config. This will
allow to specify just desired config options and keeping the defaults
for the rest.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-27 13:31:19 +01:00
Tomáš Hozza
cce8ee31c4 test/sbom/spdx: test using custom license index file
Add unit test for testing the use of custom license index file with
`SpdxLicenseExpressionFactory`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-27 13:31:19 +01:00
Tomáš Hozza
dbb7aa0051 test/sbom/spdx: move importorskip to relevant test case
Move the call to `pytest.importorskip()` function into a specific test
case that relies on imported modules. This will make test cases in the
same file to be run, even if importing the modules fail.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-27 13:31:19 +01:00
Tomáš Hozza
f24d5c843f SPEC/Fedora/-depsolve-dnf: recommend python3-license-expression
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
0174173175 test/data/spdx: add README describing each file
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
schutzbot
a6f935e939 Schutzfile: Update images dependency ref to latest 2025-02-24 13:19:36 +01:00
Michael Vogt
530ce4f80c stages: ensure dirs for dracut-conf stage are available
If the dracut config stage runs early the directory for the
dracut config may not be available yet. So just create it.
2025-02-24 13:18:33 +01:00
schutzbot
0849f4842c schutzfile: Update snapshots to 20250218 2025-02-20 16:48:52 +01:00
Tomáš Hozza
e7d9446023 tools/test/depsolve: remove checks for errors where unnecessary
Requests in some test cases are expected to always succeed. Don't check
for errors in such test cases.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01:00
Tomáš Hozza
26de07737b tools/test/depsolve: use tmp_path fixture where possible
Use the tmp_path fixture where possible, instead of
TemporaryDirectory().

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01:00
Tomáš Hozza
badd77b31e tools/test/depsolve: introduce get_test_case_repo_configs()
Move construction of repo configs to get_test_case_repo_configs().

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01:00
Tomáš Hozza
7d7e0a7296 tools/test/depsolve: factor out depsolve sbom test case
Extract testing of SBOM support into a dedicated test case. There's no
added value in running all SBOM test cases for all types of depsolve
transactions.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01:00
Tomáš Hozza
29f93af0aa tools/test/depsolve: factor out search repo combos test case
Testing all repo config combos for each search test case does not
really increase the test coverage for repo config combos. It just
increases the run time of the test.

Move the repo config combos testing to a dedicated test case, which will
test search for two packages from two different repositories.

For the original `test_search()`, always use repo configs in the
request.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01:00
Tomáš Hozza
de9f4ba3cb tools/test/depsolve: always pass dnf_config as dict
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01:00
Tomáš Hozza
b917f6a238 tools/test/depsolve: factor out depsolve repo combos test case
Testing all repo config combos for each depsolve test case does not
really increase the test coverage for repo config combos. It just
increases the run time of the test.

Move the repo config combos testing to a dedicated test case, which will
test depsolving two packages from two different repositories.

For the original `test_depsolve()`, always use repo configs in the
request.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01:00
Tomáš Hozza
52d027393c tools/test/depsolve: factor out test case repo servers filtering
Extract the code that filters and composes repo servers for a test case
into a separate function. This enables reusing it in all places that did
the same thing. The problem would get more prominent as we would
separate some test scenarios into separate test cases.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01:00
Tomáš Hozza
3743654178 tools/test/depsolve: clean up test_depsolve_result_api()
The `test_depsolve_result_api()` test case was parametrized based on
`dnf_config`, but in reality, the `depsolve()` call always used an
empty dict as `dnf_config`. Effectively, it was being tested three
times with DNF4.

In addition, don't pass optional arguments to `depsolve()`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01:00
Tomáš Hozza
e635a8a067 tools/test/depsolve: don't always pass repos, root_dir and opt_metadata
Modify the `config_combos()` to return `repo_configs` and `root_dir`
only if it should be really used. Otherwise, return `None`. Modify all
helper functions for dnf-depsolve API calls to add relevant fields to
the request JSON, only if the relevant values are set. This makes the
test cleaner, since previously, the `root_dir` was always set.

The same applies to `dnf_config`, which could be set to `None` already,
so let's make it optional.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01:00
Tomáš Hozza
a76d3e406b tools/test/depsolve: factor out func to generate repo config
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-18 10:50:19 +01: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
Dusty Mabe
a08736be49 stages/coreos.live-artifacts: use /var/tmp for mkfs.erofs
This helps reduce the memory requirements of mkfs.erofs since
it won't be writing to tmpfs (memory backed) storage, which is
what is mounted on /tmp/.
2025-02-17 20:39:38 +01:00
Michael Vogt
0c1a8c802f stages: add basic qemu cmdline test
This commit adds a basic fake commandline test for the qemu
stage.
2025-02-17 13:21:40 +01:00
Dusty Mabe
4e033c305e stages: add more options to qemu vmdk disk type
The CoreOS team uses the compat6 and adapter_type options when creating
a VMDK for AWS.

e1943d6adb/src/cosalib/qemuvariants.py (L48)
2025-02-17 03:41:11 -05:00
Sanne Raymaekers
441fbf70d6 org.osbuild.cloud-init: add new datasources and network section
Adds WSL and NoCloud datasources. The network section only allows you to
disable network configuration by cloud-init for now.
2025-02-15 10:38:12 +01:00
schutzbot
0e319018b6 Schutzfile: Update images dependency ref to latest 2025-02-14 20:17:40 +01:00
Tomáš Hozza
8fe28a2e98 GH/update-images: fix missing quote in the script
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-14 17:48:13 +01:00
Nikita Dubrovskii
035ced543b stages/coreos.live-artifacts: update comments/names to reflect erofs related changes 2025-02-13 13:40:20 +01:00
Brian C. Lane
d30cbde6f8 workflows: Switch utility workflows to using ubuntu-24.04
Pin the os version at 24.04 to avoid unexpected changes that can happen
when using ubuntu-latest
2025-02-12 22:23:32 +00:00