|
8 | 8 | from . import OptionalCheck |
9 | 9 |
|
10 | 10 |
|
11 | | -class StableKeywords(results.PackageResult, results.Error): |
12 | | - """Package uses stable keywords.""" |
| 11 | +class DisallowedStableKeywords(results.VersionResult, results.Error): |
| 12 | + """Package uses stable keywords, which are disallowed in this repository.""" |
13 | 13 |
|
14 | | - def __init__(self, versions, arches, **kwargs): |
| 14 | + def __init__(self, arches, **kwargs): |
15 | 15 | super().__init__(**kwargs) |
16 | | - self.versions = tuple(versions) |
17 | | - self.arches = tuple(arches) |
| 16 | + self.arches = tuple(sort_keywords(arches)) |
18 | 17 |
|
19 | 18 | @property |
20 | 19 | def desc(self): |
21 | 20 | s = pluralism(self.arches) |
22 | 21 | arches = ", ".join(self.arches) |
23 | | - versions = ", ".join(self.versions) |
24 | | - return f"stable keyword{s} [ {arches} ] used on version{s}: [ {versions} ]" |
| 22 | + return f"disallowed stable keyword{s}: [ {arches} ]" |
25 | 23 |
|
26 | 24 |
|
27 | | -class StableKeywordsCheck(OptionalCheck): |
28 | | - """Scan for packages using stable keywords.""" |
| 25 | +class DisallowedStableKeywordsCheck(OptionalCheck): |
| 26 | + """Scan for packages using stable keywords in repositories where they are not allowed.""" |
29 | 27 |
|
30 | | - _source = sources.PackageRepoSource |
31 | 28 | required_addons = (addons.StableArchesAddon,) |
32 | | - known_results = frozenset([StableKeywords]) |
| 29 | + known_results = frozenset({DisallowedStableKeywords}) |
| 30 | + |
| 31 | + # acct-group and acct-user eclasses define KEYWORDS |
| 32 | + # See https://bugs.gentoo.org/342185 |
| 33 | + ignored_categories = frozenset({"acct-group", "acct-user"}) |
33 | 34 |
|
34 | 35 | def __init__(self, *args, stable_arches_addon=None): |
35 | 36 | super().__init__(*args) |
36 | | - self.arches = {x.strip().lstrip("~") for x in self.options.stable_arches} |
| 37 | + self.arches = frozenset({x.strip().lstrip("~") for x in self.options.stable_arches}) |
37 | 38 |
|
38 | 39 | self.arch_restricts = { |
39 | 40 | arch: packages.PackageRestriction("keywords", values.ContainmentMatch2((arch,))) |
40 | 41 | for arch in self.arches |
41 | 42 | } |
42 | 43 |
|
43 | | - def feed(self, pkgset): |
44 | | - pkgs_arches = defaultdict(set) |
45 | | - for arch, r in self.arch_restricts.items(): |
46 | | - for pkg in pkgset: |
47 | | - if r.match(pkg): |
48 | | - pkgs_arches[pkg].add(arch) |
49 | | - |
50 | | - # invert |
51 | | - arches_pkgs = defaultdict(list) |
52 | | - for pkg, arches in pkgs_arches.items(): |
53 | | - arches_pkgs[frozenset(arches)].append(pkg) |
54 | | - |
55 | | - # collapse reports by sets of arches |
56 | | - for arches, pkgs in arches_pkgs.items(): |
57 | | - versions = (pkg.fullver for pkg in sorted(pkgs)) |
58 | | - yield StableKeywords(versions, sort_keywords(arches), pkg=pkgs[0]) |
| 44 | + def feed(self, pkg): |
| 45 | + if pkg.category in self.ignored_categories: |
| 46 | + return |
| 47 | + |
| 48 | + arches = frozenset({arch for arch, r in self.arch_restricts.items() if r.match(pkg)}) |
| 49 | + if not arches: |
| 50 | + return |
| 51 | + |
| 52 | + yield DisallowedStableKeywords(arches, pkg=pkg) |
0 commit comments