From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 718BF58973 for ; Sat, 30 Jan 2016 06:59:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DA28021C074; Sat, 30 Jan 2016 06:59:00 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 616B721C002 for ; Sat, 30 Jan 2016 06:58:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6E5B0340CDE for ; Sat, 30 Jan 2016 06:58:58 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7EDEECEB for ; Sat, 30 Jan 2016 06:58:54 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1454135637.47f880cf6ffa44309dd85e4e54ee5b0cf3043498.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/metadata/, pym/repoman/, ... X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/checks/ebuilds/variables/license.py pym/repoman/modules/scan/metadata/__init__.py pym/repoman/modules/scan/metadata/license.py pym/repoman/scanner.py X-VCS-Directories: pym/repoman/checks/ebuilds/variables/ pym/repoman/modules/scan/metadata/ pym/repoman/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 47f880cf6ffa44309dd85e4e54ee5b0cf3043498 X-VCS-Branch: repoman Date: Sat, 30 Jan 2016 06:58:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 6f0a5260-6f46-43cc-ac87-05883f9b02b7 X-Archives-Hash: 437ea2ed29718ec01e774bb183333811 commit: 47f880cf6ffa44309dd85e4e54ee5b0cf3043498 Author: Brian Dolbec gentoo org> AuthorDate: Sun Jan 3 23:09:27 2016 +0000 Commit: Brian Dolbec gentoo 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