1 |
commit: 1c0dd942127f141b493513674a97089b69142b48 |
2 |
Author: Brian Dolbec <bdolbec <AT> gaikai <DOT> com> |
3 |
AuthorDate: Tue Jun 27 17:38:48 2017 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jun 27 22:05:07 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1c0dd942 |
7 |
|
8 |
qa_data.py: Initial move of all configurable data to the repo |
9 |
|
10 |
All this data was ported to a metadata/repoman/qa_data.yml file. |
11 |
|
12 |
repoman/pym/repoman/qa_data.py | 433 ++++++++--------------------------------- |
13 |
1 file changed, 77 insertions(+), 356 deletions(-) |
14 |
|
15 |
diff --git a/repoman/pym/repoman/qa_data.py b/repoman/pym/repoman/qa_data.py |
16 |
index fed798f9f..c2721d94e 100644 |
17 |
--- a/repoman/pym/repoman/qa_data.py |
18 |
+++ b/repoman/pym/repoman/qa_data.py |
19 |
@@ -1,369 +1,90 @@ |
20 |
# -*- coding:utf-8 -*- |
21 |
|
22 |
import logging |
23 |
+import os |
24 |
+import yaml |
25 |
|
26 |
from _emerge.Package import Package |
27 |
|
28 |
# import our initialized portage instance |
29 |
from repoman._portage import portage |
30 |
|
31 |
-max_desc_len = 80 |
32 |
-allowed_filename_chars = "a-zA-Z0-9._-+:" |
33 |
|
34 |
-qahelp = { |
35 |
- "CVS/Entries.IO_error": ( |
36 |
- "Attempting to commit, and an IO error was encountered access the" |
37 |
- " Entries file"), |
38 |
- "ebuild.invalidname": ( |
39 |
- "Ebuild files with a non-parseable or syntactically incorrect name" |
40 |
- " (or using 2.1 versioning extensions)"), |
41 |
- "ebuild.namenomatch": ( |
42 |
- "Ebuild files that do not have the same name as their parent" |
43 |
- " directory"), |
44 |
- "changelog.ebuildadded": ( |
45 |
- "An ebuild was added but the ChangeLog was not modified"), |
46 |
- "changelog.missing": ( |
47 |
- "Missing ChangeLog files"), |
48 |
- "ebuild.notadded": ( |
49 |
- "Ebuilds that exist but have not been added to cvs"), |
50 |
- "ebuild.patches": ( |
51 |
- "PATCHES variable should be a bash array to ensure white space safety"), |
52 |
- "changelog.notadded": ( |
53 |
- "ChangeLogs that exist but have not been added to cvs"), |
54 |
- "dependency.bad": ( |
55 |
- "User-visible ebuilds with unsatisfied dependencies" |
56 |
- " (matched against *visible* ebuilds)"), |
57 |
- "dependency.badmasked": ( |
58 |
- "Masked ebuilds with unsatisfied dependencies" |
59 |
- " (matched against *all* ebuilds)"), |
60 |
- "dependency.badindev": ( |
61 |
- "User-visible ebuilds with unsatisfied dependencies" |
62 |
- " (matched against *visible* ebuilds) in developing arch"), |
63 |
- "dependency.badmaskedindev": ( |
64 |
- "Masked ebuilds with unsatisfied dependencies" |
65 |
- " (matched against *all* ebuilds) in developing arch"), |
66 |
- "dependency.badtilde": ( |
67 |
- "Uses the ~ dep operator with a non-zero revision part," |
68 |
- " which is useless (the revision is ignored)"), |
69 |
- "dependency.missingslot": ( |
70 |
- "RDEPEND matches more than one SLOT but does not specify a " |
71 |
- "slot and/or use the := or :* slot operator"), |
72 |
- "dependency.perlcore": ( |
73 |
- "This ebuild directly depends on a package in perl-core;" |
74 |
- " it should use the corresponding virtual instead."), |
75 |
- "dependency.syntax": ( |
76 |
- "Syntax error in dependency string" |
77 |
- " (usually an extra/missing space/parenthesis)"), |
78 |
- "dependency.unknown": ( |
79 |
- "Ebuild has a dependency that refers to an unknown package" |
80 |
- " (which may be valid if it is a blocker for a renamed/removed package," |
81 |
- " or is an alternative choice provided by an overlay)"), |
82 |
- "dependency.badslotop": ( |
83 |
- "RDEPEND contains ':=' slot operator under '||' dependency."), |
84 |
- "file.executable": ( |
85 |
- "Ebuilds, digests, metadata.xml, Manifest, and ChangeLog do not need" |
86 |
- " the executable bit"), |
87 |
- "file.size": ( |
88 |
- "Files in the files directory must be under 20 KiB"), |
89 |
- "file.size.fatal": ( |
90 |
- "Files in the files directory must be under 60 KiB"), |
91 |
- "file.empty": ( |
92 |
- "Empty file in the files directory"), |
93 |
- "file.name": ( |
94 |
- "File/dir name must be composed" |
95 |
- " of only the following chars: %s " % allowed_filename_chars), |
96 |
- "file.UTF8": ( |
97 |
- "File is not UTF8 compliant"), |
98 |
- "inherit.deprecated": ( |
99 |
- "Ebuild inherits a deprecated eclass"), |
100 |
- "inherit.missing": ( |
101 |
- "Ebuild uses functions from an eclass but does not inherit it"), |
102 |
- "inherit.unused": ( |
103 |
- "Ebuild inherits an eclass but does not use it"), |
104 |
- "java.eclassesnotused": ( |
105 |
- "With virtual/jdk in DEPEND you must inherit a java eclass"), |
106 |
- "wxwidgets.eclassnotused": ( |
107 |
- "Ebuild DEPENDs on x11-libs/wxGTK without inheriting wxwidgets.eclass"), |
108 |
- "KEYWORDS.dropped": ( |
109 |
- "Ebuilds that appear to have dropped KEYWORDS for some arch"), |
110 |
- "KEYWORDS.missing": ( |
111 |
- "Ebuilds that have a missing or empty KEYWORDS variable"), |
112 |
- "KEYWORDS.stable": ( |
113 |
- "Ebuilds that have been added directly with stable KEYWORDS"), |
114 |
- "KEYWORDS.stupid": ( |
115 |
- "Ebuilds that use KEYWORDS=-* instead of package.mask"), |
116 |
- "LICENSE.missing": ( |
117 |
- "Ebuilds that have a missing or empty LICENSE variable"), |
118 |
- "LICENSE.virtual": ( |
119 |
- "Virtuals that have a non-empty LICENSE variable"), |
120 |
- "DESCRIPTION.missing": ( |
121 |
- "Ebuilds that have a missing or empty DESCRIPTION variable"), |
122 |
- "DESCRIPTION.toolong": ( |
123 |
- "DESCRIPTION is over %d characters" % max_desc_len), |
124 |
- "EAPI.definition": ( |
125 |
- "EAPI definition does not conform to PMS section 7.3.1" |
126 |
- " (first non-comment, non-blank line)"), |
127 |
- "EAPI.deprecated": ( |
128 |
- "Ebuilds that use features that are deprecated in the current EAPI"), |
129 |
- "EAPI.incompatible": ( |
130 |
- "Ebuilds that use features that are only available with a different" |
131 |
- " EAPI"), |
132 |
- "EAPI.unsupported": ( |
133 |
- "Ebuilds that have an unsupported EAPI version" |
134 |
- " (you must upgrade portage)"), |
135 |
- "SLOT.invalid": ( |
136 |
- "Ebuilds that have a missing or invalid SLOT variable value"), |
137 |
- "HOMEPAGE.missing": ( |
138 |
- "Ebuilds that have a missing or empty HOMEPAGE variable"), |
139 |
- "HOMEPAGE.virtual": ( |
140 |
- "Virtuals that have a non-empty HOMEPAGE variable"), |
141 |
- "HOMEPAGE.missingurischeme": ( |
142 |
- "HOMEPAGE is missing an URI scheme"), |
143 |
- "PDEPEND.suspect": ( |
144 |
- "PDEPEND contains a package that usually only belongs in DEPEND."), |
145 |
- "LICENSE.syntax": ( |
146 |
- "Syntax error in LICENSE" |
147 |
- " (usually an extra/missing space/parenthesis)"), |
148 |
- "PROVIDE.syntax": ( |
149 |
- "Syntax error in PROVIDE" |
150 |
- " (usually an extra/missing space/parenthesis)"), |
151 |
- "PROPERTIES.syntax": ( |
152 |
- "Syntax error in PROPERTIES" |
153 |
- " (usually an extra/missing space/parenthesis)"), |
154 |
- "RESTRICT.syntax": ( |
155 |
- "Syntax error in RESTRICT" |
156 |
- " (usually an extra/missing space/parenthesis)"), |
157 |
- "REQUIRED_USE.syntax": ( |
158 |
- "Syntax error in REQUIRED_USE" |
159 |
- " (usually an extra/missing space/parenthesis)"), |
160 |
- "SRC_URI.syntax": ( |
161 |
- "Syntax error in SRC_URI" |
162 |
- " (usually an extra/missing space/parenthesis)"), |
163 |
- "SRC_URI.mirror": ( |
164 |
- "A uri listed in profiles/thirdpartymirrors is found in SRC_URI"), |
165 |
- "ebuild.syntax": ( |
166 |
- "Error generating cache entry for ebuild;" |
167 |
- " typically caused by ebuild syntax error" |
168 |
- " or digest verification failure"), |
169 |
- "ebuild.output": ( |
170 |
- "A simple sourcing of the ebuild produces output;" |
171 |
- " this breaks ebuild policy."), |
172 |
- "ebuild.nesteddie": ( |
173 |
- "Placing 'die' inside ( ) prints an error," |
174 |
- " but doesn't stop the ebuild."), |
175 |
- "variable.invalidchar": ( |
176 |
- "A variable contains an invalid character" |
177 |
- " that is not part of the ASCII character set"), |
178 |
- "variable.readonly": ( |
179 |
- "Assigning a readonly variable"), |
180 |
- "variable.usedwithhelpers": ( |
181 |
- "Ebuild uses D, ROOT, ED, EROOT or EPREFIX with helpers"), |
182 |
- "LIVEVCS.stable": ( |
183 |
- "This ebuild is a live checkout from a VCS but has stable keywords."), |
184 |
- "LIVEVCS.unmasked": ( |
185 |
- "This ebuild is a live checkout from a VCS but has keywords" |
186 |
- " and is not masked in the global package.mask."), |
187 |
- "IUSE.invalid": ( |
188 |
- "This ebuild has a variable in IUSE" |
189 |
- " that is not in the use.desc or its metadata.xml file"), |
190 |
- "IUSE.missing": ( |
191 |
- "This ebuild has a USE conditional" |
192 |
- " which references a flag that is not listed in IUSE"), |
193 |
- "IUSE.rubydeprecated": ( |
194 |
- "The ebuild has set a ruby interpreter in USE_RUBY," |
195 |
- " that is not available as a ruby target anymore"), |
196 |
- "LICENSE.invalid": ( |
197 |
- "This ebuild is listing a license" |
198 |
- " that doesnt exist in portages license/ dir."), |
199 |
- "LICENSE.deprecated": ( |
200 |
- "This ebuild is listing a deprecated license."), |
201 |
- "KEYWORDS.invalid": ( |
202 |
- "This ebuild contains KEYWORDS" |
203 |
- " that are not listed in profiles/arch.list" |
204 |
- " or for which no valid profile was found"), |
205 |
- "RDEPEND.implicit": ( |
206 |
- "RDEPEND is unset in the ebuild" |
207 |
- " which triggers implicit RDEPEND=$DEPEND assignment" |
208 |
- " (prior to EAPI 4)"), |
209 |
- "RDEPEND.suspect": ( |
210 |
- "RDEPEND contains a package that usually only belongs in DEPEND."), |
211 |
- "RESTRICT.invalid": ( |
212 |
- "This ebuild contains invalid RESTRICT values."), |
213 |
- "digest.assumed": ( |
214 |
- "Existing digest must be assumed correct (Package level only)"), |
215 |
- "digest.missing": ( |
216 |
- "Some files listed in SRC_URI aren't referenced in the Manifest"), |
217 |
- "digest.unused": ( |
218 |
- "Some files listed in the Manifest aren't referenced in SRC_URI"), |
219 |
- "ebuild.absdosym": ( |
220 |
- "This ebuild uses absolute target to dosym where relative symlink" |
221 |
- " could be used instead"), |
222 |
- "ebuild.majorsyn": ( |
223 |
- "This ebuild has a major syntax error" |
224 |
- " that may cause the ebuild to fail partially or fully"), |
225 |
- "ebuild.minorsyn": ( |
226 |
- "This ebuild has a minor syntax error" |
227 |
- " that contravenes gentoo coding style"), |
228 |
- "ebuild.badheader": ( |
229 |
- "This ebuild has a malformed header"), |
230 |
- "manifest.bad": ( |
231 |
- "Manifest has missing or incorrect digests"), |
232 |
- "metadata.missing": ( |
233 |
- "Missing metadata.xml files"), |
234 |
- "metadata.bad": ( |
235 |
- "Bad metadata.xml files"), |
236 |
- "metadata.warning": ( |
237 |
- "Warnings in metadata.xml files"), |
238 |
- "portage.internal": ( |
239 |
- "The ebuild uses an internal Portage function or variable"), |
240 |
- "repo.eapi.banned": ( |
241 |
- "The ebuild uses an EAPI which is" |
242 |
- " banned by the repository's metadata/layout.conf settings"), |
243 |
- "repo.eapi.deprecated": ( |
244 |
- "The ebuild uses an EAPI which is" |
245 |
- " deprecated by the repository's metadata/layout.conf settings"), |
246 |
- "virtual.oldstyle": ( |
247 |
- "The ebuild PROVIDEs an old-style virtual (see GLEP 37)"), |
248 |
- "virtual.suspect": ( |
249 |
- "Ebuild contains a package" |
250 |
- " that usually should be pulled via virtual/, not directly."), |
251 |
- "usage.obsolete": ( |
252 |
- "The ebuild makes use of an obsolete construct"), |
253 |
- "upstream.workaround": ( |
254 |
- "The ebuild works around an upstream bug," |
255 |
- " an upstream bug should be filed and tracked in bugs.gentoo.org"), |
256 |
- "uri.https": "URI uses http:// but should use https://", |
257 |
-} |
258 |
- |
259 |
-qacats = list(qahelp) |
260 |
-qacats.sort() |
261 |
- |
262 |
-qawarnings = set(( |
263 |
- "changelog.missing", |
264 |
- "changelog.notadded", |
265 |
- "dependency.unknown", |
266 |
- "digest.assumed", |
267 |
- "digest.unused", |
268 |
- "ebuild.notadded", |
269 |
- "ebuild.nesteddie", |
270 |
- "dependency.badmasked", |
271 |
- "dependency.badindev", |
272 |
- "dependency.badmaskedindev", |
273 |
- "dependency.badtilde", |
274 |
- "dependency.missingslot", |
275 |
- "dependency.perlcore", |
276 |
- "DESCRIPTION.toolong", |
277 |
- "EAPI.deprecated", |
278 |
- "HOMEPAGE.virtual", |
279 |
- "LICENSE.deprecated", |
280 |
- "LICENSE.virtual", |
281 |
- "KEYWORDS.dropped", |
282 |
- "KEYWORDS.stupid", |
283 |
- "KEYWORDS.missing", |
284 |
- "PDEPEND.suspect", |
285 |
- "RDEPEND.implicit", |
286 |
- "RDEPEND.suspect", |
287 |
- "virtual.suspect", |
288 |
- "RESTRICT.invalid", |
289 |
- "ebuild.absdosym", |
290 |
- "ebuild.minorsyn", |
291 |
- "ebuild.badheader", |
292 |
- "ebuild.patches", |
293 |
- "file.empty", |
294 |
- "file.size", |
295 |
- "inherit.unused", |
296 |
- "inherit.deprecated", |
297 |
- "java.eclassesnotused", |
298 |
- "wxwidgets.eclassnotused", |
299 |
- "metadata.warning", |
300 |
- "portage.internal", |
301 |
- "repo.eapi.deprecated", |
302 |
- "usage.obsolete", |
303 |
- "upstream.workaround", |
304 |
- "IUSE.rubydeprecated", |
305 |
- "uri.https", |
306 |
-)) |
307 |
- |
308 |
- |
309 |
-missingvars = ["KEYWORDS", "LICENSE", "DESCRIPTION", "HOMEPAGE"] |
310 |
-allvars = set(x for x in portage.auxdbkeys if not x.startswith("UNUSED_")) |
311 |
-allvars.update(Package.metadata_keys) |
312 |
-allvars = sorted(allvars) |
313 |
- |
314 |
-for x in missingvars: |
315 |
- x += ".missing" |
316 |
- if x not in qacats: |
317 |
- logging.warning('* missingvars values need to be added to qahelp ("%s")' % x) |
318 |
- qacats.append(x) |
319 |
- qawarnings.add(x) |
320 |
- |
321 |
-valid_restrict = frozenset([ |
322 |
- "binchecks", "bindist", "fetch", "installsources", "mirror", |
323 |
- "preserve-libs", "primaryuri", "splitdebug", "strip", "test", "userpriv"]) |
324 |
- |
325 |
- |
326 |
-suspect_rdepend = frozenset([ |
327 |
- "app-arch/cabextract", |
328 |
- "app-arch/rpm2targz", |
329 |
- "app-doc/doxygen", |
330 |
- "dev-lang/nasm", |
331 |
- "dev-lang/swig", |
332 |
- "dev-lang/yasm", |
333 |
- "dev-perl/extutils-pkgconfig", |
334 |
- "dev-qt/linguist-tools", |
335 |
- "dev-util/byacc", |
336 |
- "dev-util/cmake", |
337 |
- "dev-util/ftjam", |
338 |
- "dev-util/gperf", |
339 |
- "dev-util/gtk-doc", |
340 |
- "dev-util/gtk-doc-am", |
341 |
- "dev-util/intltool", |
342 |
- "dev-util/jam", |
343 |
- "dev-util/pkg-config-lite", |
344 |
- "dev-util/pkgconf", |
345 |
- "dev-util/pkgconfig", |
346 |
- "dev-util/pkgconfig-openbsd", |
347 |
- "dev-util/scons", |
348 |
- "dev-util/unifdef", |
349 |
- "dev-util/yacc", |
350 |
- "media-gfx/ebdftopcf", |
351 |
- "sys-apps/help2man", |
352 |
- "sys-devel/autoconf", |
353 |
- "sys-devel/automake", |
354 |
- "sys-devel/bin86", |
355 |
- "sys-devel/bison", |
356 |
- "sys-devel/dev86", |
357 |
- "sys-devel/flex", |
358 |
- "sys-devel/m4", |
359 |
- "sys-devel/pmake", |
360 |
- "virtual/linux-sources", |
361 |
- "virtual/linuxtv-dvb-headers", |
362 |
- "virtual/os-headers", |
363 |
- "virtual/pkgconfig", |
364 |
- "x11-misc/bdftopcf", |
365 |
- "x11-misc/imake", |
366 |
-]) |
367 |
- |
368 |
-suspect_virtual = { |
369 |
- "dev-util/pkg-config-lite": "virtual/pkgconfig", |
370 |
- "dev-util/pkgconf": "virtual/pkgconfig", |
371 |
- "dev-util/pkgconfig": "virtual/pkgconfig", |
372 |
- "dev-util/pkgconfig-openbsd": "virtual/pkgconfig", |
373 |
- "dev-libs/libusb": "virtual/libusb", |
374 |
- "dev-libs/libusbx": "virtual/libusb", |
375 |
- "dev-libs/libusb-compat": "virtual/libusb", |
376 |
-} |
377 |
- |
378 |
-ruby_deprecated = frozenset([ |
379 |
- "ruby_targets_ree18", |
380 |
- "ruby_targets_ruby18", |
381 |
- "ruby_targets_ruby19", |
382 |
- "ruby_targets_ruby20", |
383 |
-]) |
384 |
- |
385 |
- |
386 |
-# file.executable |
387 |
-no_exec = frozenset(["Manifest", "ChangeLog", "metadata.xml"]) |
388 |
+class QAData(object): |
389 |
+ |
390 |
+ def __init__(self): |
391 |
+ # Create the main exported data variables |
392 |
+ self.max_desc_len = None |
393 |
+ self.allowed_filename_chars = None |
394 |
+ self.qahelp = None |
395 |
+ self.qacats = None |
396 |
+ self.qawarnings = None |
397 |
+ self.missingvars = None |
398 |
+ self.allvars = None |
399 |
+ self.valid_restrict = None |
400 |
+ self.suspect_rdepend = None |
401 |
+ self.suspect_virtual = None |
402 |
+ self.ruby_deprecated = None |
403 |
+ self.no_exec = None |
404 |
+ |
405 |
+ |
406 |
+ def load_repo_config(self, repopath, options): |
407 |
+ '''Load the repository repoman qa_data.yml config |
408 |
+ |
409 |
+ @param repopath: string, The path of the repository being scanned |
410 |
+ This could be a parent repository using the |
411 |
+ repoman_masters layout.conf variable |
412 |
+ ''' |
413 |
+ filepath = os.path.join(repopath, 'metadata/repoman/qa_data.yml') |
414 |
+ logging.debug("QAData: reading file", filepath) |
415 |
+ try: |
416 |
+ with open(filepath, 'r') as qadata_file: |
417 |
+ qadata = yaml.safe_load(qadata_file.read()) |
418 |
+ except IOError as error: |
419 |
+ logging.error("Failed to load 'qa_data.yml' file at path: %s", filepath) |
420 |
+ logging.eception(error) |
421 |
+ return False |
422 |
+ self.max_desc_len = qadata.get('max_description_length', 80) |
423 |
+ self.allowed_filename_chars = qadata.get("allowed_filename_chars", "a-zA-Z0-9._-+:") |
424 |
+ |
425 |
+ self.qahelp = qadata.get('qahelp', {}) |
426 |
+ |
427 |
+ self.qacats = [] |
428 |
+ for x in sorted(self.qahelp): |
429 |
+ for y in sorted(self.qahelp[x]): |
430 |
+ self.qacats.append('.'.join([x, y])) |
431 |
+ self.qacats.sort() |
432 |
+ |
433 |
+ self.qawarnings = set(qadata.get('qawarnings', [])) |
434 |
+ if options.experimental_inherit == 'y': |
435 |
+ # This is experimental, so it's non-fatal. |
436 |
+ self.qawarnings.add("inherit.missing") |
437 |
+ |
438 |
+ self.missingvars = qadata.get("missingvars", []) |
439 |
+ logging.debug("QAData: missingvars", self.missingvars) |
440 |
+ self.allvars = set(x for x in portage.auxdbkeys if not x.startswith("UNUSED_")) |
441 |
+ self.allvars.update(Package.metadata_keys) |
442 |
+ self.allvars = sorted(self.allvars) |
443 |
+ |
444 |
+ for x in self.missingvars: |
445 |
+ x += ".missing" |
446 |
+ if x not in self.qacats: |
447 |
+ logging.warning('* missingvars values need to be added to qahelp ("%s")' % x) |
448 |
+ self.qacats.append(x) |
449 |
+ self.qawarnings.add(x) |
450 |
+ |
451 |
+ self.valid_restrict = frozenset(qadata.get("valid_restrict", [])) |
452 |
+ |
453 |
+ self.suspect_rdepend = frozenset(qadata.get("suspect_rdepend", [])) |
454 |
+ |
455 |
+ self.suspect_virtual = qadata.get("suspect_virtual", {}) |
456 |
+ |
457 |
+ self.ruby_deprecated = frozenset(qadata.get("ruby_deprecated", [])) |
458 |
+ |
459 |
+ # file.executable |
460 |
+ self.no_exec = frozenset(qadata.get("no_exec_files", [])) |
461 |
+ logging.debug("QAData: completed loading file: %s", filepath) |
462 |
+ return True |
463 |
|
464 |
|
465 |
def format_qa_output( |