1 |
commit: 3a4ed09c34f7c98b7a8af76411b7aaf449d94003 |
2 |
Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jun 6 15:09:43 2014 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Wed Oct 1 23:45:35 2014 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3a4ed09c |
7 |
|
8 |
repoman/main.py: Split LICENSE checks to checks/ebuild/variables/ |
9 |
|
10 |
--- |
11 |
pym/repoman/checks/ebuilds/variables/license.py | 47 +++++++++++++++++++++++++ |
12 |
pym/repoman/main.py | 21 +++-------- |
13 |
2 files changed, 52 insertions(+), 16 deletions(-) |
14 |
|
15 |
diff --git a/pym/repoman/checks/ebuilds/variables/license.py b/pym/repoman/checks/ebuilds/variables/license.py |
16 |
new file mode 100644 |
17 |
index 0000000..bdc859c |
18 |
--- /dev/null |
19 |
+++ b/pym/repoman/checks/ebuilds/variables/license.py |
20 |
@@ -0,0 +1,47 @@ |
21 |
+ |
22 |
+'''description.py |
23 |
+Perform checks on the LICENSE variable. |
24 |
+''' |
25 |
+ |
26 |
+# import our initialized portage instance |
27 |
+from repoman._portage import portage |
28 |
+ |
29 |
+ |
30 |
+class LicenseChecks(object): |
31 |
+ '''Perform checks on the LICENSE variable.''' |
32 |
+ |
33 |
+ def __init__(self, qatracker, liclist, liclist_deprecated): |
34 |
+ ''' |
35 |
+ @param qatracker: QATracker instance |
36 |
+ @param liclist: List of licenses. |
37 |
+ @param liclist: List of deprecated licenses. |
38 |
+ ''' |
39 |
+ self.qatracker = qatracker |
40 |
+ self.liclist = liclist |
41 |
+ self.liclist_deprecated = liclist_deprecated |
42 |
+ |
43 |
+ def check( |
44 |
+ self, pkg, package, ebuild, y_ebuild): |
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 |
+ ''' |
51 |
+ |
52 |
+ # Parse the LICENSE variable, remove USE conditions and flatten it. |
53 |
+ licenses = portage.dep.use_reduce( |
54 |
+ pkg._metadata["LICENSE"], matchall=1, flat=True) |
55 |
+ |
56 |
+ # Check each entry to ensure that it exists in ${PORTDIR}/licenses/. |
57 |
+ for lic in licenses: |
58 |
+ # Need to check for "||" manually as no portage |
59 |
+ # function will remove it without removing values. |
60 |
+ if lic not in self.liclist and lic != "||": |
61 |
+ self.qatracker.add_error( |
62 |
+ "LICENSE.invalid", |
63 |
+ package + "/" + y_ebuild + ".ebuild: %s" % lic) |
64 |
+ elif lic in self.liclist_deprecated: |
65 |
+ self.qatracker.add_error( |
66 |
+ "LICENSE.deprecated", |
67 |
+ "%s: %s" % (ebuild.relative_path, lic)) |
68 |
|
69 |
diff --git a/pym/repoman/main.py b/pym/repoman/main.py |
70 |
index ed3cf88..722de79 100755 |
71 |
--- a/pym/repoman/main.py |
72 |
+++ b/pym/repoman/main.py |
73 |
@@ -60,6 +60,7 @@ from repoman.checks.ebuilds.pkgmetadata import PkgMetadata |
74 |
from repoman.checks.ebuilds.use_flags import USEFlagChecks |
75 |
from repoman.checks.ebuilds.variables.description import DescriptionChecks |
76 |
from repoman.checks.ebuilds.variables.eapi import EAPIChecks |
77 |
+from repoman.checks.ebuilds.variables.license import LicenseChecks |
78 |
from repoman.ebuild import Ebuild |
79 |
from repoman.errors import err |
80 |
from repoman.modules.commit import repochecks |
81 |
@@ -296,6 +297,7 @@ liveeclasscheck = LiveEclassChecks(qatracker) |
82 |
rubyeclasscheck = RubyEclassChecks(qatracker) |
83 |
eapicheck = EAPIChecks(qatracker, repo_settings) |
84 |
descriptioncheck = DescriptionChecks(qatracker) |
85 |
+licensecheck = LicenseChecks(qatracker, liclist, liclist_deprecated) |
86 |
###################### |
87 |
|
88 |
for xpkg in effective_scanlist: |
89 |
@@ -611,22 +613,9 @@ for xpkg in effective_scanlist: |
90 |
|
91 |
# license checks |
92 |
if not badlicsyntax: |
93 |
- # Parse the LICENSE variable, remove USE conditions and |
94 |
- # flatten it. |
95 |
- licenses = portage.dep.use_reduce(myaux["LICENSE"], matchall=1, flat=True) |
96 |
- # Check each entry to ensure that it exists in PORTDIR's |
97 |
- # license directory. |
98 |
- for lic in licenses: |
99 |
- # Need to check for "||" manually as no portage |
100 |
- # function will remove it without removing values. |
101 |
- if lic not in liclist and lic != "||": |
102 |
- qatracker.add_error( |
103 |
- "LICENSE.invalid", |
104 |
- xpkg + "/" + y_ebuild + ".ebuild: %s" % lic) |
105 |
- elif lic in liclist_deprecated: |
106 |
- qatracker.add_error( |
107 |
- "LICENSE.deprecated", |
108 |
- "%s: %s" % (ebuild.relative_path, lic)) |
109 |
+ ################# |
110 |
+ licensecheck.check(pkg, xpkg, ebuild, y_ebuild) |
111 |
+ ################# |
112 |
|
113 |
# restrict checks |
114 |
myrestrict = None |