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)
This commit is contained in:
parent
38f5964205
commit
9552ba0fc1
1 changed files with 27 additions and 7 deletions
|
|
@ -253,9 +253,10 @@ class Solver():
|
|||
continue
|
||||
last_transaction.append(tsi.pkg)
|
||||
|
||||
dependencies = []
|
||||
packages = []
|
||||
pkg_repos = {}
|
||||
for package in last_transaction:
|
||||
dependencies.append({
|
||||
packages.append({
|
||||
"name": package.name,
|
||||
"epoch": package.epoch,
|
||||
"version": package.version,
|
||||
|
|
@ -264,13 +265,32 @@ class Solver():
|
|||
"repo_id": package.repoid,
|
||||
"path": package.relativepath,
|
||||
"remote_location": package.remote_location(),
|
||||
"checksum": (
|
||||
f"{hawkey.chksum_name(package.chksum[0])}:"
|
||||
f"{package.chksum[1].hex()}"
|
||||
)
|
||||
"checksum": f"{hawkey.chksum_name(package.chksum[0])}:{package.chksum[1].hex()}",
|
||||
})
|
||||
# collect repository objects by id to create the 'repositories' collection for the response
|
||||
pkgrepo = package.repo
|
||||
pkg_repos[pkgrepo.id] = pkgrepo
|
||||
|
||||
return dependencies
|
||||
repositories = {} # full repository configs for the response
|
||||
for repo in pkg_repos.values():
|
||||
repositories[repo.id] = {
|
||||
"id": repo.id,
|
||||
"name": repo.name,
|
||||
"baseurl": list(repo.baseurl) if repo.baseurl else None,
|
||||
"metalink": repo.metalink,
|
||||
"mirrorlist": repo.mirrorlist,
|
||||
"gpgcheck": repo.gpgcheck,
|
||||
"check_repogpg": repo.repo_gpgcheck,
|
||||
"ignoressl": not bool(repo.sslverify),
|
||||
"sslcacert": repo.sslcacert,
|
||||
"sslclientkey": repo.sslclientkey,
|
||||
"sslclientcert": repo.sslclientcert,
|
||||
}
|
||||
response = {
|
||||
"packages": packages,
|
||||
"repos": repositories,
|
||||
}
|
||||
return response
|
||||
|
||||
|
||||
def setup_cachedir(request):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue