commit: 579b15fcc854b1bd10f087af41c9b10ec6e252c1 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> AuthorDate: Fri Jan 8 01:37:39 2016 +0000 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> 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'])