From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: testdata/repos/standalone/metadata/, ...
Date: Fri, 14 Jul 2023 06:01:55 +0000 (UTC) [thread overview]
Message-ID: <1689313721.a4fdd4b970e2bb0c87a019c2ffc514d5428b726d.arthurzam@gentoo> (raw)
commit: a4fdd4b970e2bb0c87a019c2ffc514d5428b726d
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 7 13:26:22 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jul 14 05:48:41 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=a4fdd4b9
RepoManifestHashCheck: check for deprecated repo manifest-hashes
Resolves: https://github.com/pkgcore/pkgcheck/issues/508
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/checks/repo_metadata.py | 49 ++++++++++++++++++----
.../DeprecatedRepoHash/expected.json | 1 +
testdata/repos/standalone/metadata/layout.conf | 1 +
3 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/src/pkgcheck/checks/repo_metadata.py b/src/pkgcheck/checks/repo_metadata.py
index 21df0745..2f28f805 100644
--- a/src/pkgcheck/checks/repo_metadata.py
+++ b/src/pkgcheck/checks/repo_metadata.py
@@ -12,6 +12,9 @@ from .. import addons, base, results, sources
from . import Check, MirrorsCheck, RepoCheck
+DEPRECATED_HASHES = frozenset({"md5", "rmd160", "sha1", "whirlpool"})
+
+
class MultiMovePackageUpdate(results.ProfilesResult, results.Warning):
"""Entry for package moved multiple times in profiles/updates files."""
@@ -174,7 +177,7 @@ class UnusedLicensesCheck(RepoCheck):
"""Check for unused license files."""
_source = sources.RepositoryRepoSource
- known_results = frozenset([UnusedLicenses])
+ known_results = frozenset({UnusedLicenses})
def __init__(self, *args):
super().__init__(*args)
@@ -213,7 +216,7 @@ class UnusedMirrorsCheck(MirrorsCheck, RepoCheck):
"""Check for unused mirrors."""
_source = sources.RepositoryRepoSource
- known_results = frozenset([UnusedMirrors])
+ known_results = frozenset({UnusedMirrors})
def start(self):
master_mirrors = set()
@@ -249,7 +252,7 @@ class UnusedEclassesCheck(RepoCheck):
"""Check for unused eclasses."""
_source = sources.RepositoryRepoSource
- known_results = frozenset([UnusedEclasses])
+ known_results = frozenset({UnusedEclasses})
def __init__(self, *args):
super().__init__(*args)
@@ -291,7 +294,7 @@ class LicenseGroupsCheck(RepoCheck):
"""Scan license groups for unknown licenses."""
_source = (sources.EmptySource, (base.repo_scope,))
- known_results = frozenset([UnknownLicenses])
+ known_results = frozenset({UnknownLicenses})
def __init__(self, *args):
super().__init__(*args)
@@ -682,7 +685,7 @@ class ManifestCollisionCheck(Check):
"""
_source = (sources.RepositoryRepoSource, (), (("source", sources.PackageRepoSource),))
- known_results = frozenset([ConflictingChksums, MatchingChksums])
+ known_results = frozenset({ConflictingChksums, MatchingChksums})
def __init__(self, *args):
super().__init__(*args)
@@ -746,13 +749,45 @@ class ProjectMetadataCheck(RepoCheck):
"""Check projects.xml for issues."""
_source = (sources.EmptySource, (base.repo_scope,))
- known_results = frozenset([EmptyProject])
+ known_results = frozenset({EmptyProject})
def __init__(self, *args):
super().__init__(*args)
self.repo = self.options.target_repo
def finish(self):
- for _key, project in self.repo.projects_xml.projects.items():
+ for project in self.repo.projects_xml.projects.values():
if not project.recursive_members:
yield EmptyProject(project)
+
+
+class DeprecatedRepoHash(results.Warning):
+ """Repositories ``manifest-hashes`` defines deprecated hashes.
+
+ The repository defines deprecated hashes in ``manifest-hashes``.
+ """
+
+ def __init__(self, hashes):
+ super().__init__()
+ self.hashes = tuple(hashes)
+
+ @property
+ def desc(self):
+ s = pluralism(self.hashes)
+ hashes = ", ".join(self.hashes)
+ return f"defines deprecated manifest-hash{s}: [ {hashes} ]"
+
+
+class RepoManifestHashCheck(RepoCheck):
+ """Check ``manifest-hashes`` config for issues."""
+
+ _source = (sources.EmptySource, (base.repo_scope,))
+ known_results = frozenset({DeprecatedRepoHash})
+
+ def __init__(self, *args):
+ super().__init__(*args)
+ self.repo = self.options.target_repo
+
+ def finish(self):
+ if deprecated_hashes := DEPRECATED_HASHES.intersection(self.repo.config.manifests.hashes):
+ yield DeprecatedRepoHash(sorted(deprecated_hashes))
diff --git a/testdata/data/repos/standalone/RepoManifestHashCheck/DeprecatedRepoHash/expected.json b/testdata/data/repos/standalone/RepoManifestHashCheck/DeprecatedRepoHash/expected.json
new file mode 100644
index 00000000..4d753b93
--- /dev/null
+++ b/testdata/data/repos/standalone/RepoManifestHashCheck/DeprecatedRepoHash/expected.json
@@ -0,0 +1 @@
+{"__class__": "DeprecatedRepoHash", "hashes": ["sha1", "whirlpool"]}
diff --git a/testdata/repos/standalone/metadata/layout.conf b/testdata/repos/standalone/metadata/layout.conf
index 46e02cb8..5add29b7 100644
--- a/testdata/repos/standalone/metadata/layout.conf
+++ b/testdata/repos/standalone/metadata/layout.conf
@@ -5,3 +5,4 @@ eapis-banned = 1
eapis-deprecated = 5
properties-allowed = interactive live
restrict-allowed = bindist fetch mirror test
+manifest-hashes = BLAKE2B SHA1 SHA512 WHIRLPOOL
reply other threads:[~2023-07-14 6:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1689313721.a4fdd4b970e2bb0c87a019c2ffc514d5428b726d.arthurzam@gentoo \
--to=arthurzam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox