1 |
commit: f5b8099f789b28533ffbe3dea814ebcae5c67ada |
2 |
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jun 6 15:23:33 2014 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 21 23:42:44 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f5b8099f |
7 |
|
8 |
repoman/main.py: Split RESTRICT checks to checks/ebuild/variables/ |
9 |
|
10 |
pym/repoman/checks/ebuilds/variables/restrict.py | 41 ++++++++++++++++++++++++ |
11 |
pym/repoman/main.py | 25 ++++----------- |
12 |
2 files changed, 47 insertions(+), 19 deletions(-) |
13 |
|
14 |
diff --git a/pym/repoman/checks/ebuilds/variables/restrict.py b/pym/repoman/checks/ebuilds/variables/restrict.py |
15 |
new file mode 100644 |
16 |
index 0000000..215b792 |
17 |
--- /dev/null |
18 |
+++ b/pym/repoman/checks/ebuilds/variables/restrict.py |
19 |
@@ -0,0 +1,41 @@ |
20 |
+ |
21 |
+'''restrict.py |
22 |
+Perform checks on the RESTRICT variable. |
23 |
+''' |
24 |
+ |
25 |
+# import our initialized portage instance |
26 |
+from repoman._portage import portage |
27 |
+ |
28 |
+from repoman.qa_data import valid_restrict |
29 |
+ |
30 |
+ |
31 |
+class RestrictChecks(object): |
32 |
+ '''Perform checks on the RESTRICT variable.''' |
33 |
+ |
34 |
+ def __init__(self, qatracker): |
35 |
+ ''' |
36 |
+ @param qatracker: QATracker instance |
37 |
+ ''' |
38 |
+ self.qatracker = qatracker |
39 |
+ |
40 |
+ def check(self, pkg, package, ebuild, y_ebuild): |
41 |
+ myrestrict = None |
42 |
+ |
43 |
+ try: |
44 |
+ myrestrict = portage.dep.use_reduce( |
45 |
+ pkg._metadata["RESTRICT"], matchall=1, flat=True) |
46 |
+ except portage.exception.InvalidDependString as e: |
47 |
+ self. qatracker.add_error( |
48 |
+ "RESTRICT.syntax", |
49 |
+ "%s: RESTRICT: %s" % (ebuild.relative_path, e)) |
50 |
+ del e |
51 |
+ |
52 |
+ if myrestrict: |
53 |
+ myrestrict = set(myrestrict) |
54 |
+ mybadrestrict = myrestrict.difference(valid_restrict) |
55 |
+ |
56 |
+ if mybadrestrict: |
57 |
+ for mybad in mybadrestrict: |
58 |
+ self.qatracker.add_error( |
59 |
+ "RESTRICT.invalid", |
60 |
+ package + "/" + y_ebuild + ".ebuild: %s" % mybad) |
61 |
|
62 |
diff --git a/pym/repoman/main.py b/pym/repoman/main.py |
63 |
index 08d79eb..8497833 100755 |
64 |
--- a/pym/repoman/main.py |
65 |
+++ b/pym/repoman/main.py |
66 |
@@ -64,6 +64,7 @@ from repoman.checks.ebuilds.use_flags import USEFlagChecks |
67 |
from repoman.checks.ebuilds.variables.description import DescriptionChecks |
68 |
from repoman.checks.ebuilds.variables.eapi import EAPIChecks |
69 |
from repoman.checks.ebuilds.variables.license import LicenseChecks |
70 |
+from repoman.checks.ebuilds.variables.restrict import RestrictChecks |
71 |
from repoman.ebuild import Ebuild |
72 |
from repoman.errors import err |
73 |
from repoman.modules.commit import repochecks |
74 |
@@ -71,7 +72,7 @@ from repoman.profile import check_profiles, dev_keywords, setup_profile |
75 |
from repoman.qa_data import ( |
76 |
format_qa_output, format_qa_output_column, qahelp, |
77 |
qawarnings, qacats, missingvars, |
78 |
- suspect_virtual, suspect_rdepend, valid_restrict) |
79 |
+ suspect_virtual, suspect_rdepend) |
80 |
from repoman.qa_tracker import QATracker |
81 |
from repoman.repos import RepoSettings, repo_metadata |
82 |
from repoman.scan import Changes, scan |
83 |
@@ -301,6 +302,7 @@ rubyeclasscheck = RubyEclassChecks(qatracker) |
84 |
eapicheck = EAPIChecks(qatracker, repo_settings) |
85 |
descriptioncheck = DescriptionChecks(qatracker) |
86 |
licensecheck = LicenseChecks(qatracker, liclist, liclist_deprecated) |
87 |
+restrictcheck = RestrictChecks(qatracker) |
88 |
###################### |
89 |
|
90 |
for xpkg in effective_scanlist: |
91 |
@@ -623,24 +625,9 @@ for xpkg in effective_scanlist: |
92 |
licensecheck.check(pkg, xpkg, ebuild, y_ebuild) |
93 |
################# |
94 |
|
95 |
- # restrict checks |
96 |
- myrestrict = None |
97 |
- try: |
98 |
- myrestrict = portage.dep.use_reduce( |
99 |
- myaux["RESTRICT"], matchall=1, flat=True) |
100 |
- except portage.exception.InvalidDependString as e: |
101 |
- qatracker.add_error( |
102 |
- "RESTRICT.syntax", |
103 |
- "%s: RESTRICT: %s" % (ebuild.relative_path, e)) |
104 |
- del e |
105 |
- if myrestrict: |
106 |
- myrestrict = set(myrestrict) |
107 |
- mybadrestrict = myrestrict.difference(valid_restrict) |
108 |
- if mybadrestrict: |
109 |
- for mybad in mybadrestrict: |
110 |
- qatracker.add_error( |
111 |
- "RESTRICT.invalid", |
112 |
- xpkg + "/" + y_ebuild + ".ebuild: %s" % mybad) |
113 |
+ ################# |
114 |
+ restrictcheck.check(pkg, xpkg, ebuild, y_ebuild) |
115 |
+ ################# |
116 |
|
117 |
# Syntax Checks |