Commit graph

9 commits

Author SHA1 Message Date
Achilleas Koutsou
9552ba0fc1 tools/osbuild-depsolve-dnf: return repositories in response
When generating package sources and rpm stage metadata for a manifest
from a list of packages, we need to associate repository configuration
options to each package [1].  Previously, a caller had all the
repository configurations because they were part of the request, so
packages could be associated with all the repository options by the
repository ID.  Now, osbuild-depsolve-dnf will use repositories loaded
from a directory that the caller shouldn't have to read, so returning
all repository configurations in the response makes it possible to
get all package metadata from the response.

This changes the whole structure of the response to a depsolve request.
Previously, we returned an array of packages.  Now we return an object
with two keys:
- packages: the array of packages as before
- repositories: an object mapping repository IDs to repository
  configurations.

Each package contains the repository ID it comes from (as before), under
`repo_id`.  This can be used to get repository configurations and
determine gpg keys and SSL certs for each package.

The new structure avoids duplicating values across all the (sometimes
hundreds) of packages.

[1] 92497c7b1f/pkg/dnfjson/dnfjson.go (L499-L507)
2024-04-10 16:22:13 -07:00
Achilleas Koutsou
38f5964205 tools/osbuild-depsolve-dnf: load repos from dir
Support loading repositories from a root tree instead of supplying them
with the request.  The repositories should be in the standard yum repo
format.  Both repository sources can be defined simultaneously, but at
least one is required.

The root_dir is expected to contain files necessary for depsolving in
the standard paths.

These files are:
- Repository (.repo) configurations in <root_dir>/etc/yum.repos.d/
- GPG key files in <root_dir>/etc/pki/rpm-gpg/
    - This will be used to resolve gpg key paths specified in the .repo
      files that are relative to the root_dir.
- (Optional) Custom dnf config variables in <root_dir>/etc/dnf/vars or
  <root_dir>/etc/yum/vars.
    - This is used by CentOS Stream to set the value of $stream.

Custom repository configurations in arbitrary (non-root) paths will have
to follow this directory structure.

A new variable is added to the request, `releasever`, which is mandatory
when using `root_dir`.  This variable is used in repository URLs and GPG
key paths.  In the default case, dnf reads this variable by inspecting
the rpm database.  We will override it in the Solver the same way we
override the arch and basearch for variable substitution.  In the
future, we will make this variable mandatory in all cases, which will
make the variable available for repo configs defined in the request as
well.

The root_dir is used in two ways:
- Set the base.conf.reposdir to <root_dir>/etc/yum.repos.d.
- Call update_from_etc() with root_dir to read custom variables in
  <root_dir>/etc/yum/vars and <root_dir>/etc/dnf/vars.
2024-04-10 16:22:13 -07:00
Achilleas Koutsou
06c8aca871 tools/osbuild-depsolve-dnf: type annotation
Silence the mypy linter.
2024-04-10 16:22:13 -07:00
Brian C. Lane
291f5cc29e Revert "osbuild-depsolve-dnf: port weak dependencies"
This reverts commit e023fdec1b.

Ends up this was based on an older version of dnf-json, the correct
behavior is to use the "install_weak_deps" bool.
2024-02-13 00:17:16 +01:00
Diaa Sami
e023fdec1b osbuild-depsolve-dnf: port weak dependencies
ported from d48da99a12
2024-02-08 00:12:32 +01:00
Diaa Sami
c673eab2b5 osbuild-depsolve-dnf: port module_hotfixes support over
from 61e6f75281
2024-02-08 00:03:59 +01:00
Simon de Vlieger
1542813296 depsolve-dnf: helpful exception for repo 2023-10-26 15:53:47 +02:00
Simon de Vlieger
f371651d66 depsolve-dnf: enable weak deps selection
The import of `dnf-json` came from `osbuild-composer`, as we sadly
have/had multiple copies this wasn't the *right* version as it was
lacking previous work to disable weak dependencies.
2023-10-26 15:11:24 +02:00
Simon de Vlieger
7c35b945ee depsolve: import dnf-json
Import the `dnf-json` Python script that is included in the "images" and
"osbuild-composer" repository into "osbuild".

`dnf-json` provides dependency solving capabilities by taking in some
JSON and then outputting the package set that JSON resolves to. Since it
is a Python script it moves into a subpackage of `osbuild`.

The script is renamed to `osbuild-depsolve-dnf`.
2023-10-16 20:47:17 +02:00