Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/pkgcheck/checks/prohibited_stable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import typing

from pkgcore.ebuild.misc import sort_keywords
from snakeoil.strings import pluralism

from .. import results
from . import OptionalCheck


class ProhibitedStableKeywords(results.VersionResult, results.Error):
"""Package uses stable keywords prohibited by the repository."""

def __init__(self, arches, **kwargs):
super().__init__(**kwargs)
self.arches = tuple(sort_keywords(arches))

@property
def desc(self):
s = pluralism(self.arches)
arches = ", ".join(self.arches)
return f"prohibited stable keyword{s}: [ {arches} ]"


class ProhibitedStableKeywordsCheck(OptionalCheck):
"""Scan for packages using stable keywords prohibited by the repository."""

known_results: typing.ClassVar[frozenset] = frozenset({ProhibitedStableKeywords})

# acct-group and acct-user eclasses define KEYWORDS
# See https://bugs.gentoo.org/342185
ignored_categories: typing.ClassVar[frozenset] = frozenset({"acct-group", "acct-user"})

def feed(self, pkg):
if pkg.category in self.ignored_categories:
return

arches = {k for k in pkg.keywords if not k.startswith(("~", "-"))}
if not arches:
return

yield ProhibitedStableKeywords(arches, pkg=pkg)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"__class__": "ProhibitedStableKeywords", "category": "ProhibitedStableKeywordsCheck", "package": "ProhibitedStableKeywords", "version": "0", "arches": ["amd64"]}
{"__class__": "ProhibitedStableKeywords", "category": "ProhibitedStableKeywordsCheck", "package": "ProhibitedStableKeywords", "version": "1", "arches": ["x86"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git prohibited_stable/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-0.ebuild fixed/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-0.ebuild
index fc606dee..52f19ba0 100644
--- prohibited_stable/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-0.ebuild
+++ fixed/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-0.ebuild
@@ -9,4 +9,4 @@ SRC_URI="https://example.com/"

LICENSE="MIT"
SLOT="0"
-KEYWORDS="amd64"
+KEYWORDS="~amd64"
diff --git prohibited_stable/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-1.ebuild fixed/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-1.ebuild
index e8774608..12e0329a 100644
--- prohibited_stable/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-1.ebuild
+++ fixed/ProhibitedStableKeywordsCheck/ProhibitedStableKeywords/ProhibitedStableKeywords-1.ebuild
@@ -9,4 +9,4 @@ SRC_URI="https://example.com/"

LICENSE="MIT"
SLOT="0"
-KEYWORDS="~amd64 x86"
+KEYWORDS="~amd64 ~x86"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="ProhibitedStableKeywords"
HOMEPAGE="https://example.com/"
SRC_URI="https://example.com/"

LICENSE="MIT"
SLOT="0"
KEYWORDS="amd64"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="ProhibitedStableKeywords"
HOMEPAGE="https://example.com/"
SRC_URI="https://example.com/"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 x86"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="ProhibitedStableKeywords"
HOMEPAGE="https://example.com/"
SRC_URI="https://example.com/"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="ProhibitedStableKeywords"
HOMEPAGE="https://example.com/"
SRC_URI="https://example.com/"

LICENSE="MIT"
SLOT="0"
2 changes: 2 additions & 0 deletions testdata/repos/prohibited_stable/metadata/layout.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
masters =
cache-formats =
2 changes: 2 additions & 0 deletions testdata/repos/prohibited_stable/profiles/arch.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
amd64
x86
1 change: 1 addition & 0 deletions testdata/repos/prohibited_stable/profiles/categories
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ProhibitedStableKeywordsCheck
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ARCH="amd64"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ARCH="x86"
2 changes: 2 additions & 0 deletions testdata/repos/prohibited_stable/profiles/profiles.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
amd64 default/amd64 stable
x86 default/x86 stable
1 change: 1 addition & 0 deletions testdata/repos/prohibited_stable/profiles/repo_name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prohibited_stable
Loading