Skip to content

Commit 35bc261

Browse files
committed
SystemSetMissingKeywords: check for missing keywords in system set packages
Happened not long ago, that sys-apps/kbd was missing stable ppc and ppc64 keywords, which caused the stage3 build to fail for 3 months. This is something we can check easily, so let's do it. This commit adds a new check to the RepoProfilesCheck class that verifies that all packages in the system set have matching keywords to the arches' profiles system set. Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 13e1d6c commit 35bc261

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

src/pkgcheck/checks/profiles.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,20 @@ def desc(self):
552552
return f"'profiles/arches.desc' is out of sync with 'arch.list', arch{es}: {arches}"
553553

554554

555+
class SystemSetMissingKeywords(results.PackageResult, results.Error):
556+
"""System set is missing keywords for some arches."""
557+
558+
def __init__(self, missing_arches, **kwargs):
559+
super().__init__(**kwargs)
560+
self.missing_arches = tuple(missing_arches)
561+
562+
@property
563+
def desc(self):
564+
arches = ", ".join(self.missing_arches)
565+
s = pluralism(self.missing_arches, plural="es")
566+
return f"part of @system set, but is missing keywords for arch{s}: {arches}"
567+
568+
555569
def dir_parents(path):
556570
"""Yield all directory path parents excluding the root directory.
557571
@@ -588,6 +602,7 @@ class RepoProfilesCheck(RepoCheck):
588602
BannedProfileEapi,
589603
DeprecatedProfileEapi,
590604
ArchesOutOfSync,
605+
SystemSetMissingKeywords,
591606
}
592607
)
593608

@@ -602,6 +617,25 @@ def __init__(self, *args, profile_addon):
602617
self.repo = self.options.target_repo
603618
self.profiles_dir = self.repo.config.profiles_base
604619
self.non_profile_dirs = profile_addon.non_profile_dirs
620+
self.arch_profiles = profile_addon.arch_profiles
621+
622+
def _check_system_set(self):
623+
system_packages: dict[atom_cls, set[str]] = defaultdict(set)
624+
stable_arches = self.options.target_repo.config.arches_desc["stable"]
625+
for arch, profiles in self.arch_profiles.items():
626+
is_stable = arch in stable_arches
627+
if not is_stable:
628+
arch = "~" + arch
629+
for profile, _ in profiles:
630+
for pkg in profile.system:
631+
system_packages[pkg].add(arch)
632+
for pkg in profile.profile_set:
633+
system_packages[pkg].add(arch)
634+
for atom, required_arches in system_packages.items():
635+
if pkgs := self.repo.match(atom):
636+
keywords = frozenset().union(*(pkg.keywords for pkg in pkgs))
637+
if missing_arches := required_arches - keywords:
638+
yield SystemSetMissingKeywords(sorted(missing_arches), pkg=atom)
605639

606640
def finish(self):
607641
if unknown_category_dirs := set(self.repo.category_dirs).difference(
@@ -674,3 +708,5 @@ def finish(self):
674708
if arches_desc := frozenset().union(*self.repo.config.arches_desc.values()):
675709
if arches_mis_sync := self.repo.known_arches ^ arches_desc:
676710
yield ArchesOutOfSync(sorted(arches_mis_sync))
711+
712+
yield from self._check_system_set()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"__class__": "SystemSetMissingKeywords", "category": "cat", "package": "pkg1", "missing_arches": ["amd64"]}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
diff -Naur profiledir/cat/pkg1/pkg1-0.ebuild fixed/cat/pkg1/pkg1-0.ebuild
2+
--- profiledir/cat/pkg1/pkg1-0.ebuild
3+
+++ fixed/cat/pkg1/pkg1-0.ebuild
4+
@@ -3,3 +3,4 @@ HOMEPAGE="https://github.com/pkgcore/pkgcheck"
5+
LICENSE="BSD"
6+
SLOT="0"
7+
IUSE="used"
8+
+KEYWORDS="amd64"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*cat/pkg1

0 commit comments

Comments
 (0)