commit: 72ec9a3d5ee68be6158566ce51ef3ab62ae23832 Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> AuthorDate: Thu Jan 19 21:48:07 2023 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Fri Jan 20 06:46:02 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=72ec9a3d
ArchesMisSync: check for arch.list <-> arches.desc missync Resolves: https://github.com/pkgcore/pkgcheck/issues/526 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgcheck/checks/profiles.py | 19 +++++++++++++++++++ .../RepoProfilesCheck/ArchesOutOfSync/expected.json | 1 + .../RepoProfilesCheck/ArchesOutOfSync/fix.sh | 2 ++ testdata/repos/profiledir/profiles/arches.desc | 2 ++ 4 files changed, 24 insertions(+) diff --git a/src/pkgcheck/checks/profiles.py b/src/pkgcheck/checks/profiles.py index 625a05d6..a0b8c618 100644 --- a/src/pkgcheck/checks/profiles.py +++ b/src/pkgcheck/checks/profiles.py @@ -498,6 +498,20 @@ class NonexistentCategories(results.ProfilesResult, results.Warning): return f"nonexistent profiles/categories entr{ies}: {categories}" +class ArchesOutOfSync(results.ProfilesResult, results.Error): + """``profiles/arches.desc`` is out of sync with ``arch.list``.""" + + def __init__(self, arches): + super().__init__() + self.arches = tuple(arches) + + @property + def desc(self): + es = pluralism(self.arches, plural="es") + arches = ", ".join(self.arches) + return f"'profiles/arches.desc' is out of sync with 'arch.list', arch{es}: {arches}" + + def dir_parents(path): """Yield all directory path parents excluding the root directory. @@ -533,6 +547,7 @@ class RepoProfilesCheck(RepoCheck): ProfileWarning, BannedProfileEapi, DeprecatedProfileEapi, + ArchesOutOfSync, ] ) @@ -614,3 +629,7 @@ class RepoProfilesCheck(RepoCheck): if unused_profile_dirs := available_profile_dirs - seen_profile_dirs: yield UnusedProfileDirs(sorted(unused_profile_dirs)) + + if arches_desc := frozenset().union(*self.repo.config.arches_desc.values()): + if arches_mis_sync := self.repo.known_arches ^ arches_desc: + yield ArchesOutOfSync(sorted(arches_mis_sync)) diff --git a/testdata/data/repos/profiledir/RepoProfilesCheck/ArchesOutOfSync/expected.json b/testdata/data/repos/profiledir/RepoProfilesCheck/ArchesOutOfSync/expected.json new file mode 100644 index 00000000..9e51e311 --- /dev/null +++ b/testdata/data/repos/profiledir/RepoProfilesCheck/ArchesOutOfSync/expected.json @@ -0,0 +1 @@ +{"__class__": "ArchesOutOfSync", "arches": ["unknown_arch"]} diff --git a/testdata/data/repos/profiledir/RepoProfilesCheck/ArchesOutOfSync/fix.sh b/testdata/data/repos/profiledir/RepoProfilesCheck/ArchesOutOfSync/fix.sh new file mode 100755 index 00000000..d7c5432e --- /dev/null +++ b/testdata/data/repos/profiledir/RepoProfilesCheck/ArchesOutOfSync/fix.sh @@ -0,0 +1,2 @@ +#!/bin/bash +sed -i '/^unknown_arch/d' profiles/arch.list diff --git a/testdata/repos/profiledir/profiles/arches.desc b/testdata/repos/profiledir/profiles/arches.desc new file mode 100644 index 00000000..d6266385 --- /dev/null +++ b/testdata/repos/profiledir/profiles/arches.desc @@ -0,0 +1,2 @@ +amd64 stable +x86 testing