Commit graph

3408 commits

Author SHA1 Message Date
Simon de Vlieger
b616da69f3 test/depsolve: fix package sets, add module test
With the enabling of AppStream some more (perhaps optional) packages are
included.

This also adds a test case which installs a module and verifies that
that module is returned.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-01-22 18:03:21 +01:00
Simon de Vlieger
1e70131346 data: include appstream repository metadata
The CentOS Stream 9 repository metadata contains modules; these are
necessary for testing modularity depsolving.

Note that the filelists metadata is kept empty to keep repository size
down.

Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
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
Tomáš Hozza
bf3dff6842 Gitlab CI: use F41 for OSTree tests
Let's not use EOL F39 for OSTree tests and move to the latest supported
Fedora version.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-01-20 17:19:14 +01:00
Albert Esteve
55d53f58fd stages/mkfs.ext4: disable lazy_init
This helps to clear a risk concern for
automotive.

Add optional flag to org.osbuild.mkfs.ext4 stage
to enable/disable both lazy_itable_init and
lazy_journal_init extended options. Both mke2fs
options are controled by the same flag, namely
`lazy_init`.

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2025-01-17 19:11:38 +01:00
Florian Schüller
be9876f562 README: remove mailing list
The mailing list was sunset by the IT department and
was rarely used, so we'll replace with matrix & discussions.
2025-01-17 14:11:16 +01:00
Achilleas Koutsou
16d0b2188e gitlab: run test in CI 2025-01-17 10:10:47 +01:00
Achilleas Koutsou
e99dabe467 test: generate container-dev-null test manifests
Generate the manifests from the mpp yaml files.
2025-01-17 10:10:47 +01:00
Achilleas Koutsou
278b9130b0 test: (mpp) manifests for container embed
Add mpp files to create manifests that will embed the container (that
contains /dev/null) in an OS tree and compose an ostree commit from it.

This used to cause the rpm-ostree compose command to fail with:

    error: Writing commit: While writing rootfs to mtree: Not a regular file or symlink: null
2025-01-17 10:10:47 +01:00
Achilleas Koutsou
e2b9d0f3ca test: update rpmrepo snapshots
Required for latest version of rpm-ostree.
2025-01-17 10:10:47 +01:00
Achilleas Koutsou
6b45c81a29 test: create a container with /dev/null
Create a container using the new script and add it to the repo for use
in testing.
2025-01-17 10:10:47 +01:00
Achilleas Koutsou
0507a9807c test: container creation script with /dev/null
Add a script that creates a container image as an oci-archive that
contains /dev/null.
2025-01-17 10:10:47 +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
Michael Vogt
65a7ce2461 sources: relax "mirror" regexp to follow upstream repo ID
This commit relaxes the "mirror" schema regex from only allow
hashes to the repo ID regex as described in
https://dnf.readthedocs.io/en/latest/conf_ref.html#description

This is needed because in e.g. bootc-image-builder we use
"SetRootDir()" to get the repository information from an existing
bootc image and there the repo_id (that is then used as the mirror_id)
is written in a human friendly way instead of hex.

Thanks to Tomáš Hozza for the suggestions and background info, see
https://github.com/osbuild/osbuild/pull/1974#issuecomment-2579325272
2025-01-14 08:19:16 +01:00
Michael Vogt
b2a34d8b33 sources: add org.osbuild.mtls secret support to librepo source
This commit adds support for the `org.osbuild.mtls` sources and
adds a test.

Note that it reuses the `OSBUILD_SOURCES_CURL_` - this may or
may not be desired, it is certainly simpler this way and librepo
is using libcurl as well internally but it feels a bit messy so
maybe we want to rename the env?
2025-01-14 08:19:16 +01:00
Michael Vogt
a90ad5c432 sources: add simple status printing like curl to librepo 2025-01-14 08:19:16 +01:00
Michael Vogt
b97274dd2f sources: skip librepo test if no librepo can be imported
The librepo test has a similar issue as the dnf tests, we need
to use the system packages, c.f.
https://github.com/osbuild/containers/pull/79
2025-01-14 08:19:16 +01:00
Michael Vogt
460d743b99 sources: test schema validation for librepo
This commit adds a test for the librepo schema validation.
2025-01-14 08:19:16 +01:00
Michael Vogt
3cd587e5e6 sources: add sources_schema() helper
This helper fixture will give access to the schema of the sources.
With that we can easily test if the validations work as expected.
2025-01-14 08:19:16 +01:00
Michael Vogt
2ba797a18c sources: tweak fetch_all and fix pylint error
This commit fixes the pylint errors and as a drive-by tweaks some naming
in `fetch_all()`. Maybe they became a bit verbose along the way,
idk.

Thanks also to Tomáš Hozza for the dict.setdefault() suggestion.
2025-01-14 08:19:16 +01:00
Michael Vogt
a0b4445f3b sources: add unit tests for org.osbuild.librepo
This commit adds unit a basic test for librepo and also updates
the code to the latest requirements to provide "fetch_all".

It also fixes a bug in the handling of org.osbuild.rhsm secrets.
2025-01-14 08:19:16 +01:00
Michael Vogt
a36fca4b34 test: reformat json data to appease linter
This commit just ran:
```
  find -iname "*.json" -print -exec sh -c 'jq --indent 2 . {} | sponge {}' \;
```
to ensure that the new test json data from librepo is in the format
the linter expects.
2025-01-14 08:19:16 +01:00
Brian C. Lane
e4ae9ec018 test: Skip check_moduleinfo for unsupported versions
Most modules do not support both schema versions. This is masked by
module type code in get_schema() in most cases, but really should not be
tested. This skips running check_moduleinfo if the module doesn't
support the version. eg. org.osbuild.librepo only supports v2.
2025-01-14 08:19:16 +01:00
Brian C. Lane
0eb842e80c test: Validate the source test manifests
This helps prevent testing against invalid manifest data. It runs on the
source's manifest data, using the highest schema version parsed for the
source.
2025-01-14 08:19:16 +01:00
Brian C. Lane
e2345a6348 test: Add baseurl test for org.osbuild.librepo
These test:

* baseurl success
* baseurl with a bad checksum (or file) which is expected to fail
2025-01-14 08:19:16 +01:00
Brian C. Lane
6045b3ffd6 test: Add mirrorlist test for org.osbuild.librepo
These tests test downloading packages using mirrorlist:

* Using a single mirrorlist repo
* Using two mirrorlist repos
* A bad checksum (or file) from the download which is expected to fail
* Two mirrorlist paths with the first one returning a 404, expected to
  succeed with the 2nd mirrorlist path.
2025-01-14 08:19:16 +01:00
Brian C. Lane
0c340da0a2 test: Add metalink test for org.osbuild.librepo
NOTE: The metalink xml file points to a repomd.xml file which does not
exist. In practice librepo doesn't download this, it only uses the url
to construct the mirror urls, so it is not present.

These tests test downloading packages using metalink:

* Using a single metalink repo
* Using two metalink repos
* A bad checksum (or file) from the download which is expected to fail
* Two metalink paths with the first one returning a 404, expected to
  succeed with the 2nd metalink path.
2025-01-14 08:19:16 +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
Michael Vogt
1eb8138ab5 test: tweak test_grub2_inst.py to support running on Debian/Ubuntu
This commit adds support to run the tests on Debian/Ubuntu systems.
Here the binary is called `grub-mkimage` instead of `grub2-mkimage`,
in addition the "grub-pc-bin" package must be installed there.
2025-01-13 22:53:02 +01:00
Brian C. Lane
3bed7c7ace grub2.inst: Add support for creating iso9660 boot image
Don't include the "location" offset, and use just a path for the prefix
section to set the path of the grub2 modules on the iso. eg.

{
    "filename": "eltorito.img",
    "platform": "i386-pc",
    "core": {
        "type": "mkimage",
        "partlabel": "gpt",
        "filesystem": "iso9660"
    },
    "prefix": {
        "path": "/boot/grub2/"
    }
}
2025-01-13 22:53:02 +01:00
Brian C. Lane
41c0550a1f tests: Add simple test for org.osuild.grub2.inst stage
Tests that grub2-mkimage ran without errors, and that the image file
actually has something written to it.
2025-01-13 22:53:02 +01:00
Achilleas Koutsou
67f344fa52 tools/osbuild-image-info: append mountpoint to mount ID
The mount ID must be unique.  So far, we were using the device as the ID
for the mount because that was unique to each mount.  With btrfs
subvolumes however, the device and partition are the same for all, so we
need another way to differentiate.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
30d1faabdd tools/osbuild-image-info: move fstab search to function 2025-01-10 17:18:05 +01:00
Achilleas Koutsou
e513820518 tools/osbuild-image-info: handle root on subvol
Btrfs volumes typically only contain subvolumes instead of (parts of)
the OS tree directly.  In our images in particular, this is always the
case.  When searching for root to find /etc/fstab, search through the
subvolumes on a btrfs volume for the file and return the path to the
root subvolume.

Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
a16582b8c7 tools/osbuild-image-info: Mount() with partition=None
Always set partition=None for the kwargs of the Mount() constructor.

The previous code was added for backwards compatibility with older
versions of the Mount() constructor that didn't include the 'partition
argument.  It's safe to remove now because:
1. It's been long enough that we wont run osbuild-image-info with an old
   version of osbuild.
2. The tool is packaged with osbuild so there is no version drift and no
   compatibility issues.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
10029167db tools/osbuild-image-info: fail early if fstab isn't found
When the fstab file isn't found, the root_tree will never be set after
being initialised to "" and an exception is raised "The root filesystem
tree is not mounted".  It's a lot clearer if the failure happens closer
to the root cause, which is that fstab wasn't found and there are no
fstab entries to iterate through and find the root filesystem.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
dc047513b7 tools/osbuild-image-info: skip swap partitions
When iterating partitions to mount, skip any with filesystem type
"swap".  This is done in two places:
1. When mounting partitions to find /etc/fstab.
2. When mounting partitions and volumes to analyse the tree.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
b9e84587ad tools/osbuild-image-info: store fstype when iterating parts
When iterating through partitions, store the fstype along with the other
information.  This will be useful for identifying btrfs partitions,
which we will need to scan for subvolumes, and for identifying swap
partitions, so we can avoid trying to mount them.
2025-01-10 17:18:05 +01:00
Achilleas Koutsou
fc4232af63 tools/osbuild-image-info: print fstype in error
Print the unrecognised fstype string when failing.
2025-01-10 17:18:05 +01:00