-
Notifications
You must be signed in to change notification settings - Fork 31
StableKeywordsCheck: detect packages using stable keywords #769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
falbrechtskirchinger
wants to merge
2
commits into
pkgcore:master
Choose a base branch
from
falbrechtskirchinger:stablekeywords
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| from collections import defaultdict | ||
|
|
||
| from pkgcore.ebuild.misc import sort_keywords | ||
| from pkgcore.restrictions import packages, values | ||
| from snakeoil.strings import pluralism | ||
|
|
||
| from .. import addons, results, sources | ||
| from . import OptionalCheck | ||
|
|
||
|
|
||
| class DisallowedStableKeywords(results.VersionResult, results.Error): | ||
| """Package uses stable keywords, which are disallowed in this 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"disallowed stable keyword{s}: [ {arches} ]" | ||
|
|
||
|
|
||
| class DisallowedStableKeywordsCheck(OptionalCheck): | ||
| """Scan for packages using stable keywords in repositories where they are not allowed.""" | ||
|
|
||
| required_addons = (addons.StableArchesAddon,) | ||
| known_results = frozenset({DisallowedStableKeywords}) | ||
|
|
||
| # acct-group and acct-user eclasses define KEYWORDS | ||
| # See https://bugs.gentoo.org/342185 | ||
| ignored_categories = frozenset({"acct-group", "acct-user"}) | ||
|
|
||
| def __init__(self, *args, stable_arches_addon=None): | ||
| super().__init__(*args) | ||
| self.arches = frozenset({x.strip().lstrip("~") for x in self.options.stable_arches}) | ||
|
|
||
| self.arch_restricts = { | ||
| arch: packages.PackageRestriction("keywords", values.ContainmentMatch2((arch,))) | ||
| for arch in self.arches | ||
| } | ||
|
|
||
| def feed(self, pkg): | ||
| if pkg.category in self.ignored_categories: | ||
| return | ||
|
|
||
| arches = frozenset({arch for arch, r in self.arch_restricts.items() if r.match(pkg)}) | ||
| if not arches: | ||
| return | ||
|
|
||
| yield DisallowedStableKeywords(arches, pkg=pkg) | ||
2 changes: 2 additions & 0 deletions
2
testdata/data/repos/stable_keywords/StableKeywordsCheck/StableKeywords/expected.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| {"__class__": "StableKeywords", "category": "StableKeywordsCheck", "package": "StableKeywords", "versions": ["0"], "arches": ["amd64"]} | ||
| {"__class__": "StableKeywords", "category": "StableKeywordsCheck", "package": "StableKeywords", "versions": ["1"], "arches": ["x86"]} |
20 changes: 20 additions & 0 deletions
20
testdata/data/repos/stable_keywords/StableKeywordsCheck/StableKeywords/fix.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| diff --git stable_keywords/StableKeywordsCheck/StableKeywords/StableKeywords-0.ebuild fixed/StableKeywordsCheck/StableKeywords/StableKeywords-0.ebuild | ||
| index fc606dee..52f19ba0 100644 | ||
| --- stable_keywords/StableKeywordsCheck/StableKeywords/StableKeywords-0.ebuild | ||
| +++ fixed/StableKeywordsCheck/StableKeywords/StableKeywords-0.ebuild | ||
| @@ -9,4 +9,4 @@ SRC_URI="https://example.com/" | ||
|
|
||
| LICENSE="MIT" | ||
| SLOT="0" | ||
| -KEYWORDS="amd64" | ||
| +KEYWORDS="~amd64" | ||
| diff --git stable_keywords/StableKeywordsCheck/StableKeywords/StableKeywords-1.ebuild fixed/StableKeywordsCheck/StableKeywords/StableKeywords-1.ebuild | ||
| index e8774608..12e0329a 100644 | ||
| --- stable_keywords/StableKeywordsCheck/StableKeywords/StableKeywords-1.ebuild | ||
| +++ fixed/StableKeywordsCheck/StableKeywords/StableKeywords-1.ebuild | ||
| @@ -9,4 +9,4 @@ SRC_URI="https://example.com/" | ||
|
|
||
| LICENSE="MIT" | ||
| SLOT="0" | ||
| -KEYWORDS="~amd64 x86" | ||
| +KEYWORDS="~amd64 ~x86" |
12 changes: 12 additions & 0 deletions
12
testdata/repos/stable_keywords/StableKeywordsCheck/StableKeywords/StableKeywords-0.ebuild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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="StableKeywords" | ||
| HOMEPAGE="https://example.com/" | ||
| SRC_URI="https://example.com/" | ||
|
|
||
| LICENSE="MIT" | ||
| SLOT="0" | ||
| KEYWORDS="amd64" |
12 changes: 12 additions & 0 deletions
12
testdata/repos/stable_keywords/StableKeywordsCheck/StableKeywords/StableKeywords-1.ebuild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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="StableKeywords" | ||
| HOMEPAGE="https://example.com/" | ||
| SRC_URI="https://example.com/" | ||
|
|
||
| LICENSE="MIT" | ||
| SLOT="0" | ||
| KEYWORDS="~amd64 x86" |
12 changes: 12 additions & 0 deletions
12
testdata/repos/stable_keywords/StableKeywordsCheck/StableKeywords/StableKeywords-2.ebuild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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="StableKeywords" | ||
| HOMEPAGE="https://example.com/" | ||
| SRC_URI="https://example.com/" | ||
|
|
||
| LICENSE="MIT" | ||
| SLOT="0" | ||
| KEYWORDS="~amd64" |
11 changes: 11 additions & 0 deletions
11
testdata/repos/stable_keywords/StableKeywordsCheck/StableKeywords/StableKeywords-9999.ebuild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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="StableKeywords" | ||
| HOMEPAGE="https://example.com/" | ||
| SRC_URI="https://example.com/" | ||
|
|
||
| LICENSE="MIT" | ||
| SLOT="0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| masters = | ||
| cache-formats = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| amd64 | ||
| x86 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| StableKeywordsCheck |
1 change: 1 addition & 0 deletions
1
testdata/repos/stable_keywords/profiles/default/amd64/make.defaults
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ARCH="amd64" |
1 change: 1 addition & 0 deletions
1
testdata/repos/stable_keywords/profiles/default/x86/make.defaults
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ARCH="x86" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| amd64 default/amd64 stable | ||
| x86 default/x86 stable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| stable_keywords |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for the other docstring- this flows better IMO:
Scan for packages using stable keywords disalllowed by the repositoryIsh, but you get the idea.