diff --git a/src/pkgcheck/checks/profiles.py b/src/pkgcheck/checks/profiles.py index 625a05d62..a0b8c618f 100644 --- a/src/pkgcheck/checks/profiles.py +++ b/src/pkgcheck/checks/profiles.py @@ -498,6 +498,20 @@ def desc(self): 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 @@ def finish(self): 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 000000000..9e51e311a --- /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 000000000..d7c5432ea --- /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 000000000..d62663852 --- /dev/null +++ b/testdata/repos/profiledir/profiles/arches.desc @@ -0,0 +1,2 @@ +amd64 stable +x86 testing