commit: 196d6aa6d378c3f2ecd08a45c071c9fc568f2731
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 3 23:09:27 2016 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 21 00:35:22 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=196d6aa6
repoman: Migrate license checks to a plugin module
pym/repoman/checks/ebuilds/variables/license.py | 47 ----------------------
pym/repoman/modules/scan/metadata/__init__.py | 8 ++++
pym/repoman/modules/scan/metadata/license.py | 53 +++++++++++++++++++++++++
pym/repoman/scanner.py | 7 +---
4 files changed, 62 insertions(+), 53 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/variables/license.py
b/pym/repoman/checks/ebuilds/variables/license.py
deleted file mode 100644
index bdc859c..0000000
--- a/pym/repoman/checks/ebuilds/variables/license.py
+++ /dev/null
@@ -1,47 +0,0 @@
-
-'''description.py
-Perform checks on the LICENSE variable.
-'''
-
-# import our initialized portage instance
-from repoman._portage import portage
-
-
-class LicenseChecks(object):
- '''Perform checks on the LICENSE variable.'''
-
- def __init__(self, qatracker, liclist, liclist_deprecated):
- '''
- @param qatracker: QATracker instance
- @param liclist: List of licenses.
- @param liclist: List of deprecated licenses.
- '''
- self.qatracker = qatracker
- self.liclist = liclist
- self.liclist_deprecated = liclist_deprecated
-
- def check(
- self, pkg, package, ebuild, y_ebuild):
- '''
- @param pkg: Package in which we check (object).
- @param package: Package in which we check (string).
- @param ebuild: Ebuild which we check (object).
- @param y_ebuild: Ebuild which we check (string).
- '''
-
- # Parse the LICENSE variable, remove USE conditions and flatten
it.
- licenses = portage.dep.use_reduce(
- pkg._metadata["LICENSE"], matchall=1, flat=True)
-
- # Check each entry to ensure that it exists in
${PORTDIR}/licenses/.
- for lic in licenses:
- # Need to check for "||" manually as no portage
- # function will remove it without removing values.
- if lic not in self.liclist and lic != "||":
- self.qatracker.add_error(
- "LICENSE.invalid",
- package + "/" + y_ebuild + ".ebuild:
%s" % lic)
- elif lic in self.liclist_deprecated:
- self.qatracker.add_error(
- "LICENSE.deprecated",
- "%s: %s" % (ebuild.relative_path, lic))
diff --git a/pym/repoman/modules/scan/metadata/__init__.py
b/pym/repoman/modules/scan/metadata/__init__.py
index 2506521..ed0c59d 100644
--- a/pym/repoman/modules/scan/metadata/__init__.py
+++ b/pym/repoman/modules/scan/metadata/__init__.py
@@ -34,6 +34,14 @@ module_spec = {
'func_desc': {
},
},
+ 'license-metadata': {
+ 'name': "license",
+ 'class': "LicenseChecks",
+ 'description': doc,
+ 'functions': ['check'],
+ 'func_desc': {
+ },
+ },
}
}
diff --git a/pym/repoman/modules/scan/metadata/license.py
b/pym/repoman/modules/scan/metadata/license.py
new file mode 100644
index 0000000..b022b20
--- /dev/null
+++ b/pym/repoman/modules/scan/metadata/license.py
@@ -0,0 +1,53 @@
+
+'''license.py
+Perform checks on the LICENSE variable.
+'''
+
+# import our initialized portage instance
+from repoman._portage import portage
+
+
+class LicenseChecks(object):
+ '''Perform checks on the LICENSE variable.'''
+
+ def __init__(self, **kwargs):
+ '''
+ @param qatracker: QATracker instance
+ @param repo_metadata: dictionary of various repository items.
+ '''
+ self.qatracker = kwargs.get('qatracker')
+ self.repo_metadata = kwargs.get('repo_metadata')
+
+ def check(self, **kwargs):
+ '''
+ @param xpkg: Package in which we check (string).
+ @param ebuild: Ebuild which we check (object).
+ @param y_ebuild: Ebuild which we check (string).
+ '''
+ xpkg = kwargs.get('xpkg')
+ ebuild = kwargs.get('ebuild')
+ y_ebuild = kwargs.get('y_ebuild')
+ if not kwargs.get('badlicsyntax'):
+ # Parse the LICENSE variable, remove USE conditions and
flatten it.
+ licenses = portage.dep.use_reduce(
+ ebuild.metadata["LICENSE"], matchall=1,
flat=True)
+
+ # Check each entry to ensure that it exists in
${PORTDIR}/licenses/.
+ for lic in licenses:
+ # Need to check for "||" manually as no portage
+ # function will remove it without removing
values.
+ if lic not in self.repo_metadata['liclist'] and
lic != "||":
+
self.qatracker.add_error("LICENSE.invalid",
+ "%s/%s.ebuild: %s" % (xpkg,
y_ebuild, lic))
+ elif lic in
self.repo_metadata['lic_deprecated']:
+
self.qatracker.add_error("LICENSE.deprecated",
+ "%s: %s" %
(ebuild.relative_path, lic))
+ return {'continue': False}
+
+ @property
+ def runInPkgs(self):
+ return (False, [])
+
+ @property
+ def runInEbuilds(self):
+ return (True, [self.check])
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index d5faded..1f792bd 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -18,7 +18,6 @@ from portage import _unicode_encode
from portage.dep import Atom
from portage.output import green
from repoman.checks.ebuilds.checks import run_checks
-from repoman.checks.ebuilds.variables.license import LicenseChecks
from repoman.checks.ebuilds.variables.restrict import RestrictChecks
from repoman.modules.commit import repochecks
from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
@@ -210,7 +209,6 @@ class Scanner(object):
self.modules[mod_class.__name__] =
mod_class(**self.kwargs)
# initialize our checks classes here before the big xpkg loop
- self.licensecheck = LicenseChecks(self.qatracker, liclist,
liclist_deprecated)
self.restrictcheck = RestrictChecks(self.qatracker)
@@ -297,6 +295,7 @@ class Scanner(object):
('description', 'DescriptionChecks'), (None,
'KeywordChecks'),
('arches', 'ArchChecks'), ('depend',
'DependChecks'),
('use_flags', 'USEFlagChecks'), ('ruby',
'RubyEclassChecks'),
+ ('license', 'LicenseChecks'),
]:
if mod[0]:
mod_class =
MODULE_CONTROLLER.get_class(mod[0])
@@ -324,10 +323,6 @@ class Scanner(object):
if y_ebuild_continue:
continue
- # license checks
- if not dynamic_data['badlicsyntax']:
- self.licensecheck.check(dynamic_data['pkg'],
xpkg, dynamic_data['ebuild'], y_ebuild)
-
self.restrictcheck.check(dynamic_data['pkg'], xpkg,
dynamic_data['ebuild'], y_ebuild)
# Syntax Checks