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 3F3C21388BF for ; Sun, 10 Jan 2016 03:26:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C6CD021C01B; Sun, 10 Jan 2016 03:26:06 +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 BA95321C015 for ; Sun, 10 Jan 2016 03:26:05 +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 B643E34089F for ; Sun, 10 Jan 2016 03:26:04 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3DDDED25 for ; Sun, 10 Jan 2016 03:26:00 +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: <1452396230.579b15fcc854b1bd10f087af41c9b10ec6e252c1.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/use/, pym/repoman/, pym/repoman/checks/ebuilds/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/checks/ebuilds/use_flags.py pym/repoman/modules/scan/use/__init__.py pym/repoman/modules/scan/use/use_flags.py pym/repoman/scanner.py X-VCS-Directories: pym/repoman/modules/scan/use/ pym/repoman/ pym/repoman/checks/ebuilds/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 579b15fcc854b1bd10f087af41c9b10ec6e252c1 X-VCS-Branch: repoman Date: Sun, 10 Jan 2016 03:26:00 +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: 57b678d3-c37b-49d2-82e5-3096416e2207 X-Archives-Hash: aafc529d7a87846fd27266a6bdd30085 commit: 579b15fcc854b1bd10f087af41c9b10ec6e252c1 Author: Brian Dolbec gentoo org> AuthorDate: Fri Jan 8 01:37:39 2016 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Sun Jan 10 03:23:50 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=579b15fc repoman: Create USEFlagChecks class plugin pym/repoman/modules/scan/use/__init__.py | 23 ++++++++++++++ .../ebuilds => modules/scan/use}/use_flags.py | 36 ++++++++++++++-------- pym/repoman/scanner.py | 8 ++--- 3 files changed, 49 insertions(+), 18 deletions(-) diff --git a/pym/repoman/modules/scan/use/__init__.py b/pym/repoman/modules/scan/use/__init__.py new file mode 100644 index 0000000..e400719 --- /dev/null +++ b/pym/repoman/modules/scan/use/__init__.py @@ -0,0 +1,23 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Use plug-in module for repoman. +Performs use flag checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'use', + 'description': doc, + 'provides':{ + 'use-module': { + 'name': "use_flags", + 'class': "USEFlagChecks", + 'description': doc, + 'functions': ['check', 'getUsedUseFlags'], + 'func_desc': { + }, + }, + } +} + diff --git a/pym/repoman/checks/ebuilds/use_flags.py b/pym/repoman/modules/scan/use/use_flags.py similarity index 74% rename from pym/repoman/checks/ebuilds/use_flags.py rename to pym/repoman/modules/scan/use/use_flags.py index ac21b47..acc7dd3 100644 --- a/pym/repoman/checks/ebuilds/use_flags.py +++ b/pym/repoman/modules/scan/use/use_flags.py @@ -9,31 +9,39 @@ from repoman._portage import portage from portage import eapi from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use +from repoman.modules.scan.scanbase import ScanBase -class USEFlagChecks(object): +class USEFlagChecks(ScanBase): '''Performs checks on USE flags listed in the ebuilds and metadata.xml''' - def __init__(self, qatracker, globalUseFlags): - ''' + def __init__(self, **kwargs): + '''Class init + @param qatracker: QATracker instance @param globalUseFlags: Global USE flags ''' - self.qatracker = qatracker - self.globalUseFlags = globalUseFlags + super(USEFlagChecks, self).__init__(**kwargs) + self.qatracker = kwargs.get('qatracker') + self.globalUseFlags = kwargs.get('uselist') self.useFlags = [] self.defaultUseFlags = [] self.usedUseFlags = set() - def check(self, pkg, package, ebuild, y_ebuild, localUseFlags): + def check(self, **kwargs): '''Perform the check. @param pkg: Package in which we check (object). - @param package: Package in which we check (string). + @param xpkg: Package in which we check (string). @param ebuild: Ebuild which we check (object). @param y_ebuild: Ebuild which we check (string). - @param localUseFlags: Local USE flags of the package + @param muselist: Local USE flags of the package ''' + pkg = kwargs.get('pkg') + package = kwargs.get('xpkg') + ebuild = kwargs.get('ebuild') + y_ebuild = kwargs.get('y_ebuild') + localUseFlags = kwargs.get('muselist') # reset state variables for the run self.useFlags = [] self.defaultUseFlags = [] @@ -41,10 +49,9 @@ class USEFlagChecks(object): self._checkGlobal(pkg) self._checkMetadata(package, ebuild, y_ebuild, localUseFlags) self._checkRequiredUSE(pkg, ebuild) - - def getUsedUseFlags(self): - '''Get the USE flags that this check has seen''' - return self.usedUseFlags + used_useflags = kwargs.get('used_useflags').union(self.usedUseFlags) + return {'continue': False, 'ebuild_UsedUseFlags': self.usedUseFlags, + 'used_useflags': used_useflags} def _checkGlobal(self, pkg): for myflag in pkg._metadata["IUSE"].split(): @@ -88,3 +95,8 @@ class USEFlagChecks(object): "REQUIRED_USE.syntax", "%s: REQUIRED_USE: %s" % (ebuild.relative_path, e)) del e + + @property + def runInEbuilds(self): + '''Ebuild level scans''' + return (True, [self.check]) diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py index 7f770c3..0227a93 100644 --- a/pym/repoman/scanner.py +++ b/pym/repoman/scanner.py @@ -19,7 +19,6 @@ from portage.dep import Atom from portage.output import green from repoman.checks.ebuilds.checks import run_checks from repoman.checks.ebuilds.eclasses.ruby import RubyEclassChecks -from repoman.checks.ebuilds.use_flags import USEFlagChecks from repoman.checks.ebuilds.variables.license import LicenseChecks from repoman.checks.ebuilds.variables.restrict import RestrictChecks from repoman.modules.commit import repochecks @@ -212,7 +211,6 @@ class Scanner(object): self.modules[mod_class.__name__] = mod_class(**self.kwargs) # initialize our checks classes here before the big xpkg loop - self.use_flag_checks = USEFlagChecks(self.qatracker, uselist) self.rubyeclasscheck = RubyEclassChecks(self.qatracker) self.licensecheck = LicenseChecks(self.qatracker, liclist, liclist_deprecated) self.restrictcheck = RestrictChecks(self.qatracker) @@ -300,6 +298,7 @@ class Scanner(object): ('thirdpartymirrors', 'ThirdPartyMirrors'), ('description', 'DescriptionChecks'), (None, 'KeywordChecks'), ('arches', 'ArchChecks'), ('depend', 'DependChecks'), + ('use_flags', 'USEFlagChecks'), ]: if mod[0]: mod_class = MODULE_CONTROLLER.get_class(mod[0]) @@ -362,10 +361,7 @@ class Scanner(object): badlicsyntax = badlicsyntax > 0 badprovsyntax = badprovsyntax > 0 - self.use_flag_checks.check(dynamic_data['pkg'], xpkg, dynamic_data['ebuild'], y_ebuild, dynamic_data['muselist']) - - ebuild_used_useflags = self.use_flag_checks.getUsedUseFlags() - used_useflags = used_useflags.union(ebuild_used_useflags) + used_useflags = used_useflags.union(dynamic_data['ebuild_used_useflags']) self.rubyeclasscheck.check(dynamic_data['pkg'], dynamic_data['ebuild'])