dnfjson: drop repo checksums

The repository checksums in the response from dnf-json aren't used
anywhere.  Since we're making changes to dnf-json and depsolving, now is
a good opportunity to drop them completely.
This commit is contained in:
Achilleas Koutsou 2022-05-23 19:06:24 +02:00 committed by Tom Gundersen
parent 0ef4e7ee84
commit 7a70a5e69b
13 changed files with 182 additions and 290 deletions

View file

@ -7,9 +7,6 @@ A JSON-based interface for depsolving using DNF.
Reads a request through stdin and prints the result to stdout.
In case of error, a structured error is printed to stdout as well.
"""
import hashlib
import json
import os
import sys
@ -97,30 +94,6 @@ class Solver():
return repo
def _repo_checksums(self):
checksums = {}
for repo in self.base.repos.iter_enabled():
# Uses the same algorithm as libdnf to find cache dir:
# https://github.com/rpm-software-management/libdnf/blob/master/libdnf/repo/Repo.cpp#L1288
if repo.metalink:
url = repo.metalink
elif repo.mirrorlist:
url = repo.mirrorlist
elif repo.baseurl:
url = repo.baseurl[0]
else:
assert False
digest = hashlib.sha256(url.encode()).hexdigest()[:16]
repomd_file = f"{repo.id}-{digest}/repodata/repomd.xml"
with open(f"{self.base.conf.cachedir}/{repomd_file}", "rb") as f:
repomd = f.read()
checksums[repo.id] = "sha256:" + hashlib.sha256(repomd).hexdigest()
return checksums
@staticmethod
def _timestamp_to_rfc3339(timestamp):
return datetime.utcfromtimestamp(timestamp).strftime('%Y-%m-%dT%H:%M:%SZ')
@ -141,10 +114,7 @@ class Solver():
"buildtime": self._timestamp_to_rfc3339(package.buildtime),
"license": package.license
})
return {
"checksums": self._repo_checksums(),
"packages": packages
}
return packages
def depsolve(self, transactions):
last_transaction = []
@ -195,10 +165,7 @@ class Solver():
)
})
return {
"checksums": self._repo_checksums(),
"dependencies": dependencies
}
return dependencies
def setup_cachedir(request):