From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/metadata/, pym/repoman/, ...
Date: Sat, 30 Jan 2016 06:58:54 +0000 (UTC) [thread overview]
Message-ID: <1454135637.47f880cf6ffa44309dd85e4e54ee5b0cf3043498.dolsen@gentoo> (raw)
commit: 47f880cf6ffa44309dd85e4e54ee5b0cf3043498
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: Sat Jan 30 06:33:57 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=47f880cf
repoman: Migrate license checks to a plugin module
pym/repoman/checks/ebuilds/variables/license.py | 47 ----------------------
pym/repoman/modules/scan/metadata/__init__.py | 9 +++++
pym/repoman/modules/scan/metadata/license.py | 53 +++++++++++++++++++++++++
pym/repoman/scanner.py | 7 +---
4 files changed, 63 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 83aac7f..c8f3609 100644
--- a/pym/repoman/modules/scan/metadata/__init__.py
+++ b/pym/repoman/modules/scan/metadata/__init__.py
@@ -37,6 +37,15 @@ module_spec = {
'func_desc': {
},
},
+ 'license-metadata': {
+ 'name': "license",
+ 'sourcefile': "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 c8539cb..55f3d56 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
@@ -213,7 +212,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)
@@ -300,6 +298,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])
@@ -327,10 +326,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
next reply other threads:[~2016-01-30 6:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-30 6:58 Brian Dolbec [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-04-25 16:59 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/metadata/, pym/repoman/, Zac Medico
2016-04-25 15:32 Brian Dolbec
2016-04-21 16:54 Brian Dolbec
2016-03-15 19:00 Brian Dolbec
2016-01-29 5:01 Brian Dolbec
2016-01-27 23:15 Brian Dolbec
2016-01-27 23:15 Brian Dolbec
2016-01-23 1:42 Brian Dolbec
2016-01-22 20:55 Brian Dolbec
2016-01-11 6:31 Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454135637.47f880cf6ffa44309dd85e4e54ee5b0cf3043498.dolsen@gentoo \
--to=dolsen@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox