Skip to content

Commit 5c7a70d

Browse files
ProhibitedStableKeywordsCheck: detect prohibited stable keywords
Add an optional check to scan for packages using stable keywords prohibited by the repository. This is useful for overlays like GURU, which require that all packages use unstable keywords. Signed-off-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
1 parent 88c2e6a commit 5c7a70d

14 files changed

Lines changed: 120 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import typing
2+
3+
from pkgcore.ebuild.misc import sort_keywords
4+
from snakeoil.strings import pluralism
5+
6+
from .. import results
7+
from . import OptionalCheck
8+
9+
10+
class ProhibitedStableKeywords(results.VersionResult, results.Error):
11+
"""Package uses stable keywords prohibited by the repository."""
12+
13+
def __init__(self, arches, **kwargs):
14+
super().__init__(**kwargs)
15+
self.arches = tuple(sort_keywords(arches))
16+
17+
@property
18+
def desc(self):
19+
s = pluralism(self.arches)
20+
arches = ", ".join(self.arches)
21+
return f"prohibited stable keyword{s}: [ {arches} ]"
22+
23+
24+
class ProhibitedStableKeywordsCheck(OptionalCheck):
25+
"""Scan for packages using stable keywords prohibited by the repository."""
26+
27+
known_results: typing.ClassVar[frozenset] = frozenset({ProhibitedStableKeywords})
28+
29+
# acct-group and acct-user eclasses define KEYWORDS
30+
# See https://bugs.gentoo.org/342185
31+
ignored_categories: typing.ClassVar[frozenset] = frozenset({"acct-group", "acct-user"})
32+
33+
def feed(self, pkg):
34+
if pkg.category in self.ignored_categories:
35+
return
36+
37+
arches = {k for k in pkg.keywords if not k.startswith(("~", "-"))}
38+
if not arches:
39+
return
40+
41+
yield ProhibitedStableKeywords(arches, pkg=pkg)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{"__class__": "ProhibitedStableKeywords", "category": "ProhibitedStableKeywordsCheck", "package": "ProhibitedStableKeywords", "version": "0", "arches": ["amd64"]}
2+
{"__class__": "ProhibitedStableKeywords", "category": "ProhibitedStableKeywordsCheck", "package": "ProhibitedStableKeywords", "version": "1", "arches": ["x86"]}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git prohibited_stable/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-0.ebuild fixed/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-0.ebuild
2+
index fc606dee..52f19ba0 100644
3+
--- prohibited_stable/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-0.ebuild
4+
+++ fixed/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-0.ebuild
5+
@@ -9,4 +9,4 @@ SRC_URI="https://example.com/"
6+
7+
LICENSE="MIT"
8+
SLOT="0"
9+
-KEYWORDS="amd64"
10+
+KEYWORDS="~amd64"
11+
diff --git prohibited_stable/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-1.ebuild fixed/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-1.ebuild
12+
index e8774608..12e0329a 100644
13+
--- prohibited_stable/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-1.ebuild
14+
+++ fixed/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-1.ebuild
15+
@@ -9,4 +9,4 @@ SRC_URI="https://example.com/"
16+
17+
LICENSE="MIT"
18+
SLOT="0"
19+
-KEYWORDS="~amd64 x86"
20+
+KEYWORDS="~amd64 ~x86"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2026 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI=8
5+
6+
DESCRIPTION="ProhibitedStableKeywords"
7+
HOMEPAGE="https://example.com/"
8+
SRC_URI="https://example.com/"
9+
10+
LICENSE="MIT"
11+
SLOT="0"
12+
KEYWORDS="amd64"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2026 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI=8
5+
6+
DESCRIPTION="ProhibitedStableKeywords"
7+
HOMEPAGE="https://example.com/"
8+
SRC_URI="https://example.com/"
9+
10+
LICENSE="MIT"
11+
SLOT="0"
12+
KEYWORDS="~amd64 x86"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2026 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI=8
5+
6+
DESCRIPTION="ProhibitedStableKeywords"
7+
HOMEPAGE="https://example.com/"
8+
SRC_URI="https://example.com/"
9+
10+
LICENSE="MIT"
11+
SLOT="0"
12+
KEYWORDS="~amd64"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2026 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI=8
5+
6+
DESCRIPTION="ProhibitedStableKeywords"
7+
HOMEPAGE="https://example.com/"
8+
SRC_URI="https://example.com/"
9+
10+
LICENSE="MIT"
11+
SLOT="0"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
masters =
2+
cache-formats =
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
amd64
2+
x86
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ProhibitedStableKeywordsCheck

0 commit comments

Comments
 (0)