1 |
commit: 3488df72f0af643234e5d05b519334e169822e0d |
2 |
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jun 4 09:17:12 2014 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Wed Oct 1 23:45:34 2014 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3488df72 |
7 |
|
8 |
repoman/main.py: Split KEYWORDS checks to checks/ebuilds/keywords.py |
9 |
|
10 |
--- |
11 |
pym/repoman/checks/ebuilds/keywords.py | 67 ++++++++++++++++++++++++++++++++++ |
12 |
pym/repoman/main.py | 32 ++++------------ |
13 |
2 files changed, 75 insertions(+), 24 deletions(-) |
14 |
|
15 |
diff --git a/pym/repoman/checks/ebuilds/keywords.py b/pym/repoman/checks/ebuilds/keywords.py |
16 |
new file mode 100644 |
17 |
index 0000000..29de0db |
18 |
--- /dev/null |
19 |
+++ b/pym/repoman/checks/ebuilds/keywords.py |
20 |
@@ -0,0 +1,67 @@ |
21 |
+ |
22 |
+'''keywords.py |
23 |
+Perform KEYWORDS related checks |
24 |
+''' |
25 |
+ |
26 |
+ |
27 |
+class KeywordChecks(object): |
28 |
+ '''Perform checks on the KEYWORDS of an ebuild''' |
29 |
+ |
30 |
+ def __init__(self, qatracker): |
31 |
+ ''' |
32 |
+ @param qatracker: QATracker instance |
33 |
+ ''' |
34 |
+ self.qatracker = qatracker |
35 |
+ self.slot_keywords = {} |
36 |
+ |
37 |
+ def prepare(self): |
38 |
+ '''Prepare the checks for the next package.''' |
39 |
+ self.slot_keywords = {} |
40 |
+ |
41 |
+ def check( |
42 |
+ self, pkg, package, ebuild, y_ebuild, keywords, ebuild_archs, changed, |
43 |
+ live_ebuild): |
44 |
+ '''Perform the check. |
45 |
+ |
46 |
+ @param pkg: Package in which we check (object). |
47 |
+ @param package: Package in which we check (string). |
48 |
+ @param ebuild: Ebuild which we check (object). |
49 |
+ @param y_ebuild: Ebuild which we check (string). |
50 |
+ @param keywords: All the keywords (including -...) of the ebuild. |
51 |
+ @param ebuild_archs: Just the architectures (no prefixes) of the ebuild. |
52 |
+ @param changed: Changes instance |
53 |
+ @param slot_keywords: A dictionary of keywords per slot. |
54 |
+ @param live_ebuild: A boolean that determines if this is a live ebuild. |
55 |
+ ''' |
56 |
+ self._checkAddedWithStableKeywords( |
57 |
+ package, ebuild, y_ebuild, keywords, changed) |
58 |
+ self._checkForDroppedKeywords( |
59 |
+ pkg, ebuild, ebuild_archs, live_ebuild) |
60 |
+ |
61 |
+ self.slot_keywords[pkg.slot].update(ebuild_archs) |
62 |
+ |
63 |
+ def _checkAddedWithStableKeywords( |
64 |
+ self, package, ebuild, y_ebuild, keywords, changed): |
65 |
+ catdir, pkgdir = package.split("/") |
66 |
+ |
67 |
+ is_stable = lambda kw: not kw.startswith("~") and not kw.startswith("-") |
68 |
+ stable_keywords = list(filter(is_stable, keywords)) |
69 |
+ if stable_keywords: |
70 |
+ if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual": |
71 |
+ stable_keywords.sort() |
72 |
+ self.qatracker.add_error( |
73 |
+ "KEYWORDS.stable", |
74 |
+ "%s/%s.ebuild added with stable keywords: %s" % |
75 |
+ (package, y_ebuild, " ".join(stable_keywords))) |
76 |
+ |
77 |
+ def _checkForDroppedKeywords( |
78 |
+ self, pkg, ebuild, ebuild_archs, live_ebuild): |
79 |
+ previous_keywords = self.slot_keywords.get(pkg.slot) |
80 |
+ if previous_keywords is None: |
81 |
+ self.slot_keywords[pkg.slot] = set() |
82 |
+ elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild: |
83 |
+ dropped_keywords = previous_keywords.difference(ebuild_archs) |
84 |
+ if dropped_keywords: |
85 |
+ self.qatracker.add_error("KEYWORDS.dropped", |
86 |
+ "%s: %s" % |
87 |
+ (ebuild.relative_path, " ".join(sorted(dropped_keywords)))) |
88 |
\ No newline at end of file |
89 |
|
90 |
diff --git a/pym/repoman/main.py b/pym/repoman/main.py |
91 |
index 8a1a043..05d9a14 100755 |
92 |
--- a/pym/repoman/main.py |
93 |
+++ b/pym/repoman/main.py |
94 |
@@ -49,6 +49,7 @@ from repoman.argparser import parse_args |
95 |
from repoman.checks.directories.files import FileChecks |
96 |
from repoman.checks.ebuilds.checks import run_checks, checks_init |
97 |
from repoman.checks.ebuilds.fetches import FetchChecks |
98 |
+from repoman.checks.ebuilds.keywords import KeywordChecks |
99 |
from repoman.checks.ebuilds.isebuild import IsEbuild |
100 |
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors |
101 |
from repoman.checks.ebuilds.manifests import Manifests |
102 |
@@ -281,7 +282,7 @@ fetchcheck = FetchChecks(qatracker, repoman_settings, repo_settings, portdb, |
103 |
pkgmeta = PkgMetadata(options, qatracker, repoman_settings) |
104 |
thirdparty = ThirdPartyMirrors(repoman_settings, qatracker) |
105 |
use_flag_checks = USEFlagChecks(qatracker, uselist) |
106 |
- |
107 |
+keywordcheck = KeywordChecks(qatracker) |
108 |
|
109 |
for xpkg in effective_scanlist: |
110 |
# ebuilds and digests added to cvs respectively. |
111 |
@@ -322,7 +323,7 @@ for xpkg in effective_scanlist: |
112 |
continue |
113 |
###################### |
114 |
|
115 |
- slot_keywords = {} |
116 |
+ keywordcheck.prepare() |
117 |
|
118 |
# Sort ebuilds in ascending order for the KEYWORDS.dropped check. |
119 |
ebuildlist = sorted(pkgs.values()) |
120 |
@@ -427,32 +428,15 @@ for xpkg in effective_scanlist: |
121 |
(ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len)) |
122 |
|
123 |
keywords = myaux["KEYWORDS"].split() |
124 |
- stable_keywords = [] |
125 |
- for keyword in keywords: |
126 |
- if not keyword.startswith("~") and \ |
127 |
- not keyword.startswith("-"): |
128 |
- stable_keywords.append(keyword) |
129 |
- if stable_keywords: |
130 |
- if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual": |
131 |
- stable_keywords.sort() |
132 |
- qatracker.add_error("KEYWORDS.stable", |
133 |
- "%s/%s.ebuild added with stable keywords: %s" % |
134 |
- (xpkg, y_ebuild, " ".join(stable_keywords))) |
135 |
|
136 |
ebuild_archs = set( |
137 |
kw.lstrip("~") for kw in keywords if not kw.startswith("-")) |
138 |
|
139 |
- previous_keywords = slot_keywords.get(pkg.slot) |
140 |
- if previous_keywords is None: |
141 |
- slot_keywords[pkg.slot] = set() |
142 |
- elif ebuild_archs and "*" not in ebuild_archs and not live_ebuild: |
143 |
- dropped_keywords = previous_keywords.difference(ebuild_archs) |
144 |
- if dropped_keywords: |
145 |
- qatracker.add_error("KEYWORDS.dropped", |
146 |
- "%s: %s" % |
147 |
- (ebuild.relative_path, " ".join(sorted(dropped_keywords)))) |
148 |
- |
149 |
- slot_keywords[pkg.slot].update(ebuild_archs) |
150 |
+ ####################### |
151 |
+ keywordcheck.check( |
152 |
+ pkg, xpkg, ebuild, y_ebuild, keywords, ebuild_archs, changed, |
153 |
+ live_ebuild) |
154 |
+ ####################### |
155 |
|
156 |
# KEYWORDS="-*" is a stupid replacement for package.mask |
157 |
# and screws general KEYWORDS semantics |