public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-06  4:21 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-06  4:21 UTC (permalink / raw
  To: gentoo-commits

commit:     a490f6e830d263a9ce055c61bd4e794943204e09
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 21:19:59 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Jan  6 04:08:23 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a490f6e8

repoman: Migrate some additional Dependency code to the plugin

 pym/repoman/modules/scan/depend/depend.py | 13 ++++++++++++-
 pym/repoman/scanner.py                    | 16 +++-------------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
index 8a0ff48..7f1d007 100644
--- a/pym/repoman/modules/scan/depend/depend.py
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -1,3 +1,5 @@
+# -*- coding:utf-8 -*-
+
 
 from _emerge.Package import Package
 
@@ -121,7 +123,16 @@ class DependChecks(object):
 				qacat = m + ".syntax"
 			self.qatracker.add_error(
 				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
-		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+		# data required for some other tests
+		badlicsyntax = len([z for z in type_list if z == "LICENSE"])
+		badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
+		baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+		badlicsyntax = badlicsyntax > 0
+		#badprovsyntax = badprovsyntax > 0
+
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list,
+			'badlicsyntax': badlicsyntax, 'baddepsyntax': baddepsyntax}
 
 	@property
 	def runInPkgs(self):

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index 11f7d93..2b0a748 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -331,21 +331,11 @@ class Scanner(object):
 
 			print("**** finished plugin loop, continuing...")
 
-			baddepsyntax = False
-			badlicsyntax = False
-			badprovsyntax = False
-			# catpkg = catdir + "/" + y_ebuild
-
-			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
-			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
-			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
-			badlicsyntax = badlicsyntax > 0
-			badprovsyntax = badprovsyntax > 0
 
 			used_useflags = used_useflags.union(dynamic_data['ebuild_UsedUseFlags'])
 
 			# license checks
-			if not badlicsyntax:
+			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)
@@ -451,7 +441,7 @@ class Scanner(object):
 				dep_settings.usemask = dep_settings._use_manager.getUseMask(
 					dynamic_data['pkg'], stable=dep_settings._parent_stable)
 
-				if not baddepsyntax:
+				if not dynamic_data['baddepsyntax']:
 					ismasked = not dynamic_data['ebuild'].archs or \
 						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
 						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
@@ -541,7 +531,7 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and dynamic_data['unknown_pkgs']:
+			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-06  4:21 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-06  4:21 UTC (permalink / raw
  To: gentoo-commits

commit:     cf9dee2a64b425a088979f4c23fb03c50c5dc136
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 07:57:36 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Jan  6 04:08:24 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cf9dee2a

repoman: Move the large depency checks loop to a new plugin ProfileDependsChecks class

 pym/repoman/modules/scan/depend/__init__.py |   8 ++
 pym/repoman/modules/scan/depend/profile.py  | 211 ++++++++++++++++++++++++++++
 pym/repoman/repos.py                        |   1 +
 pym/repoman/scanner.py                      | 179 +----------------------
 4 files changed, 226 insertions(+), 173 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index 73d3f8f..2dac94b 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -18,6 +18,14 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'profile-module': {
+			'name': "profile",
+			'class': "ProfileDependsChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/profile.py b/pym/repoman/modules/scan/depend/profile.py
new file mode 100644
index 0000000..91c52cc
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/profile.py
@@ -0,0 +1,211 @@
+# -*- coding:utf-8 -*-
+
+
+import copy
+from pprint import pformat
+
+from _emerge.Package import Package
+
+# import our initialized portage instance
+from repoman._portage import portage
+from portage.dep import Atom
+
+
+def sort_key(item):
+	return item[2].sub_path
+
+
+class ProfileDependsChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+		self.profiles = kwargs.get('profiles')
+		self.options = kwargs.get('options')
+		self.repo_settings = kwargs.get('repo_settings')
+		self.include_arches = kwargs.get('include_arches')
+		self.caches = kwargs.get('caches')
+		self.repoman_incrementals = kwargs.get('repoman_incrementals')
+		self.env = kwargs.get('env')
+		self.have = kwargs.get('have')
+		self.dev_keywords = kwargs.get('dev_keywords')
+
+	def check(self, **kwargs):
+		arches = kwargs.get('arches')
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		relevant_profiles = []
+		for keyword, arch, groups in arches:
+			if arch not in self.profiles:
+				# A missing profile will create an error further down
+				# during the KEYWORDS verification.
+				continue
+
+			if self.include_arches is not None:
+				if arch not in self.include_arches:
+					continue
+
+			relevant_profiles.extend(
+				(keyword, groups, prof) for prof in self.profiles[arch])
+
+		relevant_profiles.sort(key=sort_key)
+
+		for keyword, groups, prof in relevant_profiles:
+
+			is_stable_profile = prof.status == "stable"
+			is_dev_profile = prof.status == "dev" and \
+				self.options.include_dev
+			is_exp_profile = prof.status == "exp" and \
+				self.options.include_exp_profiles == 'y'
+			if not (is_stable_profile or is_dev_profile or is_exp_profile):
+				continue
+
+			dep_settings = self.caches['arch'].get(prof.sub_path)
+			if dep_settings is None:
+				dep_settings = portage.config(
+					config_profile_path=prof.abs_path,
+					config_incrementals=self.repoman_incrementals,
+					config_root=self.repo_settings.config_root,
+					local_config=False,
+					_unmatched_removal=self.options.unmatched_removal,
+					env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
+				dep_settings.categories = self.repo_settings.repoman_settings.categories
+				if self.options.without_mask:
+					dep_settings._mask_manager_obj = \
+						copy.deepcopy(dep_settings._mask_manager)
+					dep_settings._mask_manager._pmaskdict.clear()
+				self.caches['arch'][prof.sub_path] = dep_settings
+
+			xmatch_cache_key = (prof.sub_path, tuple(groups))
+			xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
+			if xcache is None:
+				self.portdb.melt()
+				self.portdb.freeze()
+				xcache = self.portdb.xcache
+				xcache.update(self.caches['shared_xmatch'])
+				self.caches['arch_xmatch'][xmatch_cache_key] = xcache
+
+			self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
+			self.portdb.settings = dep_settings
+			self.portdb.xcache = xcache
+
+			dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
+			# just in case, prevent config.reset() from nuking these.
+			dep_settings.backup_changes("ACCEPT_KEYWORDS")
+
+			# This attribute is used in dbapi._match_use() to apply
+			# use.stable.{mask,force} settings based on the stable
+			# status of the parent package. This is required in order
+			# for USE deps of unstable packages to be resolved correctly,
+			# since otherwise use.stable.{mask,force} settings of
+			# dependencies may conflict (see bug #456342).
+			dep_settings._parent_stable = dep_settings._isStable(pkg)
+
+			# Handle package.use*.{force,mask) calculation, for use
+			# in dep_check.
+			dep_settings.useforce = dep_settings._use_manager.getUseForce(
+				pkg, stable=dep_settings._parent_stable)
+			dep_settings.usemask = dep_settings._use_manager.getUseMask(
+				pkg, stable=dep_settings._parent_stable)
+
+			if not baddepsyntax:
+				ismasked = not ebuild.archs or \
+					pkg.cpv not in self.portdb.xmatch("match-visible",
+					Atom("%s::%s" % (pkg.cp, self.repo_settings.repo_config.name)))
+				if ismasked:
+					if not self.have['pmasked']:
+						self.have['pmasked'] = bool(dep_settings._getMaskAtom(
+							pkg.cpv, ebuild.metadata))
+					if self.options.ignore_masked:
+						continue
+					# we are testing deps for a masked package; give it some lee-way
+					suffix = "masked"
+					matchmode = "minimum-all-ignore-profile"
+				else:
+					suffix = ""
+					matchmode = "minimum-visible"
+
+				if not self.have['dev_keywords']:
+					self.have['dev_keywords'] = \
+						bool(self.dev_keywords.intersection(ebuild.keywords))
+
+				if prof.status == "dev":
+					suffix = suffix + "indev"
+
+				for mytype in Package._dep_keys:
+
+					mykey = "dependency.bad" + suffix
+					myvalue = ebuild.metadata[mytype]
+					if not myvalue:
+						continue
+
+					success, atoms = portage.dep_check(
+						myvalue, self.portdb, dep_settings,
+						use="all", mode=matchmode, trees=self.repo_settings.trees)
+
+					if success:
+						if atoms:
+
+							# Don't bother with dependency.unknown for
+							# cases in which *DEPEND.bad is triggered.
+							for atom in atoms:
+								# dep_check returns all blockers and they
+								# aren't counted for *DEPEND.bad, so we
+								# ignore them here.
+								if not atom.blocker:
+									unknown_pkgs.discard(
+										(mytype, atom.unevaluated_atom))
+
+							if not prof.sub_path:
+								# old-style virtuals currently aren't
+								# resolvable with empty profile, since
+								# 'virtuals' mappings are unavailable
+								# (it would be expensive to search
+								# for PROVIDE in all ebuilds)
+								atoms = [
+									atom for atom in atoms if not (
+										atom.cp.startswith('virtual/')
+										and not self.portdb.cp_list(atom.cp))]
+
+							# we have some unsolvable deps
+							# remove ! deps, which always show up as unsatisfiable
+							atoms = [
+								str(atom.unevaluated_atom)
+								for atom in atoms if not atom.blocker]
+
+							# if we emptied out our list, continue:
+							if not atoms:
+								continue
+							if self.options.output_style in ['column']:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s) %s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, repr(atoms)))
+							else:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s)\n%s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, pformat(atoms, indent=6)))
+					else:
+						if self.options.output_style in ['column']:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s) %s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, repr(atoms)))
+						else:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s)\n%s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, pformat(atoms, indent=6)))
+		return {'continue': False}
+
+	@property
+	def runInPkgs(self):
+		return (False, [])
+
+	@property
+	def runInEbuilds(self):
+		return (True, [self.check])

diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py
index a34f785..39f53c1 100644
--- a/pym/repoman/repos.py
+++ b/pym/repoman/repos.py
@@ -28,6 +28,7 @@ class RepoSettings(object):
 		self, config_root, portdir, portdir_overlay,
 		repoman_settings=None, vcs_settings=None, options=None,
 		qawarnings=None):
+		self.config_root = config_root
 		self.repoman_settings = repoman_settings
 		self.vcs_settings = vcs_settings
 

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index 809b8db..680d07a 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -2,17 +2,12 @@
 
 from __future__ import print_function, unicode_literals
 
-import copy
 import logging
 from itertools import chain
-from pprint import pformat
-
-from _emerge.Package import Package
 
 import portage
 from portage import normalize_path
 from portage import os
-from portage.dep import Atom
 from portage.output import green
 from repoman.modules.commit import repochecks
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
@@ -33,10 +28,6 @@ MODULE_CONTROLLER = Modules(path=MODULES_PATH, namepath="repoman.modules.scan")
 MODULE_NAMES = MODULE_CONTROLLER.module_names[:]
 
 
-def sort_key(item):
-	return item[2].sub_path
-
-
 class Scanner(object):
 	'''Primary scan class.  Operates all the small Q/A tests and checks'''
 
@@ -194,6 +185,12 @@ class Scanner(object):
 			"checks": self.checks,
 			"repo_metadata": self.repo_metadata,
 			"profiles": self.profiles,
+			"include_arches": self.include_arches,
+			"caches": self.caches,
+			"repoman_incrementals": self.repoman_incrementals,
+			"env": self.env,
+			"have": self.have,
+			"dev_keywords": self.dev_keywords,
 		}
 		# initialize the plugin checks here
 		self.modules = {}
@@ -324,170 +321,6 @@ class Scanner(object):
 
 			print("**** finished plugin loop, continuing...")
 
-			relevant_profiles = []
-			for keyword, arch, groups in dynamic_data['arches']:
-				if arch not in self.profiles:
-					# A missing profile will create an error further down
-					# during the KEYWORDS verification.
-					continue
-
-				if self.include_arches is not None:
-					if arch not in self.include_arches:
-						continue
-
-				relevant_profiles.extend(
-					(keyword, groups, prof) for prof in self.profiles[arch])
-
-			relevant_profiles.sort(key=sort_key)
-
-			for keyword, groups, prof in relevant_profiles:
-
-				is_stable_profile = prof.status == "stable"
-				is_dev_profile = prof.status == "dev" and \
-					self.options.include_dev
-				is_exp_profile = prof.status == "exp" and \
-					self.options.include_exp_profiles == 'y'
-				if not (is_stable_profile or is_dev_profile or is_exp_profile):
-					continue
-
-				dep_settings = self.caches['arch'].get(prof.sub_path)
-				if dep_settings is None:
-					dep_settings = portage.config(
-						config_profile_path=prof.abs_path,
-						config_incrementals=self.repoman_incrementals,
-						config_root=self.config_root,
-						local_config=False,
-						_unmatched_removal=self.options.unmatched_removal,
-						env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
-					dep_settings.categories = self.repo_settings.repoman_settings.categories
-					if self.options.without_mask:
-						dep_settings._mask_manager_obj = \
-							copy.deepcopy(dep_settings._mask_manager)
-						dep_settings._mask_manager._pmaskdict.clear()
-					self.caches['arch'][prof.sub_path] = dep_settings
-
-				xmatch_cache_key = (prof.sub_path, tuple(groups))
-				xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
-				if xcache is None:
-					self.portdb.melt()
-					self.portdb.freeze()
-					xcache = self.portdb.xcache
-					xcache.update(self.caches['shared_xmatch'])
-					self.caches['arch_xmatch'][xmatch_cache_key] = xcache
-
-				self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
-				self.portdb.settings = dep_settings
-				self.portdb.xcache = xcache
-
-				dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
-				# just in case, prevent config.reset() from nuking these.
-				dep_settings.backup_changes("ACCEPT_KEYWORDS")
-
-				# This attribute is used in dbapi._match_use() to apply
-				# use.stable.{mask,force} settings based on the stable
-				# status of the parent package. This is required in order
-				# for USE deps of unstable packages to be resolved correctly,
-				# since otherwise use.stable.{mask,force} settings of
-				# dependencies may conflict (see bug #456342).
-				dep_settings._parent_stable = dep_settings._isStable(dynamic_data['pkg'])
-
-				# Handle package.use*.{force,mask) calculation, for use
-				# in dep_check.
-				dep_settings.useforce = dep_settings._use_manager.getUseForce(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-				dep_settings.usemask = dep_settings._use_manager.getUseMask(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-
-				if not dynamic_data['baddepsyntax']:
-					ismasked = not dynamic_data['ebuild'].archs or \
-						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
-						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
-					if ismasked:
-						if not self.have['pmasked']:
-							self.have['pmasked'] = bool(dep_settings._getMaskAtom(
-								dynamic_data['pkg'].cpv, dynamic_data['pkg']._metadata))
-						if self.options.ignore_masked:
-							continue
-						# we are testing deps for a masked package; give it some lee-way
-						suffix = "masked"
-						matchmode = "minimum-all-ignore-profile"
-					else:
-						suffix = ""
-						matchmode = "minimum-visible"
-
-					if not self.have['dev_keywords']:
-						self.have['dev_keywords'] = \
-							bool(self.dev_keywords.intersection(dynamic_data['ebuild'].keywords))
-
-					if prof.status == "dev":
-						suffix = suffix + "indev"
-
-					for mytype in Package._dep_keys:
-
-						mykey = "dependency.bad" + suffix
-						myvalue = dynamic_data['ebuild'].metadata[mytype]
-						if not myvalue:
-							continue
-
-						success, atoms = portage.dep_check(
-							myvalue, self.portdb, dep_settings,
-							use="all", mode=matchmode, trees=self.repo_settings.trees)
-
-						if success:
-							if atoms:
-
-								# Don't bother with dependency.unknown for
-								# cases in which *DEPEND.bad is triggered.
-								for atom in atoms:
-									# dep_check returns all blockers and they
-									# aren't counted for *DEPEND.bad, so we
-									# ignore them here.
-									if not atom.blocker:
-										dynamic_data['unknown_pkgs'].discard(
-											(mytype, atom.unevaluated_atom))
-
-								if not prof.sub_path:
-									# old-style virtuals currently aren't
-									# resolvable with empty profile, since
-									# 'virtuals' mappings are unavailable
-									# (it would be expensive to search
-									# for PROVIDE in all ebuilds)
-									atoms = [
-										atom for atom in atoms if not (
-											atom.cp.startswith('virtual/')
-											and not self.portdb.cp_list(atom.cp))]
-
-								# we have some unsolvable deps
-								# remove ! deps, which always show up as unsatisfiable
-								atoms = [
-									str(atom.unevaluated_atom)
-									for atom in atoms if not atom.blocker]
-
-								# if we emptied out our list, continue:
-								if not atoms:
-									continue
-								if self.options.output_style in ['column']:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s) %s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, repr(atoms)))
-								else:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s)\n%s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, pformat(atoms, indent=6)))
-						else:
-							if self.options.output_style in ['column']:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s) %s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, repr(atoms)))
-							else:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s)\n%s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, pformat(atoms, indent=6)))
-
 			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-06  4:21 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-06  4:21 UTC (permalink / raw
  To: gentoo-commits

commit:     a272720a9d0df791945c84d4411c9f6d66fa6162
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 08:09:33 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Jan  6 04:08:24 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a272720a

repoman: Create a new DependUnknown plugin class

 pym/repoman/modules/scan/depend/__init__.py |  8 ++++++++
 pym/repoman/modules/scan/depend/unknown.py  | 30 +++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 10 +---------
 3 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index 2dac94b..65555b4 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -26,6 +26,14 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'unknown-module': {
+			'name': "unknown",
+			'class': "DependUnknown",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py
new file mode 100644
index 0000000..61d51b9
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/unknown.py
@@ -0,0 +1,30 @@
+# -*- coding:utf-8 -*-
+
+
+class DependUnknown(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		if not baddepsyntax and unknown_pkgs:
+			type_map = {}
+			for mytype, atom in unknown_pkgs:
+				type_map.setdefault(mytype, set()).add(atom)
+			for mytype, atoms in type_map.items():
+				self.qatracker.add_error(
+					"dependency.unknown", "%s: %s: %s"
+					% (ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
+		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 680d07a..08e53ac 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -291,6 +291,7 @@ class Scanner(object):
 				('mtime', 'MtimeChecks'), ('encoding', 'EncodingCheck'),
 				# Options.is_forced() is used to bypass further checks
 				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
+				('unknown', 'DependUnknown'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -321,15 +322,6 @@ class Scanner(object):
 
 			print("**** finished plugin loop, continuing...")
 
-			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
-				type_map = {}
-				for mytype, atom in dynamic_data['unknown_pkgs']:
-					type_map.setdefault(mytype, set()).add(atom)
-				for mytype, atoms in type_map.items():
-					self.qatracker.add_error(
-						"dependency.unknown", "%s: %s: %s"
-						% (dynamic_data['ebuild'].relative_path, mytype, ", ".join(sorted(atoms))))
-
 		# check if there are unused local USE-descriptions in metadata.xml
 		# (unless there are any invalids, to avoid noise)
 		if dynamic_data['allvalid']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-10  3:26 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-10  3:26 UTC (permalink / raw
  To: gentoo-commits

commit:     cf6693c8e27b4b540076821d97c6dadaea697e76
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 20:38:11 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=cf6693c8

repoman: New DependChecks plugin

Migrate code from _scan_ebuilds to the plugin system

 pym/repoman/modules/scan/depend/__init__.py |  23 +++++
 pym/repoman/modules/scan/depend/depend.py   | 132 ++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 119 ++-----------------------
 3 files changed, 162 insertions(+), 112 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
new file mode 100644
index 0000000..73d3f8f
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -0,0 +1,23 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Depend plug-in module for repoman.
+Performs Dependency checks on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+	'name': 'depend',
+	'description': doc,
+	'provides':{
+		'depend-module': {
+			'name': "depend",
+			'class': "DependChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
+	}
+}
+

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
new file mode 100644
index 0000000..8a0ff48
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -0,0 +1,132 @@
+
+from _emerge.Package import Package
+
+from repoman.check_missingslot import check_missingslot
+# import our initialized portage instance
+from repoman._portage import portage
+from repoman.qa_data import suspect_virtual, suspect_rdepend
+
+
+class DependChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+
+		unknown_pkgs = set()
+
+		inherited_java_eclass = "java-pkg-2" in ebuild.inherited or \
+			"java-pkg-opt-2" in ebuild.inherited,
+		inherited_wxwidgets_eclass = "wxwidgets" in ebuild.inherited
+		# operator_tokens = set(["||", "(", ")"])
+		type_list, badsyntax = [], []
+		for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
+			mydepstr = ebuild.metadata[mytype]
+
+			buildtime = mytype in Package._buildtime_keys
+			runtime = mytype in Package._runtime_keys
+			token_class = None
+			if mytype.endswith("DEPEND"):
+				token_class = portage.dep.Atom
+
+			try:
+				atoms = portage.dep.use_reduce(
+					mydepstr, matchall=1, flat=True,
+					is_valid_flag=pkg.iuse.is_valid_flag, token_class=token_class)
+			except portage.exception.InvalidDependString as e:
+				atoms = None
+				badsyntax.append(str(e))
+
+			if atoms and mytype.endswith("DEPEND"):
+				if runtime and \
+					"test?" in mydepstr.split():
+					self.qatracker.add_error(
+						mytype + '.suspect',
+						"%s: 'test?' USE conditional in %s" %
+						(ebuild.relative_path, mytype))
+
+				for atom in atoms:
+					if atom == "||":
+						continue
+
+					is_blocker = atom.blocker
+
+					# Skip dependency.unknown for blockers, so that we
+					# don't encourage people to remove necessary blockers,
+					# as discussed in bug 382407. We use atom.without_use
+					# due to bug 525376.
+					if not is_blocker and \
+						not self.portdb.xmatch("match-all", atom.without_use) and \
+						not atom.cp.startswith("virtual/"):
+						unknown_pkgs.add((mytype, atom.unevaluated_atom))
+
+					if kwargs.get('catdir') != "virtual":
+						if not is_blocker and \
+							atom.cp in suspect_virtual:
+							self.qatracker.add_error(
+								'virtual.suspect', ebuild.relative_path +
+								": %s: consider using '%s' instead of '%s'" %
+								(mytype, suspect_virtual[atom.cp], atom))
+						if not is_blocker and \
+							atom.cp.startswith("perl-core/"):
+							self.qatracker.add_error('dependency.perlcore',
+								ebuild.relative_path +
+								": %s: please use '%s' instead of '%s'" %
+								(mytype,
+								atom.replace("perl-core/","virtual/perl-"),
+								atom))
+
+					if buildtime and \
+						not is_blocker and \
+						not inherited_java_eclass and \
+						atom.cp == "virtual/jdk":
+						self.qatracker.add_error(
+							'java.eclassesnotused', ebuild.relative_path)
+					elif buildtime and \
+						not is_blocker and \
+						not inherited_wxwidgets_eclass and \
+						atom.cp == "x11-libs/wxGTK":
+						self.qatracker.add_error(
+							'wxwidgets.eclassnotused',
+							"%s: %ss on x11-libs/wxGTK without inheriting"
+							" wxwidgets.eclass" % (ebuild.relative_path, mytype))
+					elif runtime:
+						if not is_blocker and \
+							atom.cp in suspect_rdepend:
+							self.qatracker.add_error(
+								mytype + '.suspect',
+								ebuild.relative_path + ": '%s'" % atom)
+
+					if atom.operator == "~" and \
+						portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
+						qacat = 'dependency.badtilde'
+						self.qatracker.add_error(
+							qacat, "%s: %s uses the ~ operator"
+							" with a non-zero revision: '%s'" %
+							(ebuild.relative_path, mytype, atom))
+
+					check_missingslot(atom, mytype, ebuild.eapi, self.portdb, self.qatracker,
+						ebuild.relative_path, ebuild.metadata)
+
+			type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
+
+		for m, b in zip(type_list, badsyntax):
+			if m.endswith("DEPEND"):
+				qacat = "dependency.syntax"
+			else:
+				qacat = m + ".syntax"
+			self.qatracker.add_error(
+				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+	@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 7b07a95..7f770c3 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -19,13 +19,11 @@ 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.check_missingslot import check_missingslot
 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
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
-from repoman.qa_data import missingvars, suspect_virtual, suspect_rdepend
 from repoman.repos import repo_metadata
 from repoman.modules.scan.scan import scan
 from repoman.modules.vcs.vcs import vcs_files_to_cps
@@ -301,7 +299,7 @@ class Scanner(object):
 				('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
 				('thirdpartymirrors', 'ThirdPartyMirrors'),
 				('description', 'DescriptionChecks'), (None, 'KeywordChecks'),
-				('arches', 'ArchChecks'),
+				('arches', 'ArchChecks'), ('depend', 'DependChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -358,112 +356,9 @@ class Scanner(object):
 			badprovsyntax = False
 			# catpkg = catdir + "/" + y_ebuild
 
-			inherited_java_eclass = "java-pkg-2" in dynamic_data['ebuild'].inherited or \
-				"java-pkg-opt-2" in dynamic_data['ebuild'].inherited,
-			inherited_wxwidgets_eclass = "wxwidgets" in dynamic_data['ebuild'].inherited
-			# operator_tokens = set(["||", "(", ")"])
-			type_list, badsyntax = [], []
-			for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
-				mydepstr = dynamic_data['ebuild'].metadata[mytype]
-
-				buildtime = mytype in Package._buildtime_keys
-				runtime = mytype in Package._runtime_keys
-				token_class = None
-				if mytype.endswith("DEPEND"):
-					token_class = portage.dep.Atom
-
-				try:
-					atoms = portage.dep.use_reduce(
-						mydepstr, matchall=1, flat=True,
-						is_valid_flag=dynamic_data['pkg'].iuse.is_valid_flag, token_class=token_class)
-				except portage.exception.InvalidDependString as e:
-					atoms = None
-					badsyntax.append(str(e))
-
-				if atoms and mytype.endswith("DEPEND"):
-					if runtime and \
-						"test?" in mydepstr.split():
-						self.qatracker.add_error(
-							mytype + '.suspect',
-							"%s: 'test?' USE conditional in %s" %
-							(dynamic_data['ebuild'].relative_path, mytype))
-
-					for atom in atoms:
-						if atom == "||":
-							continue
-
-						is_blocker = atom.blocker
-
-						# Skip dependency.unknown for blockers, so that we
-						# don't encourage people to remove necessary blockers,
-						# as discussed in bug 382407. We use atom.without_use
-						# due to bug 525376.
-						if not is_blocker and \
-							not self.portdb.xmatch("match-all", atom.without_use) and \
-							not atom.cp.startswith("virtual/"):
-							unknown_pkgs.add((mytype, atom.unevaluated_atom))
-
-						if dynamic_data['catdir'] != "virtual":
-							if not is_blocker and \
-								atom.cp in suspect_virtual:
-								self.qatracker.add_error(
-									'virtual.suspect', dynamic_data['ebuild'].relative_path +
-									": %s: consider using '%s' instead of '%s'" %
-									(mytype, suspect_virtual[atom.cp], atom))
-							if not is_blocker and \
-								atom.cp.startswith("perl-core/"):
-								self.qatracker.add_error('dependency.perlcore',
-									dynamic_data['ebuild'].relative_path +
-									": %s: please use '%s' instead of '%s'" %
-									(mytype,
-									atom.replace("perl-core/","virtual/perl-"),
-									atom))
-
-						if buildtime and \
-							not is_blocker and \
-							not inherited_java_eclass and \
-							atom.cp == "virtual/jdk":
-							self.qatracker.add_error(
-								'java.eclassesnotused', dynamic_data['ebuild'].relative_path)
-						elif buildtime and \
-							not is_blocker and \
-							not inherited_wxwidgets_eclass and \
-							atom.cp == "x11-libs/wxGTK":
-							self.qatracker.add_error(
-								'wxwidgets.eclassnotused',
-								"%s: %ss on x11-libs/wxGTK without inheriting"
-								" wxwidgets.eclass" % (dynamic_data['ebuild'].relative_path, mytype))
-						elif runtime:
-							if not is_blocker and \
-								atom.cp in suspect_rdepend:
-								self.qatracker.add_error(
-									mytype + '.suspect',
-									dynamic_data['ebuild'].relative_path + ": '%s'" % atom)
-
-						if atom.operator == "~" and \
-							portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
-							qacat = 'dependency.badtilde'
-							self.qatracker.add_error(
-								qacat, "%s: %s uses the ~ operator"
-								" with a non-zero revision: '%s'" %
-								(dynamic_data['ebuild'].relative_path, mytype, atom))
-
-						check_missingslot(atom, mytype, dynamic_data['ebuild'].eapi, self.portdb, self.qatracker,
-							dynamic_data['ebuild'].relative_path, dynamic_data['ebuild'].metadata)
-
-				type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
-
-			for m, b in zip(type_list, badsyntax):
-				if m.endswith("DEPEND"):
-					qacat = "dependency.syntax"
-				else:
-					qacat = m + ".syntax"
-				self.qatracker.add_error(
-					qacat, "%s: %s: %s" % (dynamic_data['ebuild'].relative_path, m, b))
-
-			badlicsyntax = len([z for z in type_list if z == "LICENSE"])
-			badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
-			baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
+			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
+			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
 			badlicsyntax = badlicsyntax > 0
 			badprovsyntax = badprovsyntax > 0
 
@@ -626,7 +521,7 @@ class Scanner(object):
 									# aren't counted for *DEPEND.bad, so we
 									# ignore them here.
 									if not atom.blocker:
-										unknown_pkgs.discard(
+										dynamic_data['unknown_pkgs'].discard(
 											(mytype, atom.unevaluated_atom))
 
 								if not prof.sub_path:
@@ -671,9 +566,9 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and unknown_pkgs:
+			if not baddepsyntax and dynamic_data['unknown_pkgs']:
 				type_map = {}
-				for mytype, atom in unknown_pkgs:
+				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)
 				for mytype, atoms in type_map.items():
 					self.qatracker.add_error(


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-10  3:26 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-10  3:26 UTC (permalink / raw
  To: gentoo-commits

commit:     89295567960c110468afb5b972583b4c56f7180a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 21:19:59 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Jan 10 03:23:51 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=89295567

repoman: Migrate some additional Dependency code to the plugin

 pym/repoman/modules/scan/depend/depend.py | 13 ++++++++++++-
 pym/repoman/scanner.py                    | 22 +++-------------------
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
index 8a0ff48..7f1d007 100644
--- a/pym/repoman/modules/scan/depend/depend.py
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -1,3 +1,5 @@
+# -*- coding:utf-8 -*-
+
 
 from _emerge.Package import Package
 
@@ -121,7 +123,16 @@ class DependChecks(object):
 				qacat = m + ".syntax"
 			self.qatracker.add_error(
 				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
-		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+		# data required for some other tests
+		badlicsyntax = len([z for z in type_list if z == "LICENSE"])
+		badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
+		baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+		badlicsyntax = badlicsyntax > 0
+		#badprovsyntax = badprovsyntax > 0
+
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list,
+			'badlicsyntax': badlicsyntax, 'baddepsyntax': baddepsyntax}
 
 	@property
 	def runInPkgs(self):

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index d42fd33..6d5416b 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -324,26 +324,10 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if dynamic_data['live_ebuild'] and self.repo_settings.repo_config.name == "gentoo":
-				self.liveeclasscheck.check(
-					dynamic_data['pkg'], xpkg, dynamic_data['ebuild'], y_ebuild, dynamic_data['ebuild'].keywords, self.repo_metadata['pmaskdict'])
-
-			unknown_pkgs = set()
-			baddepsyntax = False
-			badlicsyntax = False
-			badprovsyntax = False
-			# catpkg = catdir + "/" + y_ebuild
-
-			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
-			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
-			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
-			badlicsyntax = badlicsyntax > 0
-			badprovsyntax = badprovsyntax > 0
-
 			used_useflags = used_useflags.union(dynamic_data['ebuild_UsedUseFlags'])
 
 			# license checks
-			if not badlicsyntax:
+			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)
@@ -449,7 +433,7 @@ class Scanner(object):
 				dep_settings.usemask = dep_settings._use_manager.getUseMask(
 					dynamic_data['pkg'], stable=dep_settings._parent_stable)
 
-				if not baddepsyntax:
+				if not dynamic_data['baddepsyntax']:
 					ismasked = not dynamic_data['ebuild'].archs or \
 						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
 						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
@@ -539,7 +523,7 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and dynamic_data['unknown_pkgs']:
+			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-10  3:26 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-10  3:26 UTC (permalink / raw
  To: gentoo-commits

commit:     a4a0bd1b60818e3099ef835324d13e93c1d7de37
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 07:57:36 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Jan 10 03:23:52 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a4a0bd1b

repoman: Move the large depency checks loop to a new plugin ProfileDependsChecks class

 pym/repoman/modules/scan/depend/__init__.py |   8 ++
 pym/repoman/modules/scan/depend/profile.py  | 211 ++++++++++++++++++++++++++++
 pym/repoman/repos.py                        |   1 +
 pym/repoman/scanner.py                      | 181 +-----------------------
 4 files changed, 227 insertions(+), 174 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index 73d3f8f..2dac94b 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -18,6 +18,14 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'profile-module': {
+			'name': "profile",
+			'class': "ProfileDependsChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/profile.py b/pym/repoman/modules/scan/depend/profile.py
new file mode 100644
index 0000000..91c52cc
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/profile.py
@@ -0,0 +1,211 @@
+# -*- coding:utf-8 -*-
+
+
+import copy
+from pprint import pformat
+
+from _emerge.Package import Package
+
+# import our initialized portage instance
+from repoman._portage import portage
+from portage.dep import Atom
+
+
+def sort_key(item):
+	return item[2].sub_path
+
+
+class ProfileDependsChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+		self.profiles = kwargs.get('profiles')
+		self.options = kwargs.get('options')
+		self.repo_settings = kwargs.get('repo_settings')
+		self.include_arches = kwargs.get('include_arches')
+		self.caches = kwargs.get('caches')
+		self.repoman_incrementals = kwargs.get('repoman_incrementals')
+		self.env = kwargs.get('env')
+		self.have = kwargs.get('have')
+		self.dev_keywords = kwargs.get('dev_keywords')
+
+	def check(self, **kwargs):
+		arches = kwargs.get('arches')
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		relevant_profiles = []
+		for keyword, arch, groups in arches:
+			if arch not in self.profiles:
+				# A missing profile will create an error further down
+				# during the KEYWORDS verification.
+				continue
+
+			if self.include_arches is not None:
+				if arch not in self.include_arches:
+					continue
+
+			relevant_profiles.extend(
+				(keyword, groups, prof) for prof in self.profiles[arch])
+
+		relevant_profiles.sort(key=sort_key)
+
+		for keyword, groups, prof in relevant_profiles:
+
+			is_stable_profile = prof.status == "stable"
+			is_dev_profile = prof.status == "dev" and \
+				self.options.include_dev
+			is_exp_profile = prof.status == "exp" and \
+				self.options.include_exp_profiles == 'y'
+			if not (is_stable_profile or is_dev_profile or is_exp_profile):
+				continue
+
+			dep_settings = self.caches['arch'].get(prof.sub_path)
+			if dep_settings is None:
+				dep_settings = portage.config(
+					config_profile_path=prof.abs_path,
+					config_incrementals=self.repoman_incrementals,
+					config_root=self.repo_settings.config_root,
+					local_config=False,
+					_unmatched_removal=self.options.unmatched_removal,
+					env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
+				dep_settings.categories = self.repo_settings.repoman_settings.categories
+				if self.options.without_mask:
+					dep_settings._mask_manager_obj = \
+						copy.deepcopy(dep_settings._mask_manager)
+					dep_settings._mask_manager._pmaskdict.clear()
+				self.caches['arch'][prof.sub_path] = dep_settings
+
+			xmatch_cache_key = (prof.sub_path, tuple(groups))
+			xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
+			if xcache is None:
+				self.portdb.melt()
+				self.portdb.freeze()
+				xcache = self.portdb.xcache
+				xcache.update(self.caches['shared_xmatch'])
+				self.caches['arch_xmatch'][xmatch_cache_key] = xcache
+
+			self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
+			self.portdb.settings = dep_settings
+			self.portdb.xcache = xcache
+
+			dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
+			# just in case, prevent config.reset() from nuking these.
+			dep_settings.backup_changes("ACCEPT_KEYWORDS")
+
+			# This attribute is used in dbapi._match_use() to apply
+			# use.stable.{mask,force} settings based on the stable
+			# status of the parent package. This is required in order
+			# for USE deps of unstable packages to be resolved correctly,
+			# since otherwise use.stable.{mask,force} settings of
+			# dependencies may conflict (see bug #456342).
+			dep_settings._parent_stable = dep_settings._isStable(pkg)
+
+			# Handle package.use*.{force,mask) calculation, for use
+			# in dep_check.
+			dep_settings.useforce = dep_settings._use_manager.getUseForce(
+				pkg, stable=dep_settings._parent_stable)
+			dep_settings.usemask = dep_settings._use_manager.getUseMask(
+				pkg, stable=dep_settings._parent_stable)
+
+			if not baddepsyntax:
+				ismasked = not ebuild.archs or \
+					pkg.cpv not in self.portdb.xmatch("match-visible",
+					Atom("%s::%s" % (pkg.cp, self.repo_settings.repo_config.name)))
+				if ismasked:
+					if not self.have['pmasked']:
+						self.have['pmasked'] = bool(dep_settings._getMaskAtom(
+							pkg.cpv, ebuild.metadata))
+					if self.options.ignore_masked:
+						continue
+					# we are testing deps for a masked package; give it some lee-way
+					suffix = "masked"
+					matchmode = "minimum-all-ignore-profile"
+				else:
+					suffix = ""
+					matchmode = "minimum-visible"
+
+				if not self.have['dev_keywords']:
+					self.have['dev_keywords'] = \
+						bool(self.dev_keywords.intersection(ebuild.keywords))
+
+				if prof.status == "dev":
+					suffix = suffix + "indev"
+
+				for mytype in Package._dep_keys:
+
+					mykey = "dependency.bad" + suffix
+					myvalue = ebuild.metadata[mytype]
+					if not myvalue:
+						continue
+
+					success, atoms = portage.dep_check(
+						myvalue, self.portdb, dep_settings,
+						use="all", mode=matchmode, trees=self.repo_settings.trees)
+
+					if success:
+						if atoms:
+
+							# Don't bother with dependency.unknown for
+							# cases in which *DEPEND.bad is triggered.
+							for atom in atoms:
+								# dep_check returns all blockers and they
+								# aren't counted for *DEPEND.bad, so we
+								# ignore them here.
+								if not atom.blocker:
+									unknown_pkgs.discard(
+										(mytype, atom.unevaluated_atom))
+
+							if not prof.sub_path:
+								# old-style virtuals currently aren't
+								# resolvable with empty profile, since
+								# 'virtuals' mappings are unavailable
+								# (it would be expensive to search
+								# for PROVIDE in all ebuilds)
+								atoms = [
+									atom for atom in atoms if not (
+										atom.cp.startswith('virtual/')
+										and not self.portdb.cp_list(atom.cp))]
+
+							# we have some unsolvable deps
+							# remove ! deps, which always show up as unsatisfiable
+							atoms = [
+								str(atom.unevaluated_atom)
+								for atom in atoms if not atom.blocker]
+
+							# if we emptied out our list, continue:
+							if not atoms:
+								continue
+							if self.options.output_style in ['column']:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s) %s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, repr(atoms)))
+							else:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s)\n%s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, pformat(atoms, indent=6)))
+					else:
+						if self.options.output_style in ['column']:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s) %s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, repr(atoms)))
+						else:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s)\n%s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, pformat(atoms, indent=6)))
+		return {'continue': False}
+
+	@property
+	def runInPkgs(self):
+		return (False, [])
+
+	@property
+	def runInEbuilds(self):
+		return (True, [self.check])

diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py
index a34f785..39f53c1 100644
--- a/pym/repoman/repos.py
+++ b/pym/repoman/repos.py
@@ -28,6 +28,7 @@ class RepoSettings(object):
 		self, config_root, portdir, portdir_overlay,
 		repoman_settings=None, vcs_settings=None, options=None,
 		qawarnings=None):
+		self.config_root = config_root
 		self.repoman_settings = repoman_settings
 		self.vcs_settings = vcs_settings
 

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index a047237..be971db 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -2,17 +2,12 @@
 
 from __future__ import print_function, unicode_literals
 
-import copy
 import logging
 from itertools import chain
-from pprint import pformat
-
-from _emerge.Package import Package
 
 import portage
 from portage import normalize_path
 from portage import os
-from portage.dep import Atom
 from portage.output import green
 from repoman.modules.commit import repochecks
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
@@ -33,10 +28,6 @@ MODULE_CONTROLLER = Modules(path=MODULES_PATH, namepath="repoman.modules.scan")
 MODULE_NAMES = MODULE_CONTROLLER.module_names[:]
 
 
-def sort_key(item):
-	return item[2].sub_path
-
-
 class Scanner(object):
 	'''Primary scan class.  Operates all the small Q/A tests and checks'''
 
@@ -194,6 +185,12 @@ class Scanner(object):
 			"checks": self.checks,
 			"repo_metadata": self.repo_metadata,
 			"profiles": self.profiles,
+			"include_arches": self.include_arches,
+			"caches": self.caches,
+			"repoman_incrementals": self.repoman_incrementals,
+			"env": self.env,
+			"have": self.have,
+			"dev_keywords": self.dev_keywords,
 		}
 		# initialize the plugin checks here
 		self.modules = {}
@@ -291,7 +288,7 @@ class Scanner(object):
 				('license', 'LicenseChecks'), ('restrict', 'RestrictChecks'),
 				('mtime', 'MtimeChecks'), ('encoding', 'EncodingCheck'),
 				# Options.is_forced() is used to bypass further checks
-				('options', 'Options'),
+				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -319,170 +316,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			relevant_profiles = []
-			for keyword, arch, groups in dynamic_data['arches']:
-				if arch not in self.profiles:
-					# A missing profile will create an error further down
-					# during the KEYWORDS verification.
-					continue
-
-				if self.include_arches is not None:
-					if arch not in self.include_arches:
-						continue
-
-				relevant_profiles.extend(
-					(keyword, groups, prof) for prof in self.profiles[arch])
-
-			relevant_profiles.sort(key=sort_key)
-
-			for keyword, groups, prof in relevant_profiles:
-
-				is_stable_profile = prof.status == "stable"
-				is_dev_profile = prof.status == "dev" and \
-					self.options.include_dev
-				is_exp_profile = prof.status == "exp" and \
-					self.options.include_exp_profiles == 'y'
-				if not (is_stable_profile or is_dev_profile or is_exp_profile):
-					continue
-
-				dep_settings = self.caches['arch'].get(prof.sub_path)
-				if dep_settings is None:
-					dep_settings = portage.config(
-						config_profile_path=prof.abs_path,
-						config_incrementals=self.repoman_incrementals,
-						config_root=self.config_root,
-						local_config=False,
-						_unmatched_removal=self.options.unmatched_removal,
-						env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
-					dep_settings.categories = self.repo_settings.repoman_settings.categories
-					if self.options.without_mask:
-						dep_settings._mask_manager_obj = \
-							copy.deepcopy(dep_settings._mask_manager)
-						dep_settings._mask_manager._pmaskdict.clear()
-					self.caches['arch'][prof.sub_path] = dep_settings
-
-				xmatch_cache_key = (prof.sub_path, tuple(groups))
-				xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
-				if xcache is None:
-					self.portdb.melt()
-					self.portdb.freeze()
-					xcache = self.portdb.xcache
-					xcache.update(self.caches['shared_xmatch'])
-					self.caches['arch_xmatch'][xmatch_cache_key] = xcache
-
-				self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
-				self.portdb.settings = dep_settings
-				self.portdb.xcache = xcache
-
-				dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
-				# just in case, prevent config.reset() from nuking these.
-				dep_settings.backup_changes("ACCEPT_KEYWORDS")
-
-				# This attribute is used in dbapi._match_use() to apply
-				# use.stable.{mask,force} settings based on the stable
-				# status of the parent package. This is required in order
-				# for USE deps of unstable packages to be resolved correctly,
-				# since otherwise use.stable.{mask,force} settings of
-				# dependencies may conflict (see bug #456342).
-				dep_settings._parent_stable = dep_settings._isStable(dynamic_data['pkg'])
-
-				# Handle package.use*.{force,mask) calculation, for use
-				# in dep_check.
-				dep_settings.useforce = dep_settings._use_manager.getUseForce(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-				dep_settings.usemask = dep_settings._use_manager.getUseMask(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-
-				if not dynamic_data['baddepsyntax']:
-					ismasked = not dynamic_data['ebuild'].archs or \
-						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
-						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
-					if ismasked:
-						if not self.have['pmasked']:
-							self.have['pmasked'] = bool(dep_settings._getMaskAtom(
-								dynamic_data['pkg'].cpv, dynamic_data['pkg']._metadata))
-						if self.options.ignore_masked:
-							continue
-						# we are testing deps for a masked package; give it some lee-way
-						suffix = "masked"
-						matchmode = "minimum-all-ignore-profile"
-					else:
-						suffix = ""
-						matchmode = "minimum-visible"
-
-					if not self.have['dev_keywords']:
-						self.have['dev_keywords'] = \
-							bool(self.dev_keywords.intersection(dynamic_data['ebuild'].keywords))
-
-					if prof.status == "dev":
-						suffix = suffix + "indev"
-
-					for mytype in Package._dep_keys:
-
-						mykey = "dependency.bad" + suffix
-						myvalue = dynamic_data['ebuild'].metadata[mytype]
-						if not myvalue:
-							continue
-
-						success, atoms = portage.dep_check(
-							myvalue, self.portdb, dep_settings,
-							use="all", mode=matchmode, trees=self.repo_settings.trees)
-
-						if success:
-							if atoms:
-
-								# Don't bother with dependency.unknown for
-								# cases in which *DEPEND.bad is triggered.
-								for atom in atoms:
-									# dep_check returns all blockers and they
-									# aren't counted for *DEPEND.bad, so we
-									# ignore them here.
-									if not atom.blocker:
-										dynamic_data['unknown_pkgs'].discard(
-											(mytype, atom.unevaluated_atom))
-
-								if not prof.sub_path:
-									# old-style virtuals currently aren't
-									# resolvable with empty profile, since
-									# 'virtuals' mappings are unavailable
-									# (it would be expensive to search
-									# for PROVIDE in all ebuilds)
-									atoms = [
-										atom for atom in atoms if not (
-											atom.cp.startswith('virtual/')
-											and not self.portdb.cp_list(atom.cp))]
-
-								# we have some unsolvable deps
-								# remove ! deps, which always show up as unsatisfiable
-								atoms = [
-									str(atom.unevaluated_atom)
-									for atom in atoms if not atom.blocker]
-
-								# if we emptied out our list, continue:
-								if not atoms:
-									continue
-								if self.options.output_style in ['column']:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s) %s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, repr(atoms)))
-								else:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s)\n%s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, pformat(atoms, indent=6)))
-						else:
-							if self.options.output_style in ['column']:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s) %s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, repr(atoms)))
-							else:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s)\n%s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, pformat(atoms, indent=6)))
-
 			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-10 20:17 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-10 20:17 UTC (permalink / raw
  To: gentoo-commits

commit:     6cd0ec7dfe6cea518416561188b8e3ed6cb4cfa0
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 07:57:36 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Jan 10 20:15:08 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=6cd0ec7d

repoman: Move the large depency checks loop to a new plugin ProfileDependsChecks class

 pym/repoman/modules/scan/depend/__init__.py |   8 ++
 pym/repoman/modules/scan/depend/profile.py  | 211 ++++++++++++++++++++++++++++
 pym/repoman/repos.py                        |   1 +
 pym/repoman/scanner.py                      | 181 +-----------------------
 4 files changed, 227 insertions(+), 174 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index 73d3f8f..2dac94b 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -18,6 +18,14 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'profile-module': {
+			'name': "profile",
+			'class': "ProfileDependsChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/profile.py b/pym/repoman/modules/scan/depend/profile.py
new file mode 100644
index 0000000..91c52cc
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/profile.py
@@ -0,0 +1,211 @@
+# -*- coding:utf-8 -*-
+
+
+import copy
+from pprint import pformat
+
+from _emerge.Package import Package
+
+# import our initialized portage instance
+from repoman._portage import portage
+from portage.dep import Atom
+
+
+def sort_key(item):
+	return item[2].sub_path
+
+
+class ProfileDependsChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+		self.profiles = kwargs.get('profiles')
+		self.options = kwargs.get('options')
+		self.repo_settings = kwargs.get('repo_settings')
+		self.include_arches = kwargs.get('include_arches')
+		self.caches = kwargs.get('caches')
+		self.repoman_incrementals = kwargs.get('repoman_incrementals')
+		self.env = kwargs.get('env')
+		self.have = kwargs.get('have')
+		self.dev_keywords = kwargs.get('dev_keywords')
+
+	def check(self, **kwargs):
+		arches = kwargs.get('arches')
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		relevant_profiles = []
+		for keyword, arch, groups in arches:
+			if arch not in self.profiles:
+				# A missing profile will create an error further down
+				# during the KEYWORDS verification.
+				continue
+
+			if self.include_arches is not None:
+				if arch not in self.include_arches:
+					continue
+
+			relevant_profiles.extend(
+				(keyword, groups, prof) for prof in self.profiles[arch])
+
+		relevant_profiles.sort(key=sort_key)
+
+		for keyword, groups, prof in relevant_profiles:
+
+			is_stable_profile = prof.status == "stable"
+			is_dev_profile = prof.status == "dev" and \
+				self.options.include_dev
+			is_exp_profile = prof.status == "exp" and \
+				self.options.include_exp_profiles == 'y'
+			if not (is_stable_profile or is_dev_profile or is_exp_profile):
+				continue
+
+			dep_settings = self.caches['arch'].get(prof.sub_path)
+			if dep_settings is None:
+				dep_settings = portage.config(
+					config_profile_path=prof.abs_path,
+					config_incrementals=self.repoman_incrementals,
+					config_root=self.repo_settings.config_root,
+					local_config=False,
+					_unmatched_removal=self.options.unmatched_removal,
+					env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
+				dep_settings.categories = self.repo_settings.repoman_settings.categories
+				if self.options.without_mask:
+					dep_settings._mask_manager_obj = \
+						copy.deepcopy(dep_settings._mask_manager)
+					dep_settings._mask_manager._pmaskdict.clear()
+				self.caches['arch'][prof.sub_path] = dep_settings
+
+			xmatch_cache_key = (prof.sub_path, tuple(groups))
+			xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
+			if xcache is None:
+				self.portdb.melt()
+				self.portdb.freeze()
+				xcache = self.portdb.xcache
+				xcache.update(self.caches['shared_xmatch'])
+				self.caches['arch_xmatch'][xmatch_cache_key] = xcache
+
+			self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
+			self.portdb.settings = dep_settings
+			self.portdb.xcache = xcache
+
+			dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
+			# just in case, prevent config.reset() from nuking these.
+			dep_settings.backup_changes("ACCEPT_KEYWORDS")
+
+			# This attribute is used in dbapi._match_use() to apply
+			# use.stable.{mask,force} settings based on the stable
+			# status of the parent package. This is required in order
+			# for USE deps of unstable packages to be resolved correctly,
+			# since otherwise use.stable.{mask,force} settings of
+			# dependencies may conflict (see bug #456342).
+			dep_settings._parent_stable = dep_settings._isStable(pkg)
+
+			# Handle package.use*.{force,mask) calculation, for use
+			# in dep_check.
+			dep_settings.useforce = dep_settings._use_manager.getUseForce(
+				pkg, stable=dep_settings._parent_stable)
+			dep_settings.usemask = dep_settings._use_manager.getUseMask(
+				pkg, stable=dep_settings._parent_stable)
+
+			if not baddepsyntax:
+				ismasked = not ebuild.archs or \
+					pkg.cpv not in self.portdb.xmatch("match-visible",
+					Atom("%s::%s" % (pkg.cp, self.repo_settings.repo_config.name)))
+				if ismasked:
+					if not self.have['pmasked']:
+						self.have['pmasked'] = bool(dep_settings._getMaskAtom(
+							pkg.cpv, ebuild.metadata))
+					if self.options.ignore_masked:
+						continue
+					# we are testing deps for a masked package; give it some lee-way
+					suffix = "masked"
+					matchmode = "minimum-all-ignore-profile"
+				else:
+					suffix = ""
+					matchmode = "minimum-visible"
+
+				if not self.have['dev_keywords']:
+					self.have['dev_keywords'] = \
+						bool(self.dev_keywords.intersection(ebuild.keywords))
+
+				if prof.status == "dev":
+					suffix = suffix + "indev"
+
+				for mytype in Package._dep_keys:
+
+					mykey = "dependency.bad" + suffix
+					myvalue = ebuild.metadata[mytype]
+					if not myvalue:
+						continue
+
+					success, atoms = portage.dep_check(
+						myvalue, self.portdb, dep_settings,
+						use="all", mode=matchmode, trees=self.repo_settings.trees)
+
+					if success:
+						if atoms:
+
+							# Don't bother with dependency.unknown for
+							# cases in which *DEPEND.bad is triggered.
+							for atom in atoms:
+								# dep_check returns all blockers and they
+								# aren't counted for *DEPEND.bad, so we
+								# ignore them here.
+								if not atom.blocker:
+									unknown_pkgs.discard(
+										(mytype, atom.unevaluated_atom))
+
+							if not prof.sub_path:
+								# old-style virtuals currently aren't
+								# resolvable with empty profile, since
+								# 'virtuals' mappings are unavailable
+								# (it would be expensive to search
+								# for PROVIDE in all ebuilds)
+								atoms = [
+									atom for atom in atoms if not (
+										atom.cp.startswith('virtual/')
+										and not self.portdb.cp_list(atom.cp))]
+
+							# we have some unsolvable deps
+							# remove ! deps, which always show up as unsatisfiable
+							atoms = [
+								str(atom.unevaluated_atom)
+								for atom in atoms if not atom.blocker]
+
+							# if we emptied out our list, continue:
+							if not atoms:
+								continue
+							if self.options.output_style in ['column']:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s) %s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, repr(atoms)))
+							else:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s)\n%s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, pformat(atoms, indent=6)))
+					else:
+						if self.options.output_style in ['column']:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s) %s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, repr(atoms)))
+						else:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s)\n%s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, pformat(atoms, indent=6)))
+		return {'continue': False}
+
+	@property
+	def runInPkgs(self):
+		return (False, [])
+
+	@property
+	def runInEbuilds(self):
+		return (True, [self.check])

diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py
index a34f785..39f53c1 100644
--- a/pym/repoman/repos.py
+++ b/pym/repoman/repos.py
@@ -28,6 +28,7 @@ class RepoSettings(object):
 		self, config_root, portdir, portdir_overlay,
 		repoman_settings=None, vcs_settings=None, options=None,
 		qawarnings=None):
+		self.config_root = config_root
 		self.repoman_settings = repoman_settings
 		self.vcs_settings = vcs_settings
 

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index a047237..be971db 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -2,17 +2,12 @@
 
 from __future__ import print_function, unicode_literals
 
-import copy
 import logging
 from itertools import chain
-from pprint import pformat
-
-from _emerge.Package import Package
 
 import portage
 from portage import normalize_path
 from portage import os
-from portage.dep import Atom
 from portage.output import green
 from repoman.modules.commit import repochecks
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
@@ -33,10 +28,6 @@ MODULE_CONTROLLER = Modules(path=MODULES_PATH, namepath="repoman.modules.scan")
 MODULE_NAMES = MODULE_CONTROLLER.module_names[:]
 
 
-def sort_key(item):
-	return item[2].sub_path
-
-
 class Scanner(object):
 	'''Primary scan class.  Operates all the small Q/A tests and checks'''
 
@@ -194,6 +185,12 @@ class Scanner(object):
 			"checks": self.checks,
 			"repo_metadata": self.repo_metadata,
 			"profiles": self.profiles,
+			"include_arches": self.include_arches,
+			"caches": self.caches,
+			"repoman_incrementals": self.repoman_incrementals,
+			"env": self.env,
+			"have": self.have,
+			"dev_keywords": self.dev_keywords,
 		}
 		# initialize the plugin checks here
 		self.modules = {}
@@ -291,7 +288,7 @@ class Scanner(object):
 				('license', 'LicenseChecks'), ('restrict', 'RestrictChecks'),
 				('mtime', 'MtimeChecks'), ('encoding', 'EncodingCheck'),
 				# Options.is_forced() is used to bypass further checks
-				('options', 'Options'),
+				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -319,170 +316,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			relevant_profiles = []
-			for keyword, arch, groups in dynamic_data['arches']:
-				if arch not in self.profiles:
-					# A missing profile will create an error further down
-					# during the KEYWORDS verification.
-					continue
-
-				if self.include_arches is not None:
-					if arch not in self.include_arches:
-						continue
-
-				relevant_profiles.extend(
-					(keyword, groups, prof) for prof in self.profiles[arch])
-
-			relevant_profiles.sort(key=sort_key)
-
-			for keyword, groups, prof in relevant_profiles:
-
-				is_stable_profile = prof.status == "stable"
-				is_dev_profile = prof.status == "dev" and \
-					self.options.include_dev
-				is_exp_profile = prof.status == "exp" and \
-					self.options.include_exp_profiles == 'y'
-				if not (is_stable_profile or is_dev_profile or is_exp_profile):
-					continue
-
-				dep_settings = self.caches['arch'].get(prof.sub_path)
-				if dep_settings is None:
-					dep_settings = portage.config(
-						config_profile_path=prof.abs_path,
-						config_incrementals=self.repoman_incrementals,
-						config_root=self.config_root,
-						local_config=False,
-						_unmatched_removal=self.options.unmatched_removal,
-						env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
-					dep_settings.categories = self.repo_settings.repoman_settings.categories
-					if self.options.without_mask:
-						dep_settings._mask_manager_obj = \
-							copy.deepcopy(dep_settings._mask_manager)
-						dep_settings._mask_manager._pmaskdict.clear()
-					self.caches['arch'][prof.sub_path] = dep_settings
-
-				xmatch_cache_key = (prof.sub_path, tuple(groups))
-				xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
-				if xcache is None:
-					self.portdb.melt()
-					self.portdb.freeze()
-					xcache = self.portdb.xcache
-					xcache.update(self.caches['shared_xmatch'])
-					self.caches['arch_xmatch'][xmatch_cache_key] = xcache
-
-				self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
-				self.portdb.settings = dep_settings
-				self.portdb.xcache = xcache
-
-				dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
-				# just in case, prevent config.reset() from nuking these.
-				dep_settings.backup_changes("ACCEPT_KEYWORDS")
-
-				# This attribute is used in dbapi._match_use() to apply
-				# use.stable.{mask,force} settings based on the stable
-				# status of the parent package. This is required in order
-				# for USE deps of unstable packages to be resolved correctly,
-				# since otherwise use.stable.{mask,force} settings of
-				# dependencies may conflict (see bug #456342).
-				dep_settings._parent_stable = dep_settings._isStable(dynamic_data['pkg'])
-
-				# Handle package.use*.{force,mask) calculation, for use
-				# in dep_check.
-				dep_settings.useforce = dep_settings._use_manager.getUseForce(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-				dep_settings.usemask = dep_settings._use_manager.getUseMask(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-
-				if not dynamic_data['baddepsyntax']:
-					ismasked = not dynamic_data['ebuild'].archs or \
-						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
-						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
-					if ismasked:
-						if not self.have['pmasked']:
-							self.have['pmasked'] = bool(dep_settings._getMaskAtom(
-								dynamic_data['pkg'].cpv, dynamic_data['pkg']._metadata))
-						if self.options.ignore_masked:
-							continue
-						# we are testing deps for a masked package; give it some lee-way
-						suffix = "masked"
-						matchmode = "minimum-all-ignore-profile"
-					else:
-						suffix = ""
-						matchmode = "minimum-visible"
-
-					if not self.have['dev_keywords']:
-						self.have['dev_keywords'] = \
-							bool(self.dev_keywords.intersection(dynamic_data['ebuild'].keywords))
-
-					if prof.status == "dev":
-						suffix = suffix + "indev"
-
-					for mytype in Package._dep_keys:
-
-						mykey = "dependency.bad" + suffix
-						myvalue = dynamic_data['ebuild'].metadata[mytype]
-						if not myvalue:
-							continue
-
-						success, atoms = portage.dep_check(
-							myvalue, self.portdb, dep_settings,
-							use="all", mode=matchmode, trees=self.repo_settings.trees)
-
-						if success:
-							if atoms:
-
-								# Don't bother with dependency.unknown for
-								# cases in which *DEPEND.bad is triggered.
-								for atom in atoms:
-									# dep_check returns all blockers and they
-									# aren't counted for *DEPEND.bad, so we
-									# ignore them here.
-									if not atom.blocker:
-										dynamic_data['unknown_pkgs'].discard(
-											(mytype, atom.unevaluated_atom))
-
-								if not prof.sub_path:
-									# old-style virtuals currently aren't
-									# resolvable with empty profile, since
-									# 'virtuals' mappings are unavailable
-									# (it would be expensive to search
-									# for PROVIDE in all ebuilds)
-									atoms = [
-										atom for atom in atoms if not (
-											atom.cp.startswith('virtual/')
-											and not self.portdb.cp_list(atom.cp))]
-
-								# we have some unsolvable deps
-								# remove ! deps, which always show up as unsatisfiable
-								atoms = [
-									str(atom.unevaluated_atom)
-									for atom in atoms if not atom.blocker]
-
-								# if we emptied out our list, continue:
-								if not atoms:
-									continue
-								if self.options.output_style in ['column']:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s) %s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, repr(atoms)))
-								else:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s)\n%s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, pformat(atoms, indent=6)))
-						else:
-							if self.options.output_style in ['column']:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s) %s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, repr(atoms)))
-							else:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s)\n%s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, pformat(atoms, indent=6)))
-
 			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-10 20:17 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-10 20:17 UTC (permalink / raw
  To: gentoo-commits

commit:     c4a8f9ab920c6e96f1d8c6e5cafa02073e128dc2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 08:09:33 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Jan 10 20:15:08 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c4a8f9ab

repoman: Create a new DependUnknown plugin class

 pym/repoman/modules/scan/depend/__init__.py |  8 ++++++++
 pym/repoman/modules/scan/depend/unknown.py  | 30 +++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 10 +---------
 3 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index 2dac94b..65555b4 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -26,6 +26,14 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'unknown-module': {
+			'name': "unknown",
+			'class': "DependUnknown",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py
new file mode 100644
index 0000000..61d51b9
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/unknown.py
@@ -0,0 +1,30 @@
+# -*- coding:utf-8 -*-
+
+
+class DependUnknown(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		if not baddepsyntax and unknown_pkgs:
+			type_map = {}
+			for mytype, atom in unknown_pkgs:
+				type_map.setdefault(mytype, set()).add(atom)
+			for mytype, atoms in type_map.items():
+				self.qatracker.add_error(
+					"dependency.unknown", "%s: %s: %s"
+					% (ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
+		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 be971db..89eaa57 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -289,6 +289,7 @@ class Scanner(object):
 				('mtime', 'MtimeChecks'), ('encoding', 'EncodingCheck'),
 				# Options.is_forced() is used to bypass further checks
 				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
+				('unknown', 'DependUnknown'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -316,15 +317,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
-				type_map = {}
-				for mytype, atom in dynamic_data['unknown_pkgs']:
-					type_map.setdefault(mytype, set()).add(atom)
-				for mytype, atoms in type_map.items():
-					self.qatracker.add_error(
-						"dependency.unknown", "%s: %s: %s"
-						% (dynamic_data['ebuild'].relative_path, mytype, ", ".join(sorted(atoms))))
-
 		# check if there are unused local USE-descriptions in metadata.xml
 		# (unless there are any invalids, to avoid noise)
 		if dynamic_data['allvalid']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-11  6:31 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-11  6:31 UTC (permalink / raw
  To: gentoo-commits

commit:     d2bdf2bbd826318819b53b56504ec38fe2f4ac2c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 20:38:11 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Jan 10 22:59:34 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d2bdf2bb

repoman: New DependChecks plugin

Migrate code from _scan_ebuilds to the plugin system

 pym/repoman/modules/scan/depend/__init__.py |  23 +++++
 pym/repoman/modules/scan/depend/depend.py   | 132 ++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 119 ++-----------------------
 3 files changed, 162 insertions(+), 112 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
new file mode 100644
index 0000000..73d3f8f
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -0,0 +1,23 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Depend plug-in module for repoman.
+Performs Dependency checks on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+	'name': 'depend',
+	'description': doc,
+	'provides':{
+		'depend-module': {
+			'name': "depend",
+			'class': "DependChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
+	}
+}
+

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
new file mode 100644
index 0000000..8a0ff48
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -0,0 +1,132 @@
+
+from _emerge.Package import Package
+
+from repoman.check_missingslot import check_missingslot
+# import our initialized portage instance
+from repoman._portage import portage
+from repoman.qa_data import suspect_virtual, suspect_rdepend
+
+
+class DependChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+
+		unknown_pkgs = set()
+
+		inherited_java_eclass = "java-pkg-2" in ebuild.inherited or \
+			"java-pkg-opt-2" in ebuild.inherited,
+		inherited_wxwidgets_eclass = "wxwidgets" in ebuild.inherited
+		# operator_tokens = set(["||", "(", ")"])
+		type_list, badsyntax = [], []
+		for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
+			mydepstr = ebuild.metadata[mytype]
+
+			buildtime = mytype in Package._buildtime_keys
+			runtime = mytype in Package._runtime_keys
+			token_class = None
+			if mytype.endswith("DEPEND"):
+				token_class = portage.dep.Atom
+
+			try:
+				atoms = portage.dep.use_reduce(
+					mydepstr, matchall=1, flat=True,
+					is_valid_flag=pkg.iuse.is_valid_flag, token_class=token_class)
+			except portage.exception.InvalidDependString as e:
+				atoms = None
+				badsyntax.append(str(e))
+
+			if atoms and mytype.endswith("DEPEND"):
+				if runtime and \
+					"test?" in mydepstr.split():
+					self.qatracker.add_error(
+						mytype + '.suspect',
+						"%s: 'test?' USE conditional in %s" %
+						(ebuild.relative_path, mytype))
+
+				for atom in atoms:
+					if atom == "||":
+						continue
+
+					is_blocker = atom.blocker
+
+					# Skip dependency.unknown for blockers, so that we
+					# don't encourage people to remove necessary blockers,
+					# as discussed in bug 382407. We use atom.without_use
+					# due to bug 525376.
+					if not is_blocker and \
+						not self.portdb.xmatch("match-all", atom.without_use) and \
+						not atom.cp.startswith("virtual/"):
+						unknown_pkgs.add((mytype, atom.unevaluated_atom))
+
+					if kwargs.get('catdir') != "virtual":
+						if not is_blocker and \
+							atom.cp in suspect_virtual:
+							self.qatracker.add_error(
+								'virtual.suspect', ebuild.relative_path +
+								": %s: consider using '%s' instead of '%s'" %
+								(mytype, suspect_virtual[atom.cp], atom))
+						if not is_blocker and \
+							atom.cp.startswith("perl-core/"):
+							self.qatracker.add_error('dependency.perlcore',
+								ebuild.relative_path +
+								": %s: please use '%s' instead of '%s'" %
+								(mytype,
+								atom.replace("perl-core/","virtual/perl-"),
+								atom))
+
+					if buildtime and \
+						not is_blocker and \
+						not inherited_java_eclass and \
+						atom.cp == "virtual/jdk":
+						self.qatracker.add_error(
+							'java.eclassesnotused', ebuild.relative_path)
+					elif buildtime and \
+						not is_blocker and \
+						not inherited_wxwidgets_eclass and \
+						atom.cp == "x11-libs/wxGTK":
+						self.qatracker.add_error(
+							'wxwidgets.eclassnotused',
+							"%s: %ss on x11-libs/wxGTK without inheriting"
+							" wxwidgets.eclass" % (ebuild.relative_path, mytype))
+					elif runtime:
+						if not is_blocker and \
+							atom.cp in suspect_rdepend:
+							self.qatracker.add_error(
+								mytype + '.suspect',
+								ebuild.relative_path + ": '%s'" % atom)
+
+					if atom.operator == "~" and \
+						portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
+						qacat = 'dependency.badtilde'
+						self.qatracker.add_error(
+							qacat, "%s: %s uses the ~ operator"
+							" with a non-zero revision: '%s'" %
+							(ebuild.relative_path, mytype, atom))
+
+					check_missingslot(atom, mytype, ebuild.eapi, self.portdb, self.qatracker,
+						ebuild.relative_path, ebuild.metadata)
+
+			type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
+
+		for m, b in zip(type_list, badsyntax):
+			if m.endswith("DEPEND"):
+				qacat = "dependency.syntax"
+			else:
+				qacat = m + ".syntax"
+			self.qatracker.add_error(
+				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+	@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 7b07a95..7f770c3 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -19,13 +19,11 @@ 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.check_missingslot import check_missingslot
 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
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
-from repoman.qa_data import missingvars, suspect_virtual, suspect_rdepend
 from repoman.repos import repo_metadata
 from repoman.modules.scan.scan import scan
 from repoman.modules.vcs.vcs import vcs_files_to_cps
@@ -301,7 +299,7 @@ class Scanner(object):
 				('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
 				('thirdpartymirrors', 'ThirdPartyMirrors'),
 				('description', 'DescriptionChecks'), (None, 'KeywordChecks'),
-				('arches', 'ArchChecks'),
+				('arches', 'ArchChecks'), ('depend', 'DependChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -358,112 +356,9 @@ class Scanner(object):
 			badprovsyntax = False
 			# catpkg = catdir + "/" + y_ebuild
 
-			inherited_java_eclass = "java-pkg-2" in dynamic_data['ebuild'].inherited or \
-				"java-pkg-opt-2" in dynamic_data['ebuild'].inherited,
-			inherited_wxwidgets_eclass = "wxwidgets" in dynamic_data['ebuild'].inherited
-			# operator_tokens = set(["||", "(", ")"])
-			type_list, badsyntax = [], []
-			for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
-				mydepstr = dynamic_data['ebuild'].metadata[mytype]
-
-				buildtime = mytype in Package._buildtime_keys
-				runtime = mytype in Package._runtime_keys
-				token_class = None
-				if mytype.endswith("DEPEND"):
-					token_class = portage.dep.Atom
-
-				try:
-					atoms = portage.dep.use_reduce(
-						mydepstr, matchall=1, flat=True,
-						is_valid_flag=dynamic_data['pkg'].iuse.is_valid_flag, token_class=token_class)
-				except portage.exception.InvalidDependString as e:
-					atoms = None
-					badsyntax.append(str(e))
-
-				if atoms and mytype.endswith("DEPEND"):
-					if runtime and \
-						"test?" in mydepstr.split():
-						self.qatracker.add_error(
-							mytype + '.suspect',
-							"%s: 'test?' USE conditional in %s" %
-							(dynamic_data['ebuild'].relative_path, mytype))
-
-					for atom in atoms:
-						if atom == "||":
-							continue
-
-						is_blocker = atom.blocker
-
-						# Skip dependency.unknown for blockers, so that we
-						# don't encourage people to remove necessary blockers,
-						# as discussed in bug 382407. We use atom.without_use
-						# due to bug 525376.
-						if not is_blocker and \
-							not self.portdb.xmatch("match-all", atom.without_use) and \
-							not atom.cp.startswith("virtual/"):
-							unknown_pkgs.add((mytype, atom.unevaluated_atom))
-
-						if dynamic_data['catdir'] != "virtual":
-							if not is_blocker and \
-								atom.cp in suspect_virtual:
-								self.qatracker.add_error(
-									'virtual.suspect', dynamic_data['ebuild'].relative_path +
-									": %s: consider using '%s' instead of '%s'" %
-									(mytype, suspect_virtual[atom.cp], atom))
-							if not is_blocker and \
-								atom.cp.startswith("perl-core/"):
-								self.qatracker.add_error('dependency.perlcore',
-									dynamic_data['ebuild'].relative_path +
-									": %s: please use '%s' instead of '%s'" %
-									(mytype,
-									atom.replace("perl-core/","virtual/perl-"),
-									atom))
-
-						if buildtime and \
-							not is_blocker and \
-							not inherited_java_eclass and \
-							atom.cp == "virtual/jdk":
-							self.qatracker.add_error(
-								'java.eclassesnotused', dynamic_data['ebuild'].relative_path)
-						elif buildtime and \
-							not is_blocker and \
-							not inherited_wxwidgets_eclass and \
-							atom.cp == "x11-libs/wxGTK":
-							self.qatracker.add_error(
-								'wxwidgets.eclassnotused',
-								"%s: %ss on x11-libs/wxGTK without inheriting"
-								" wxwidgets.eclass" % (dynamic_data['ebuild'].relative_path, mytype))
-						elif runtime:
-							if not is_blocker and \
-								atom.cp in suspect_rdepend:
-								self.qatracker.add_error(
-									mytype + '.suspect',
-									dynamic_data['ebuild'].relative_path + ": '%s'" % atom)
-
-						if atom.operator == "~" and \
-							portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
-							qacat = 'dependency.badtilde'
-							self.qatracker.add_error(
-								qacat, "%s: %s uses the ~ operator"
-								" with a non-zero revision: '%s'" %
-								(dynamic_data['ebuild'].relative_path, mytype, atom))
-
-						check_missingslot(atom, mytype, dynamic_data['ebuild'].eapi, self.portdb, self.qatracker,
-							dynamic_data['ebuild'].relative_path, dynamic_data['ebuild'].metadata)
-
-				type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
-
-			for m, b in zip(type_list, badsyntax):
-				if m.endswith("DEPEND"):
-					qacat = "dependency.syntax"
-				else:
-					qacat = m + ".syntax"
-				self.qatracker.add_error(
-					qacat, "%s: %s: %s" % (dynamic_data['ebuild'].relative_path, m, b))
-
-			badlicsyntax = len([z for z in type_list if z == "LICENSE"])
-			badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
-			baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
+			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
+			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
 			badlicsyntax = badlicsyntax > 0
 			badprovsyntax = badprovsyntax > 0
 
@@ -626,7 +521,7 @@ class Scanner(object):
 									# aren't counted for *DEPEND.bad, so we
 									# ignore them here.
 									if not atom.blocker:
-										unknown_pkgs.discard(
+										dynamic_data['unknown_pkgs'].discard(
 											(mytype, atom.unevaluated_atom))
 
 								if not prof.sub_path:
@@ -671,9 +566,9 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and unknown_pkgs:
+			if not baddepsyntax and dynamic_data['unknown_pkgs']:
 				type_map = {}
-				for mytype, atom in unknown_pkgs:
+				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)
 				for mytype, atoms in type_map.items():
 					self.qatracker.add_error(


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-11  6:31 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-11  6:31 UTC (permalink / raw
  To: gentoo-commits

commit:     07395fe2d7275f6663fd0e936aa2f36fcd3688d4
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 08:09:33 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Jan 10 22:59:38 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=07395fe2

repoman: Create a new DependUnknown plugin class

 pym/repoman/modules/scan/depend/__init__.py |  8 ++++++++
 pym/repoman/modules/scan/depend/unknown.py  | 30 +++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 10 +---------
 3 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index 2dac94b..65555b4 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -26,6 +26,14 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'unknown-module': {
+			'name': "unknown",
+			'class': "DependUnknown",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py
new file mode 100644
index 0000000..61d51b9
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/unknown.py
@@ -0,0 +1,30 @@
+# -*- coding:utf-8 -*-
+
+
+class DependUnknown(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		if not baddepsyntax and unknown_pkgs:
+			type_map = {}
+			for mytype, atom in unknown_pkgs:
+				type_map.setdefault(mytype, set()).add(atom)
+			for mytype, atoms in type_map.items():
+				self.qatracker.add_error(
+					"dependency.unknown", "%s: %s: %s"
+					% (ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
+		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 be971db..89eaa57 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -289,6 +289,7 @@ class Scanner(object):
 				('mtime', 'MtimeChecks'), ('encoding', 'EncodingCheck'),
 				# Options.is_forced() is used to bypass further checks
 				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
+				('unknown', 'DependUnknown'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -316,15 +317,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
-				type_map = {}
-				for mytype, atom in dynamic_data['unknown_pkgs']:
-					type_map.setdefault(mytype, set()).add(atom)
-				for mytype, atoms in type_map.items():
-					self.qatracker.add_error(
-						"dependency.unknown", "%s: %s: %s"
-						% (dynamic_data['ebuild'].relative_path, mytype, ", ".join(sorted(atoms))))
-
 		# check if there are unused local USE-descriptions in metadata.xml
 		# (unless there are any invalids, to avoid noise)
 		if dynamic_data['allvalid']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-11  8:01 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-11  8:01 UTC (permalink / raw
  To: gentoo-commits

commit:     283500eb3b2044f79daa793d532fbc1c6bdcad59
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 20:38:11 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jan 11 08:00:16 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=283500eb

repoman: New DependChecks plugin

Migrate code from _scan_ebuilds to the plugin system

 pym/repoman/modules/scan/depend/__init__.py |  23 +++++
 pym/repoman/modules/scan/depend/depend.py   | 132 ++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 119 ++-----------------------
 3 files changed, 162 insertions(+), 112 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
new file mode 100644
index 0000000..73d3f8f
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -0,0 +1,23 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Depend plug-in module for repoman.
+Performs Dependency checks on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+	'name': 'depend',
+	'description': doc,
+	'provides':{
+		'depend-module': {
+			'name': "depend",
+			'class': "DependChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
+	}
+}
+

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
new file mode 100644
index 0000000..8a0ff48
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -0,0 +1,132 @@
+
+from _emerge.Package import Package
+
+from repoman.check_missingslot import check_missingslot
+# import our initialized portage instance
+from repoman._portage import portage
+from repoman.qa_data import suspect_virtual, suspect_rdepend
+
+
+class DependChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+
+		unknown_pkgs = set()
+
+		inherited_java_eclass = "java-pkg-2" in ebuild.inherited or \
+			"java-pkg-opt-2" in ebuild.inherited,
+		inherited_wxwidgets_eclass = "wxwidgets" in ebuild.inherited
+		# operator_tokens = set(["||", "(", ")"])
+		type_list, badsyntax = [], []
+		for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
+			mydepstr = ebuild.metadata[mytype]
+
+			buildtime = mytype in Package._buildtime_keys
+			runtime = mytype in Package._runtime_keys
+			token_class = None
+			if mytype.endswith("DEPEND"):
+				token_class = portage.dep.Atom
+
+			try:
+				atoms = portage.dep.use_reduce(
+					mydepstr, matchall=1, flat=True,
+					is_valid_flag=pkg.iuse.is_valid_flag, token_class=token_class)
+			except portage.exception.InvalidDependString as e:
+				atoms = None
+				badsyntax.append(str(e))
+
+			if atoms and mytype.endswith("DEPEND"):
+				if runtime and \
+					"test?" in mydepstr.split():
+					self.qatracker.add_error(
+						mytype + '.suspect',
+						"%s: 'test?' USE conditional in %s" %
+						(ebuild.relative_path, mytype))
+
+				for atom in atoms:
+					if atom == "||":
+						continue
+
+					is_blocker = atom.blocker
+
+					# Skip dependency.unknown for blockers, so that we
+					# don't encourage people to remove necessary blockers,
+					# as discussed in bug 382407. We use atom.without_use
+					# due to bug 525376.
+					if not is_blocker and \
+						not self.portdb.xmatch("match-all", atom.without_use) and \
+						not atom.cp.startswith("virtual/"):
+						unknown_pkgs.add((mytype, atom.unevaluated_atom))
+
+					if kwargs.get('catdir') != "virtual":
+						if not is_blocker and \
+							atom.cp in suspect_virtual:
+							self.qatracker.add_error(
+								'virtual.suspect', ebuild.relative_path +
+								": %s: consider using '%s' instead of '%s'" %
+								(mytype, suspect_virtual[atom.cp], atom))
+						if not is_blocker and \
+							atom.cp.startswith("perl-core/"):
+							self.qatracker.add_error('dependency.perlcore',
+								ebuild.relative_path +
+								": %s: please use '%s' instead of '%s'" %
+								(mytype,
+								atom.replace("perl-core/","virtual/perl-"),
+								atom))
+
+					if buildtime and \
+						not is_blocker and \
+						not inherited_java_eclass and \
+						atom.cp == "virtual/jdk":
+						self.qatracker.add_error(
+							'java.eclassesnotused', ebuild.relative_path)
+					elif buildtime and \
+						not is_blocker and \
+						not inherited_wxwidgets_eclass and \
+						atom.cp == "x11-libs/wxGTK":
+						self.qatracker.add_error(
+							'wxwidgets.eclassnotused',
+							"%s: %ss on x11-libs/wxGTK without inheriting"
+							" wxwidgets.eclass" % (ebuild.relative_path, mytype))
+					elif runtime:
+						if not is_blocker and \
+							atom.cp in suspect_rdepend:
+							self.qatracker.add_error(
+								mytype + '.suspect',
+								ebuild.relative_path + ": '%s'" % atom)
+
+					if atom.operator == "~" and \
+						portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
+						qacat = 'dependency.badtilde'
+						self.qatracker.add_error(
+							qacat, "%s: %s uses the ~ operator"
+							" with a non-zero revision: '%s'" %
+							(ebuild.relative_path, mytype, atom))
+
+					check_missingslot(atom, mytype, ebuild.eapi, self.portdb, self.qatracker,
+						ebuild.relative_path, ebuild.metadata)
+
+			type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
+
+		for m, b in zip(type_list, badsyntax):
+			if m.endswith("DEPEND"):
+				qacat = "dependency.syntax"
+			else:
+				qacat = m + ".syntax"
+			self.qatracker.add_error(
+				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+	@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 7b07a95..7f770c3 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -19,13 +19,11 @@ 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.check_missingslot import check_missingslot
 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
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
-from repoman.qa_data import missingvars, suspect_virtual, suspect_rdepend
 from repoman.repos import repo_metadata
 from repoman.modules.scan.scan import scan
 from repoman.modules.vcs.vcs import vcs_files_to_cps
@@ -301,7 +299,7 @@ class Scanner(object):
 				('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
 				('thirdpartymirrors', 'ThirdPartyMirrors'),
 				('description', 'DescriptionChecks'), (None, 'KeywordChecks'),
-				('arches', 'ArchChecks'),
+				('arches', 'ArchChecks'), ('depend', 'DependChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -358,112 +356,9 @@ class Scanner(object):
 			badprovsyntax = False
 			# catpkg = catdir + "/" + y_ebuild
 
-			inherited_java_eclass = "java-pkg-2" in dynamic_data['ebuild'].inherited or \
-				"java-pkg-opt-2" in dynamic_data['ebuild'].inherited,
-			inherited_wxwidgets_eclass = "wxwidgets" in dynamic_data['ebuild'].inherited
-			# operator_tokens = set(["||", "(", ")"])
-			type_list, badsyntax = [], []
-			for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
-				mydepstr = dynamic_data['ebuild'].metadata[mytype]
-
-				buildtime = mytype in Package._buildtime_keys
-				runtime = mytype in Package._runtime_keys
-				token_class = None
-				if mytype.endswith("DEPEND"):
-					token_class = portage.dep.Atom
-
-				try:
-					atoms = portage.dep.use_reduce(
-						mydepstr, matchall=1, flat=True,
-						is_valid_flag=dynamic_data['pkg'].iuse.is_valid_flag, token_class=token_class)
-				except portage.exception.InvalidDependString as e:
-					atoms = None
-					badsyntax.append(str(e))
-
-				if atoms and mytype.endswith("DEPEND"):
-					if runtime and \
-						"test?" in mydepstr.split():
-						self.qatracker.add_error(
-							mytype + '.suspect',
-							"%s: 'test?' USE conditional in %s" %
-							(dynamic_data['ebuild'].relative_path, mytype))
-
-					for atom in atoms:
-						if atom == "||":
-							continue
-
-						is_blocker = atom.blocker
-
-						# Skip dependency.unknown for blockers, so that we
-						# don't encourage people to remove necessary blockers,
-						# as discussed in bug 382407. We use atom.without_use
-						# due to bug 525376.
-						if not is_blocker and \
-							not self.portdb.xmatch("match-all", atom.without_use) and \
-							not atom.cp.startswith("virtual/"):
-							unknown_pkgs.add((mytype, atom.unevaluated_atom))
-
-						if dynamic_data['catdir'] != "virtual":
-							if not is_blocker and \
-								atom.cp in suspect_virtual:
-								self.qatracker.add_error(
-									'virtual.suspect', dynamic_data['ebuild'].relative_path +
-									": %s: consider using '%s' instead of '%s'" %
-									(mytype, suspect_virtual[atom.cp], atom))
-							if not is_blocker and \
-								atom.cp.startswith("perl-core/"):
-								self.qatracker.add_error('dependency.perlcore',
-									dynamic_data['ebuild'].relative_path +
-									": %s: please use '%s' instead of '%s'" %
-									(mytype,
-									atom.replace("perl-core/","virtual/perl-"),
-									atom))
-
-						if buildtime and \
-							not is_blocker and \
-							not inherited_java_eclass and \
-							atom.cp == "virtual/jdk":
-							self.qatracker.add_error(
-								'java.eclassesnotused', dynamic_data['ebuild'].relative_path)
-						elif buildtime and \
-							not is_blocker and \
-							not inherited_wxwidgets_eclass and \
-							atom.cp == "x11-libs/wxGTK":
-							self.qatracker.add_error(
-								'wxwidgets.eclassnotused',
-								"%s: %ss on x11-libs/wxGTK without inheriting"
-								" wxwidgets.eclass" % (dynamic_data['ebuild'].relative_path, mytype))
-						elif runtime:
-							if not is_blocker and \
-								atom.cp in suspect_rdepend:
-								self.qatracker.add_error(
-									mytype + '.suspect',
-									dynamic_data['ebuild'].relative_path + ": '%s'" % atom)
-
-						if atom.operator == "~" and \
-							portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
-							qacat = 'dependency.badtilde'
-							self.qatracker.add_error(
-								qacat, "%s: %s uses the ~ operator"
-								" with a non-zero revision: '%s'" %
-								(dynamic_data['ebuild'].relative_path, mytype, atom))
-
-						check_missingslot(atom, mytype, dynamic_data['ebuild'].eapi, self.portdb, self.qatracker,
-							dynamic_data['ebuild'].relative_path, dynamic_data['ebuild'].metadata)
-
-				type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
-
-			for m, b in zip(type_list, badsyntax):
-				if m.endswith("DEPEND"):
-					qacat = "dependency.syntax"
-				else:
-					qacat = m + ".syntax"
-				self.qatracker.add_error(
-					qacat, "%s: %s: %s" % (dynamic_data['ebuild'].relative_path, m, b))
-
-			badlicsyntax = len([z for z in type_list if z == "LICENSE"])
-			badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
-			baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
+			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
+			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
 			badlicsyntax = badlicsyntax > 0
 			badprovsyntax = badprovsyntax > 0
 
@@ -626,7 +521,7 @@ class Scanner(object):
 									# aren't counted for *DEPEND.bad, so we
 									# ignore them here.
 									if not atom.blocker:
-										unknown_pkgs.discard(
+										dynamic_data['unknown_pkgs'].discard(
 											(mytype, atom.unevaluated_atom))
 
 								if not prof.sub_path:
@@ -671,9 +566,9 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and unknown_pkgs:
+			if not baddepsyntax and dynamic_data['unknown_pkgs']:
 				type_map = {}
-				for mytype, atom in unknown_pkgs:
+				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)
 				for mytype, atoms in type_map.items():
 					self.qatracker.add_error(


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-18 19:23 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-18 19:23 UTC (permalink / raw
  To: gentoo-commits

commit:     d41825e26f02b97ac4889dfbf90b4a151e19dd72
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 07:57:36 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jan 18 19:20:03 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d41825e2

repoman: Move the large depency checks loop to a new plugin ProfileDependsChecks class

 pym/repoman/modules/scan/depend/__init__.py |   8 ++
 pym/repoman/modules/scan/depend/profile.py  | 211 ++++++++++++++++++++++++++++
 pym/repoman/repos.py                        |   1 +
 pym/repoman/scanner.py                      | 181 +-----------------------
 4 files changed, 227 insertions(+), 174 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index 73d3f8f..2dac94b 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -18,6 +18,14 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'profile-module': {
+			'name': "profile",
+			'class': "ProfileDependsChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/profile.py b/pym/repoman/modules/scan/depend/profile.py
new file mode 100644
index 0000000..91c52cc
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/profile.py
@@ -0,0 +1,211 @@
+# -*- coding:utf-8 -*-
+
+
+import copy
+from pprint import pformat
+
+from _emerge.Package import Package
+
+# import our initialized portage instance
+from repoman._portage import portage
+from portage.dep import Atom
+
+
+def sort_key(item):
+	return item[2].sub_path
+
+
+class ProfileDependsChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+		self.profiles = kwargs.get('profiles')
+		self.options = kwargs.get('options')
+		self.repo_settings = kwargs.get('repo_settings')
+		self.include_arches = kwargs.get('include_arches')
+		self.caches = kwargs.get('caches')
+		self.repoman_incrementals = kwargs.get('repoman_incrementals')
+		self.env = kwargs.get('env')
+		self.have = kwargs.get('have')
+		self.dev_keywords = kwargs.get('dev_keywords')
+
+	def check(self, **kwargs):
+		arches = kwargs.get('arches')
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		relevant_profiles = []
+		for keyword, arch, groups in arches:
+			if arch not in self.profiles:
+				# A missing profile will create an error further down
+				# during the KEYWORDS verification.
+				continue
+
+			if self.include_arches is not None:
+				if arch not in self.include_arches:
+					continue
+
+			relevant_profiles.extend(
+				(keyword, groups, prof) for prof in self.profiles[arch])
+
+		relevant_profiles.sort(key=sort_key)
+
+		for keyword, groups, prof in relevant_profiles:
+
+			is_stable_profile = prof.status == "stable"
+			is_dev_profile = prof.status == "dev" and \
+				self.options.include_dev
+			is_exp_profile = prof.status == "exp" and \
+				self.options.include_exp_profiles == 'y'
+			if not (is_stable_profile or is_dev_profile or is_exp_profile):
+				continue
+
+			dep_settings = self.caches['arch'].get(prof.sub_path)
+			if dep_settings is None:
+				dep_settings = portage.config(
+					config_profile_path=prof.abs_path,
+					config_incrementals=self.repoman_incrementals,
+					config_root=self.repo_settings.config_root,
+					local_config=False,
+					_unmatched_removal=self.options.unmatched_removal,
+					env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
+				dep_settings.categories = self.repo_settings.repoman_settings.categories
+				if self.options.without_mask:
+					dep_settings._mask_manager_obj = \
+						copy.deepcopy(dep_settings._mask_manager)
+					dep_settings._mask_manager._pmaskdict.clear()
+				self.caches['arch'][prof.sub_path] = dep_settings
+
+			xmatch_cache_key = (prof.sub_path, tuple(groups))
+			xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
+			if xcache is None:
+				self.portdb.melt()
+				self.portdb.freeze()
+				xcache = self.portdb.xcache
+				xcache.update(self.caches['shared_xmatch'])
+				self.caches['arch_xmatch'][xmatch_cache_key] = xcache
+
+			self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
+			self.portdb.settings = dep_settings
+			self.portdb.xcache = xcache
+
+			dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
+			# just in case, prevent config.reset() from nuking these.
+			dep_settings.backup_changes("ACCEPT_KEYWORDS")
+
+			# This attribute is used in dbapi._match_use() to apply
+			# use.stable.{mask,force} settings based on the stable
+			# status of the parent package. This is required in order
+			# for USE deps of unstable packages to be resolved correctly,
+			# since otherwise use.stable.{mask,force} settings of
+			# dependencies may conflict (see bug #456342).
+			dep_settings._parent_stable = dep_settings._isStable(pkg)
+
+			# Handle package.use*.{force,mask) calculation, for use
+			# in dep_check.
+			dep_settings.useforce = dep_settings._use_manager.getUseForce(
+				pkg, stable=dep_settings._parent_stable)
+			dep_settings.usemask = dep_settings._use_manager.getUseMask(
+				pkg, stable=dep_settings._parent_stable)
+
+			if not baddepsyntax:
+				ismasked = not ebuild.archs or \
+					pkg.cpv not in self.portdb.xmatch("match-visible",
+					Atom("%s::%s" % (pkg.cp, self.repo_settings.repo_config.name)))
+				if ismasked:
+					if not self.have['pmasked']:
+						self.have['pmasked'] = bool(dep_settings._getMaskAtom(
+							pkg.cpv, ebuild.metadata))
+					if self.options.ignore_masked:
+						continue
+					# we are testing deps for a masked package; give it some lee-way
+					suffix = "masked"
+					matchmode = "minimum-all-ignore-profile"
+				else:
+					suffix = ""
+					matchmode = "minimum-visible"
+
+				if not self.have['dev_keywords']:
+					self.have['dev_keywords'] = \
+						bool(self.dev_keywords.intersection(ebuild.keywords))
+
+				if prof.status == "dev":
+					suffix = suffix + "indev"
+
+				for mytype in Package._dep_keys:
+
+					mykey = "dependency.bad" + suffix
+					myvalue = ebuild.metadata[mytype]
+					if not myvalue:
+						continue
+
+					success, atoms = portage.dep_check(
+						myvalue, self.portdb, dep_settings,
+						use="all", mode=matchmode, trees=self.repo_settings.trees)
+
+					if success:
+						if atoms:
+
+							# Don't bother with dependency.unknown for
+							# cases in which *DEPEND.bad is triggered.
+							for atom in atoms:
+								# dep_check returns all blockers and they
+								# aren't counted for *DEPEND.bad, so we
+								# ignore them here.
+								if not atom.blocker:
+									unknown_pkgs.discard(
+										(mytype, atom.unevaluated_atom))
+
+							if not prof.sub_path:
+								# old-style virtuals currently aren't
+								# resolvable with empty profile, since
+								# 'virtuals' mappings are unavailable
+								# (it would be expensive to search
+								# for PROVIDE in all ebuilds)
+								atoms = [
+									atom for atom in atoms if not (
+										atom.cp.startswith('virtual/')
+										and not self.portdb.cp_list(atom.cp))]
+
+							# we have some unsolvable deps
+							# remove ! deps, which always show up as unsatisfiable
+							atoms = [
+								str(atom.unevaluated_atom)
+								for atom in atoms if not atom.blocker]
+
+							# if we emptied out our list, continue:
+							if not atoms:
+								continue
+							if self.options.output_style in ['column']:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s) %s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, repr(atoms)))
+							else:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s)\n%s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, pformat(atoms, indent=6)))
+					else:
+						if self.options.output_style in ['column']:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s) %s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, repr(atoms)))
+						else:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s)\n%s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, pformat(atoms, indent=6)))
+		return {'continue': False}
+
+	@property
+	def runInPkgs(self):
+		return (False, [])
+
+	@property
+	def runInEbuilds(self):
+		return (True, [self.check])

diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py
index a34f785..39f53c1 100644
--- a/pym/repoman/repos.py
+++ b/pym/repoman/repos.py
@@ -28,6 +28,7 @@ class RepoSettings(object):
 		self, config_root, portdir, portdir_overlay,
 		repoman_settings=None, vcs_settings=None, options=None,
 		qawarnings=None):
+		self.config_root = config_root
 		self.repoman_settings = repoman_settings
 		self.vcs_settings = vcs_settings
 

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index a047237..be971db 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -2,17 +2,12 @@
 
 from __future__ import print_function, unicode_literals
 
-import copy
 import logging
 from itertools import chain
-from pprint import pformat
-
-from _emerge.Package import Package
 
 import portage
 from portage import normalize_path
 from portage import os
-from portage.dep import Atom
 from portage.output import green
 from repoman.modules.commit import repochecks
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
@@ -33,10 +28,6 @@ MODULE_CONTROLLER = Modules(path=MODULES_PATH, namepath="repoman.modules.scan")
 MODULE_NAMES = MODULE_CONTROLLER.module_names[:]
 
 
-def sort_key(item):
-	return item[2].sub_path
-
-
 class Scanner(object):
 	'''Primary scan class.  Operates all the small Q/A tests and checks'''
 
@@ -194,6 +185,12 @@ class Scanner(object):
 			"checks": self.checks,
 			"repo_metadata": self.repo_metadata,
 			"profiles": self.profiles,
+			"include_arches": self.include_arches,
+			"caches": self.caches,
+			"repoman_incrementals": self.repoman_incrementals,
+			"env": self.env,
+			"have": self.have,
+			"dev_keywords": self.dev_keywords,
 		}
 		# initialize the plugin checks here
 		self.modules = {}
@@ -291,7 +288,7 @@ class Scanner(object):
 				('license', 'LicenseChecks'), ('restrict', 'RestrictChecks'),
 				('mtime', 'MtimeChecks'), ('encoding', 'EncodingCheck'),
 				# Options.is_forced() is used to bypass further checks
-				('options', 'Options'),
+				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -319,170 +316,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			relevant_profiles = []
-			for keyword, arch, groups in dynamic_data['arches']:
-				if arch not in self.profiles:
-					# A missing profile will create an error further down
-					# during the KEYWORDS verification.
-					continue
-
-				if self.include_arches is not None:
-					if arch not in self.include_arches:
-						continue
-
-				relevant_profiles.extend(
-					(keyword, groups, prof) for prof in self.profiles[arch])
-
-			relevant_profiles.sort(key=sort_key)
-
-			for keyword, groups, prof in relevant_profiles:
-
-				is_stable_profile = prof.status == "stable"
-				is_dev_profile = prof.status == "dev" and \
-					self.options.include_dev
-				is_exp_profile = prof.status == "exp" and \
-					self.options.include_exp_profiles == 'y'
-				if not (is_stable_profile or is_dev_profile or is_exp_profile):
-					continue
-
-				dep_settings = self.caches['arch'].get(prof.sub_path)
-				if dep_settings is None:
-					dep_settings = portage.config(
-						config_profile_path=prof.abs_path,
-						config_incrementals=self.repoman_incrementals,
-						config_root=self.config_root,
-						local_config=False,
-						_unmatched_removal=self.options.unmatched_removal,
-						env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
-					dep_settings.categories = self.repo_settings.repoman_settings.categories
-					if self.options.without_mask:
-						dep_settings._mask_manager_obj = \
-							copy.deepcopy(dep_settings._mask_manager)
-						dep_settings._mask_manager._pmaskdict.clear()
-					self.caches['arch'][prof.sub_path] = dep_settings
-
-				xmatch_cache_key = (prof.sub_path, tuple(groups))
-				xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
-				if xcache is None:
-					self.portdb.melt()
-					self.portdb.freeze()
-					xcache = self.portdb.xcache
-					xcache.update(self.caches['shared_xmatch'])
-					self.caches['arch_xmatch'][xmatch_cache_key] = xcache
-
-				self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
-				self.portdb.settings = dep_settings
-				self.portdb.xcache = xcache
-
-				dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
-				# just in case, prevent config.reset() from nuking these.
-				dep_settings.backup_changes("ACCEPT_KEYWORDS")
-
-				# This attribute is used in dbapi._match_use() to apply
-				# use.stable.{mask,force} settings based on the stable
-				# status of the parent package. This is required in order
-				# for USE deps of unstable packages to be resolved correctly,
-				# since otherwise use.stable.{mask,force} settings of
-				# dependencies may conflict (see bug #456342).
-				dep_settings._parent_stable = dep_settings._isStable(dynamic_data['pkg'])
-
-				# Handle package.use*.{force,mask) calculation, for use
-				# in dep_check.
-				dep_settings.useforce = dep_settings._use_manager.getUseForce(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-				dep_settings.usemask = dep_settings._use_manager.getUseMask(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-
-				if not dynamic_data['baddepsyntax']:
-					ismasked = not dynamic_data['ebuild'].archs or \
-						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
-						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
-					if ismasked:
-						if not self.have['pmasked']:
-							self.have['pmasked'] = bool(dep_settings._getMaskAtom(
-								dynamic_data['pkg'].cpv, dynamic_data['pkg']._metadata))
-						if self.options.ignore_masked:
-							continue
-						# we are testing deps for a masked package; give it some lee-way
-						suffix = "masked"
-						matchmode = "minimum-all-ignore-profile"
-					else:
-						suffix = ""
-						matchmode = "minimum-visible"
-
-					if not self.have['dev_keywords']:
-						self.have['dev_keywords'] = \
-							bool(self.dev_keywords.intersection(dynamic_data['ebuild'].keywords))
-
-					if prof.status == "dev":
-						suffix = suffix + "indev"
-
-					for mytype in Package._dep_keys:
-
-						mykey = "dependency.bad" + suffix
-						myvalue = dynamic_data['ebuild'].metadata[mytype]
-						if not myvalue:
-							continue
-
-						success, atoms = portage.dep_check(
-							myvalue, self.portdb, dep_settings,
-							use="all", mode=matchmode, trees=self.repo_settings.trees)
-
-						if success:
-							if atoms:
-
-								# Don't bother with dependency.unknown for
-								# cases in which *DEPEND.bad is triggered.
-								for atom in atoms:
-									# dep_check returns all blockers and they
-									# aren't counted for *DEPEND.bad, so we
-									# ignore them here.
-									if not atom.blocker:
-										dynamic_data['unknown_pkgs'].discard(
-											(mytype, atom.unevaluated_atom))
-
-								if not prof.sub_path:
-									# old-style virtuals currently aren't
-									# resolvable with empty profile, since
-									# 'virtuals' mappings are unavailable
-									# (it would be expensive to search
-									# for PROVIDE in all ebuilds)
-									atoms = [
-										atom for atom in atoms if not (
-											atom.cp.startswith('virtual/')
-											and not self.portdb.cp_list(atom.cp))]
-
-								# we have some unsolvable deps
-								# remove ! deps, which always show up as unsatisfiable
-								atoms = [
-									str(atom.unevaluated_atom)
-									for atom in atoms if not atom.blocker]
-
-								# if we emptied out our list, continue:
-								if not atoms:
-									continue
-								if self.options.output_style in ['column']:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s) %s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, repr(atoms)))
-								else:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s)\n%s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, pformat(atoms, indent=6)))
-						else:
-							if self.options.output_style in ['column']:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s) %s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, repr(atoms)))
-							else:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s)\n%s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, pformat(atoms, indent=6)))
-
 			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-21 18:30 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-21 18:30 UTC (permalink / raw
  To: gentoo-commits

commit:     3644c04f0f81814b47d5c284150e6ce85cb6e032
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 20:38:11 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=3644c04f

repoman: New DependChecks plugin

Migrate code from _scan_ebuilds to the plugin system

 pym/repoman/modules/scan/depend/__init__.py |  23 +++++
 pym/repoman/modules/scan/depend/depend.py   | 132 ++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 119 ++-----------------------
 3 files changed, 162 insertions(+), 112 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
new file mode 100644
index 0000000..73d3f8f
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -0,0 +1,23 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Depend plug-in module for repoman.
+Performs Dependency checks on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+	'name': 'depend',
+	'description': doc,
+	'provides':{
+		'depend-module': {
+			'name': "depend",
+			'class': "DependChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
+	}
+}
+

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
new file mode 100644
index 0000000..8a0ff48
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -0,0 +1,132 @@
+
+from _emerge.Package import Package
+
+from repoman.check_missingslot import check_missingslot
+# import our initialized portage instance
+from repoman._portage import portage
+from repoman.qa_data import suspect_virtual, suspect_rdepend
+
+
+class DependChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+
+		unknown_pkgs = set()
+
+		inherited_java_eclass = "java-pkg-2" in ebuild.inherited or \
+			"java-pkg-opt-2" in ebuild.inherited,
+		inherited_wxwidgets_eclass = "wxwidgets" in ebuild.inherited
+		# operator_tokens = set(["||", "(", ")"])
+		type_list, badsyntax = [], []
+		for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
+			mydepstr = ebuild.metadata[mytype]
+
+			buildtime = mytype in Package._buildtime_keys
+			runtime = mytype in Package._runtime_keys
+			token_class = None
+			if mytype.endswith("DEPEND"):
+				token_class = portage.dep.Atom
+
+			try:
+				atoms = portage.dep.use_reduce(
+					mydepstr, matchall=1, flat=True,
+					is_valid_flag=pkg.iuse.is_valid_flag, token_class=token_class)
+			except portage.exception.InvalidDependString as e:
+				atoms = None
+				badsyntax.append(str(e))
+
+			if atoms and mytype.endswith("DEPEND"):
+				if runtime and \
+					"test?" in mydepstr.split():
+					self.qatracker.add_error(
+						mytype + '.suspect',
+						"%s: 'test?' USE conditional in %s" %
+						(ebuild.relative_path, mytype))
+
+				for atom in atoms:
+					if atom == "||":
+						continue
+
+					is_blocker = atom.blocker
+
+					# Skip dependency.unknown for blockers, so that we
+					# don't encourage people to remove necessary blockers,
+					# as discussed in bug 382407. We use atom.without_use
+					# due to bug 525376.
+					if not is_blocker and \
+						not self.portdb.xmatch("match-all", atom.without_use) and \
+						not atom.cp.startswith("virtual/"):
+						unknown_pkgs.add((mytype, atom.unevaluated_atom))
+
+					if kwargs.get('catdir') != "virtual":
+						if not is_blocker and \
+							atom.cp in suspect_virtual:
+							self.qatracker.add_error(
+								'virtual.suspect', ebuild.relative_path +
+								": %s: consider using '%s' instead of '%s'" %
+								(mytype, suspect_virtual[atom.cp], atom))
+						if not is_blocker and \
+							atom.cp.startswith("perl-core/"):
+							self.qatracker.add_error('dependency.perlcore',
+								ebuild.relative_path +
+								": %s: please use '%s' instead of '%s'" %
+								(mytype,
+								atom.replace("perl-core/","virtual/perl-"),
+								atom))
+
+					if buildtime and \
+						not is_blocker and \
+						not inherited_java_eclass and \
+						atom.cp == "virtual/jdk":
+						self.qatracker.add_error(
+							'java.eclassesnotused', ebuild.relative_path)
+					elif buildtime and \
+						not is_blocker and \
+						not inherited_wxwidgets_eclass and \
+						atom.cp == "x11-libs/wxGTK":
+						self.qatracker.add_error(
+							'wxwidgets.eclassnotused',
+							"%s: %ss on x11-libs/wxGTK without inheriting"
+							" wxwidgets.eclass" % (ebuild.relative_path, mytype))
+					elif runtime:
+						if not is_blocker and \
+							atom.cp in suspect_rdepend:
+							self.qatracker.add_error(
+								mytype + '.suspect',
+								ebuild.relative_path + ": '%s'" % atom)
+
+					if atom.operator == "~" and \
+						portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
+						qacat = 'dependency.badtilde'
+						self.qatracker.add_error(
+							qacat, "%s: %s uses the ~ operator"
+							" with a non-zero revision: '%s'" %
+							(ebuild.relative_path, mytype, atom))
+
+					check_missingslot(atom, mytype, ebuild.eapi, self.portdb, self.qatracker,
+						ebuild.relative_path, ebuild.metadata)
+
+			type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
+
+		for m, b in zip(type_list, badsyntax):
+			if m.endswith("DEPEND"):
+				qacat = "dependency.syntax"
+			else:
+				qacat = m + ".syntax"
+			self.qatracker.add_error(
+				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+	@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 7b07a95..7f770c3 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -19,13 +19,11 @@ 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.check_missingslot import check_missingslot
 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
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
-from repoman.qa_data import missingvars, suspect_virtual, suspect_rdepend
 from repoman.repos import repo_metadata
 from repoman.modules.scan.scan import scan
 from repoman.modules.vcs.vcs import vcs_files_to_cps
@@ -301,7 +299,7 @@ class Scanner(object):
 				('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
 				('thirdpartymirrors', 'ThirdPartyMirrors'),
 				('description', 'DescriptionChecks'), (None, 'KeywordChecks'),
-				('arches', 'ArchChecks'),
+				('arches', 'ArchChecks'), ('depend', 'DependChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -358,112 +356,9 @@ class Scanner(object):
 			badprovsyntax = False
 			# catpkg = catdir + "/" + y_ebuild
 
-			inherited_java_eclass = "java-pkg-2" in dynamic_data['ebuild'].inherited or \
-				"java-pkg-opt-2" in dynamic_data['ebuild'].inherited,
-			inherited_wxwidgets_eclass = "wxwidgets" in dynamic_data['ebuild'].inherited
-			# operator_tokens = set(["||", "(", ")"])
-			type_list, badsyntax = [], []
-			for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
-				mydepstr = dynamic_data['ebuild'].metadata[mytype]
-
-				buildtime = mytype in Package._buildtime_keys
-				runtime = mytype in Package._runtime_keys
-				token_class = None
-				if mytype.endswith("DEPEND"):
-					token_class = portage.dep.Atom
-
-				try:
-					atoms = portage.dep.use_reduce(
-						mydepstr, matchall=1, flat=True,
-						is_valid_flag=dynamic_data['pkg'].iuse.is_valid_flag, token_class=token_class)
-				except portage.exception.InvalidDependString as e:
-					atoms = None
-					badsyntax.append(str(e))
-
-				if atoms and mytype.endswith("DEPEND"):
-					if runtime and \
-						"test?" in mydepstr.split():
-						self.qatracker.add_error(
-							mytype + '.suspect',
-							"%s: 'test?' USE conditional in %s" %
-							(dynamic_data['ebuild'].relative_path, mytype))
-
-					for atom in atoms:
-						if atom == "||":
-							continue
-
-						is_blocker = atom.blocker
-
-						# Skip dependency.unknown for blockers, so that we
-						# don't encourage people to remove necessary blockers,
-						# as discussed in bug 382407. We use atom.without_use
-						# due to bug 525376.
-						if not is_blocker and \
-							not self.portdb.xmatch("match-all", atom.without_use) and \
-							not atom.cp.startswith("virtual/"):
-							unknown_pkgs.add((mytype, atom.unevaluated_atom))
-
-						if dynamic_data['catdir'] != "virtual":
-							if not is_blocker and \
-								atom.cp in suspect_virtual:
-								self.qatracker.add_error(
-									'virtual.suspect', dynamic_data['ebuild'].relative_path +
-									": %s: consider using '%s' instead of '%s'" %
-									(mytype, suspect_virtual[atom.cp], atom))
-							if not is_blocker and \
-								atom.cp.startswith("perl-core/"):
-								self.qatracker.add_error('dependency.perlcore',
-									dynamic_data['ebuild'].relative_path +
-									": %s: please use '%s' instead of '%s'" %
-									(mytype,
-									atom.replace("perl-core/","virtual/perl-"),
-									atom))
-
-						if buildtime and \
-							not is_blocker and \
-							not inherited_java_eclass and \
-							atom.cp == "virtual/jdk":
-							self.qatracker.add_error(
-								'java.eclassesnotused', dynamic_data['ebuild'].relative_path)
-						elif buildtime and \
-							not is_blocker and \
-							not inherited_wxwidgets_eclass and \
-							atom.cp == "x11-libs/wxGTK":
-							self.qatracker.add_error(
-								'wxwidgets.eclassnotused',
-								"%s: %ss on x11-libs/wxGTK without inheriting"
-								" wxwidgets.eclass" % (dynamic_data['ebuild'].relative_path, mytype))
-						elif runtime:
-							if not is_blocker and \
-								atom.cp in suspect_rdepend:
-								self.qatracker.add_error(
-									mytype + '.suspect',
-									dynamic_data['ebuild'].relative_path + ": '%s'" % atom)
-
-						if atom.operator == "~" and \
-							portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
-							qacat = 'dependency.badtilde'
-							self.qatracker.add_error(
-								qacat, "%s: %s uses the ~ operator"
-								" with a non-zero revision: '%s'" %
-								(dynamic_data['ebuild'].relative_path, mytype, atom))
-
-						check_missingslot(atom, mytype, dynamic_data['ebuild'].eapi, self.portdb, self.qatracker,
-							dynamic_data['ebuild'].relative_path, dynamic_data['ebuild'].metadata)
-
-				type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
-
-			for m, b in zip(type_list, badsyntax):
-				if m.endswith("DEPEND"):
-					qacat = "dependency.syntax"
-				else:
-					qacat = m + ".syntax"
-				self.qatracker.add_error(
-					qacat, "%s: %s: %s" % (dynamic_data['ebuild'].relative_path, m, b))
-
-			badlicsyntax = len([z for z in type_list if z == "LICENSE"])
-			badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
-			baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
+			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
+			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
 			badlicsyntax = badlicsyntax > 0
 			badprovsyntax = badprovsyntax > 0
 
@@ -626,7 +521,7 @@ class Scanner(object):
 									# aren't counted for *DEPEND.bad, so we
 									# ignore them here.
 									if not atom.blocker:
-										unknown_pkgs.discard(
+										dynamic_data['unknown_pkgs'].discard(
 											(mytype, atom.unevaluated_atom))
 
 								if not prof.sub_path:
@@ -671,9 +566,9 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and unknown_pkgs:
+			if not baddepsyntax and dynamic_data['unknown_pkgs']:
 				type_map = {}
-				for mytype, atom in unknown_pkgs:
+				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)
 				for mytype, atoms in type_map.items():
 					self.qatracker.add_error(


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-21 19:42 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-21 19:42 UTC (permalink / raw
  To: gentoo-commits

commit:     ebcae720ecafb57b2a7e60292e8e045951fd1d7a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 08:09:33 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 21 19:28:19 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ebcae720

repoman: Create a new DependUnknown plugin class

 pym/repoman/modules/scan/depend/__init__.py |  8 ++++++++
 pym/repoman/modules/scan/depend/unknown.py  | 30 +++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 10 +---------
 3 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index 2dac94b..65555b4 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -26,6 +26,14 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'unknown-module': {
+			'name': "unknown",
+			'class': "DependUnknown",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py
new file mode 100644
index 0000000..61d51b9
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/unknown.py
@@ -0,0 +1,30 @@
+# -*- coding:utf-8 -*-
+
+
+class DependUnknown(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		if not baddepsyntax and unknown_pkgs:
+			type_map = {}
+			for mytype, atom in unknown_pkgs:
+				type_map.setdefault(mytype, set()).add(atom)
+			for mytype, atoms in type_map.items():
+				self.qatracker.add_error(
+					"dependency.unknown", "%s: %s: %s"
+					% (ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
+		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 9223876..1cd37d0 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -289,6 +289,7 @@ class Scanner(object):
 				('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
 				# Options.is_forced() is used to bypass further checks
 				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
+				('unknown', 'DependUnknown'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -316,15 +317,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
-				type_map = {}
-				for mytype, atom in dynamic_data['unknown_pkgs']:
-					type_map.setdefault(mytype, set()).add(atom)
-				for mytype, atoms in type_map.items():
-					self.qatracker.add_error(
-						"dependency.unknown", "%s: %s: %s"
-						% (dynamic_data['ebuild'].relative_path, mytype, ", ".join(sorted(atoms))))
-
 		# check if there are unused local USE-descriptions in metadata.xml
 		# (unless there are any invalids, to avoid noise)
 		if dynamic_data['allvalid']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-23  1:42 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-23  1:42 UTC (permalink / raw
  To: gentoo-commits

commit:     3399926a9ef8fc1e0f702c5c6b95f44edf3e67f8
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 21:19:59 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 23 01:30:34 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3399926a

repoman: Migrate some additional Dependency code to the plugin

 pym/repoman/modules/scan/depend/depend.py | 13 ++++++++++++-
 pym/repoman/scanner.py                    | 22 +++-------------------
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
index 8a0ff48..7f1d007 100644
--- a/pym/repoman/modules/scan/depend/depend.py
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -1,3 +1,5 @@
+# -*- coding:utf-8 -*-
+
 
 from _emerge.Package import Package
 
@@ -121,7 +123,16 @@ class DependChecks(object):
 				qacat = m + ".syntax"
 			self.qatracker.add_error(
 				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
-		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+		# data required for some other tests
+		badlicsyntax = len([z for z in type_list if z == "LICENSE"])
+		badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
+		baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+		badlicsyntax = badlicsyntax > 0
+		#badprovsyntax = badprovsyntax > 0
+
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list,
+			'badlicsyntax': badlicsyntax, 'baddepsyntax': baddepsyntax}
 
 	@property
 	def runInPkgs(self):

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index d42fd33..6d5416b 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -324,26 +324,10 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if dynamic_data['live_ebuild'] and self.repo_settings.repo_config.name == "gentoo":
-				self.liveeclasscheck.check(
-					dynamic_data['pkg'], xpkg, dynamic_data['ebuild'], y_ebuild, dynamic_data['ebuild'].keywords, self.repo_metadata['pmaskdict'])
-
-			unknown_pkgs = set()
-			baddepsyntax = False
-			badlicsyntax = False
-			badprovsyntax = False
-			# catpkg = catdir + "/" + y_ebuild
-
-			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
-			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
-			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
-			badlicsyntax = badlicsyntax > 0
-			badprovsyntax = badprovsyntax > 0
-
 			used_useflags = used_useflags.union(dynamic_data['ebuild_UsedUseFlags'])
 
 			# license checks
-			if not badlicsyntax:
+			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)
@@ -449,7 +433,7 @@ class Scanner(object):
 				dep_settings.usemask = dep_settings._use_manager.getUseMask(
 					dynamic_data['pkg'], stable=dep_settings._parent_stable)
 
-				if not baddepsyntax:
+				if not dynamic_data['baddepsyntax']:
 					ismasked = not dynamic_data['ebuild'].archs or \
 						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
 						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
@@ -539,7 +523,7 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and dynamic_data['unknown_pkgs']:
+			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-23  1:42 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-23  1:42 UTC (permalink / raw
  To: gentoo-commits

commit:     b580a0b47e7f010d5b651a274746128164b9c7cd
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 08:09:33 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 23 01:37:04 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b580a0b4

repoman: Create a new DependUnknown plugin class

 pym/repoman/modules/scan/depend/__init__.py |  9 +++++++++
 pym/repoman/modules/scan/depend/unknown.py  | 30 +++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 10 +---------
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index cddb7f1..9fd7970 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -28,6 +28,15 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'unknown-module': {
+			'name': "unknown",
+			'sourcefile': "unknown",
+			'class': "DependUnknown",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py
new file mode 100644
index 0000000..61d51b9
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/unknown.py
@@ -0,0 +1,30 @@
+# -*- coding:utf-8 -*-
+
+
+class DependUnknown(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		if not baddepsyntax and unknown_pkgs:
+			type_map = {}
+			for mytype, atom in unknown_pkgs:
+				type_map.setdefault(mytype, set()).add(atom)
+			for mytype, atoms in type_map.items():
+				self.qatracker.add_error(
+					"dependency.unknown", "%s: %s: %s"
+					% (ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
+		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 9223876..1cd37d0 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -289,6 +289,7 @@ class Scanner(object):
 				('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
 				# Options.is_forced() is used to bypass further checks
 				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
+				('unknown', 'DependUnknown'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -316,15 +317,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
-				type_map = {}
-				for mytype, atom in dynamic_data['unknown_pkgs']:
-					type_map.setdefault(mytype, set()).add(atom)
-				for mytype, atoms in type_map.items():
-					self.qatracker.add_error(
-						"dependency.unknown", "%s: %s: %s"
-						% (dynamic_data['ebuild'].relative_path, mytype, ", ".join(sorted(atoms))))
-
 		# check if there are unused local USE-descriptions in metadata.xml
 		# (unless there are any invalids, to avoid noise)
 		if dynamic_data['allvalid']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-27 23:15 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-27 23:15 UTC (permalink / raw
  To: gentoo-commits

commit:     403c638f1a29097eb8de9e541c531e0d5ae7fc67
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 20:38:11 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Jan 27 22:44:22 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=403c638f

repoman: New DependChecks class plugin

Migrate code from _scan_ebuilds to the plugin system

 pym/repoman/modules/scan/depend/__init__.py |  24 +++++
 pym/repoman/modules/scan/depend/depend.py   | 132 ++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 119 ++-----------------------
 3 files changed, 163 insertions(+), 112 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
new file mode 100644
index 0000000..ebc716c
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -0,0 +1,24 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Depend plug-in module for repoman.
+Performs Dependency checks on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+	'name': 'depend',
+	'description': doc,
+	'provides':{
+		'depend-module': {
+			'name': "depend",
+			'sourcefile': "depend",
+			'class': "DependChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
+	}
+}
+

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
new file mode 100644
index 0000000..8a0ff48
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -0,0 +1,132 @@
+
+from _emerge.Package import Package
+
+from repoman.check_missingslot import check_missingslot
+# import our initialized portage instance
+from repoman._portage import portage
+from repoman.qa_data import suspect_virtual, suspect_rdepend
+
+
+class DependChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+
+		unknown_pkgs = set()
+
+		inherited_java_eclass = "java-pkg-2" in ebuild.inherited or \
+			"java-pkg-opt-2" in ebuild.inherited,
+		inherited_wxwidgets_eclass = "wxwidgets" in ebuild.inherited
+		# operator_tokens = set(["||", "(", ")"])
+		type_list, badsyntax = [], []
+		for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
+			mydepstr = ebuild.metadata[mytype]
+
+			buildtime = mytype in Package._buildtime_keys
+			runtime = mytype in Package._runtime_keys
+			token_class = None
+			if mytype.endswith("DEPEND"):
+				token_class = portage.dep.Atom
+
+			try:
+				atoms = portage.dep.use_reduce(
+					mydepstr, matchall=1, flat=True,
+					is_valid_flag=pkg.iuse.is_valid_flag, token_class=token_class)
+			except portage.exception.InvalidDependString as e:
+				atoms = None
+				badsyntax.append(str(e))
+
+			if atoms and mytype.endswith("DEPEND"):
+				if runtime and \
+					"test?" in mydepstr.split():
+					self.qatracker.add_error(
+						mytype + '.suspect',
+						"%s: 'test?' USE conditional in %s" %
+						(ebuild.relative_path, mytype))
+
+				for atom in atoms:
+					if atom == "||":
+						continue
+
+					is_blocker = atom.blocker
+
+					# Skip dependency.unknown for blockers, so that we
+					# don't encourage people to remove necessary blockers,
+					# as discussed in bug 382407. We use atom.without_use
+					# due to bug 525376.
+					if not is_blocker and \
+						not self.portdb.xmatch("match-all", atom.without_use) and \
+						not atom.cp.startswith("virtual/"):
+						unknown_pkgs.add((mytype, atom.unevaluated_atom))
+
+					if kwargs.get('catdir') != "virtual":
+						if not is_blocker and \
+							atom.cp in suspect_virtual:
+							self.qatracker.add_error(
+								'virtual.suspect', ebuild.relative_path +
+								": %s: consider using '%s' instead of '%s'" %
+								(mytype, suspect_virtual[atom.cp], atom))
+						if not is_blocker and \
+							atom.cp.startswith("perl-core/"):
+							self.qatracker.add_error('dependency.perlcore',
+								ebuild.relative_path +
+								": %s: please use '%s' instead of '%s'" %
+								(mytype,
+								atom.replace("perl-core/","virtual/perl-"),
+								atom))
+
+					if buildtime and \
+						not is_blocker and \
+						not inherited_java_eclass and \
+						atom.cp == "virtual/jdk":
+						self.qatracker.add_error(
+							'java.eclassesnotused', ebuild.relative_path)
+					elif buildtime and \
+						not is_blocker and \
+						not inherited_wxwidgets_eclass and \
+						atom.cp == "x11-libs/wxGTK":
+						self.qatracker.add_error(
+							'wxwidgets.eclassnotused',
+							"%s: %ss on x11-libs/wxGTK without inheriting"
+							" wxwidgets.eclass" % (ebuild.relative_path, mytype))
+					elif runtime:
+						if not is_blocker and \
+							atom.cp in suspect_rdepend:
+							self.qatracker.add_error(
+								mytype + '.suspect',
+								ebuild.relative_path + ": '%s'" % atom)
+
+					if atom.operator == "~" and \
+						portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
+						qacat = 'dependency.badtilde'
+						self.qatracker.add_error(
+							qacat, "%s: %s uses the ~ operator"
+							" with a non-zero revision: '%s'" %
+							(ebuild.relative_path, mytype, atom))
+
+					check_missingslot(atom, mytype, ebuild.eapi, self.portdb, self.qatracker,
+						ebuild.relative_path, ebuild.metadata)
+
+			type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
+
+		for m, b in zip(type_list, badsyntax):
+			if m.endswith("DEPEND"):
+				qacat = "dependency.syntax"
+			else:
+				qacat = m + ".syntax"
+			self.qatracker.add_error(
+				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+	@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 4cf7ca1..6ff4eeb 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -19,13 +19,11 @@ 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.check_missingslot import check_missingslot
 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
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
-from repoman.qa_data import missingvars, suspect_virtual, suspect_rdepend
 from repoman.repos import repo_metadata
 from repoman.modules.scan.scan import scan
 from repoman.modules.vcs.vcs import vcs_files_to_cps
@@ -304,7 +302,7 @@ class Scanner(object):
 				('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
 				('thirdpartymirrors', 'ThirdPartyMirrors'),
 				('description', 'DescriptionChecks'), (None, 'KeywordChecks'),
-				('arches', 'ArchChecks'),
+				('arches', 'ArchChecks'), ('depend', 'DependChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -361,112 +359,9 @@ class Scanner(object):
 			badprovsyntax = False
 			# catpkg = catdir + "/" + y_ebuild
 
-			inherited_java_eclass = "java-pkg-2" in dynamic_data['ebuild'].inherited or \
-				"java-pkg-opt-2" in dynamic_data['ebuild'].inherited,
-			inherited_wxwidgets_eclass = "wxwidgets" in dynamic_data['ebuild'].inherited
-			# operator_tokens = set(["||", "(", ")"])
-			type_list, badsyntax = [], []
-			for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
-				mydepstr = dynamic_data['ebuild'].metadata[mytype]
-
-				buildtime = mytype in Package._buildtime_keys
-				runtime = mytype in Package._runtime_keys
-				token_class = None
-				if mytype.endswith("DEPEND"):
-					token_class = portage.dep.Atom
-
-				try:
-					atoms = portage.dep.use_reduce(
-						mydepstr, matchall=1, flat=True,
-						is_valid_flag=dynamic_data['pkg'].iuse.is_valid_flag, token_class=token_class)
-				except portage.exception.InvalidDependString as e:
-					atoms = None
-					badsyntax.append(str(e))
-
-				if atoms and mytype.endswith("DEPEND"):
-					if runtime and \
-						"test?" in mydepstr.split():
-						self.qatracker.add_error(
-							mytype + '.suspect',
-							"%s: 'test?' USE conditional in %s" %
-							(dynamic_data['ebuild'].relative_path, mytype))
-
-					for atom in atoms:
-						if atom == "||":
-							continue
-
-						is_blocker = atom.blocker
-
-						# Skip dependency.unknown for blockers, so that we
-						# don't encourage people to remove necessary blockers,
-						# as discussed in bug 382407. We use atom.without_use
-						# due to bug 525376.
-						if not is_blocker and \
-							not self.portdb.xmatch("match-all", atom.without_use) and \
-							not atom.cp.startswith("virtual/"):
-							unknown_pkgs.add((mytype, atom.unevaluated_atom))
-
-						if dynamic_data['catdir'] != "virtual":
-							if not is_blocker and \
-								atom.cp in suspect_virtual:
-								self.qatracker.add_error(
-									'virtual.suspect', dynamic_data['ebuild'].relative_path +
-									": %s: consider using '%s' instead of '%s'" %
-									(mytype, suspect_virtual[atom.cp], atom))
-							if not is_blocker and \
-								atom.cp.startswith("perl-core/"):
-								self.qatracker.add_error('dependency.perlcore',
-									dynamic_data['ebuild'].relative_path +
-									": %s: please use '%s' instead of '%s'" %
-									(mytype,
-									atom.replace("perl-core/","virtual/perl-"),
-									atom))
-
-						if buildtime and \
-							not is_blocker and \
-							not inherited_java_eclass and \
-							atom.cp == "virtual/jdk":
-							self.qatracker.add_error(
-								'java.eclassesnotused', dynamic_data['ebuild'].relative_path)
-						elif buildtime and \
-							not is_blocker and \
-							not inherited_wxwidgets_eclass and \
-							atom.cp == "x11-libs/wxGTK":
-							self.qatracker.add_error(
-								'wxwidgets.eclassnotused',
-								"%s: %ss on x11-libs/wxGTK without inheriting"
-								" wxwidgets.eclass" % (dynamic_data['ebuild'].relative_path, mytype))
-						elif runtime:
-							if not is_blocker and \
-								atom.cp in suspect_rdepend:
-								self.qatracker.add_error(
-									mytype + '.suspect',
-									dynamic_data['ebuild'].relative_path + ": '%s'" % atom)
-
-						if atom.operator == "~" and \
-							portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
-							qacat = 'dependency.badtilde'
-							self.qatracker.add_error(
-								qacat, "%s: %s uses the ~ operator"
-								" with a non-zero revision: '%s'" %
-								(dynamic_data['ebuild'].relative_path, mytype, atom))
-
-						check_missingslot(atom, mytype, dynamic_data['ebuild'].eapi, self.portdb, self.qatracker,
-							dynamic_data['ebuild'].relative_path, dynamic_data['ebuild'].metadata)
-
-				type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
-
-			for m, b in zip(type_list, badsyntax):
-				if m.endswith("DEPEND"):
-					qacat = "dependency.syntax"
-				else:
-					qacat = m + ".syntax"
-				self.qatracker.add_error(
-					qacat, "%s: %s: %s" % (dynamic_data['ebuild'].relative_path, m, b))
-
-			badlicsyntax = len([z for z in type_list if z == "LICENSE"])
-			badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
-			baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
+			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
+			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
 			badlicsyntax = badlicsyntax > 0
 			badprovsyntax = badprovsyntax > 0
 
@@ -629,7 +524,7 @@ class Scanner(object):
 									# aren't counted for *DEPEND.bad, so we
 									# ignore them here.
 									if not atom.blocker:
-										unknown_pkgs.discard(
+										dynamic_data['unknown_pkgs'].discard(
 											(mytype, atom.unevaluated_atom))
 
 								if not prof.sub_path:
@@ -674,9 +569,9 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and unknown_pkgs:
+			if not baddepsyntax and dynamic_data['unknown_pkgs']:
 				type_map = {}
-				for mytype, atom in unknown_pkgs:
+				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)
 				for mytype, atoms in type_map.items():
 					self.qatracker.add_error(


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-29  5:01 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-29  5:01 UTC (permalink / raw
  To: gentoo-commits

commit:     a997689bc6a024290ad4b11a8a94a644d4c02d64
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 20:38:11 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Jan 29 04:52:56 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a997689b

repoman: New DependChecks class plugin

Migrate code from _scan_ebuilds to the plugin system

 pym/repoman/modules/scan/depend/__init__.py |  24 +++++
 pym/repoman/modules/scan/depend/depend.py   | 132 ++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 119 ++-----------------------
 3 files changed, 163 insertions(+), 112 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
new file mode 100644
index 0000000..ebc716c
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -0,0 +1,24 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Depend plug-in module for repoman.
+Performs Dependency checks on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+	'name': 'depend',
+	'description': doc,
+	'provides':{
+		'depend-module': {
+			'name': "depend",
+			'sourcefile': "depend",
+			'class': "DependChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
+	}
+}
+

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
new file mode 100644
index 0000000..8a0ff48
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -0,0 +1,132 @@
+
+from _emerge.Package import Package
+
+from repoman.check_missingslot import check_missingslot
+# import our initialized portage instance
+from repoman._portage import portage
+from repoman.qa_data import suspect_virtual, suspect_rdepend
+
+
+class DependChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+
+		unknown_pkgs = set()
+
+		inherited_java_eclass = "java-pkg-2" in ebuild.inherited or \
+			"java-pkg-opt-2" in ebuild.inherited,
+		inherited_wxwidgets_eclass = "wxwidgets" in ebuild.inherited
+		# operator_tokens = set(["||", "(", ")"])
+		type_list, badsyntax = [], []
+		for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
+			mydepstr = ebuild.metadata[mytype]
+
+			buildtime = mytype in Package._buildtime_keys
+			runtime = mytype in Package._runtime_keys
+			token_class = None
+			if mytype.endswith("DEPEND"):
+				token_class = portage.dep.Atom
+
+			try:
+				atoms = portage.dep.use_reduce(
+					mydepstr, matchall=1, flat=True,
+					is_valid_flag=pkg.iuse.is_valid_flag, token_class=token_class)
+			except portage.exception.InvalidDependString as e:
+				atoms = None
+				badsyntax.append(str(e))
+
+			if atoms and mytype.endswith("DEPEND"):
+				if runtime and \
+					"test?" in mydepstr.split():
+					self.qatracker.add_error(
+						mytype + '.suspect',
+						"%s: 'test?' USE conditional in %s" %
+						(ebuild.relative_path, mytype))
+
+				for atom in atoms:
+					if atom == "||":
+						continue
+
+					is_blocker = atom.blocker
+
+					# Skip dependency.unknown for blockers, so that we
+					# don't encourage people to remove necessary blockers,
+					# as discussed in bug 382407. We use atom.without_use
+					# due to bug 525376.
+					if not is_blocker and \
+						not self.portdb.xmatch("match-all", atom.without_use) and \
+						not atom.cp.startswith("virtual/"):
+						unknown_pkgs.add((mytype, atom.unevaluated_atom))
+
+					if kwargs.get('catdir') != "virtual":
+						if not is_blocker and \
+							atom.cp in suspect_virtual:
+							self.qatracker.add_error(
+								'virtual.suspect', ebuild.relative_path +
+								": %s: consider using '%s' instead of '%s'" %
+								(mytype, suspect_virtual[atom.cp], atom))
+						if not is_blocker and \
+							atom.cp.startswith("perl-core/"):
+							self.qatracker.add_error('dependency.perlcore',
+								ebuild.relative_path +
+								": %s: please use '%s' instead of '%s'" %
+								(mytype,
+								atom.replace("perl-core/","virtual/perl-"),
+								atom))
+
+					if buildtime and \
+						not is_blocker and \
+						not inherited_java_eclass and \
+						atom.cp == "virtual/jdk":
+						self.qatracker.add_error(
+							'java.eclassesnotused', ebuild.relative_path)
+					elif buildtime and \
+						not is_blocker and \
+						not inherited_wxwidgets_eclass and \
+						atom.cp == "x11-libs/wxGTK":
+						self.qatracker.add_error(
+							'wxwidgets.eclassnotused',
+							"%s: %ss on x11-libs/wxGTK without inheriting"
+							" wxwidgets.eclass" % (ebuild.relative_path, mytype))
+					elif runtime:
+						if not is_blocker and \
+							atom.cp in suspect_rdepend:
+							self.qatracker.add_error(
+								mytype + '.suspect',
+								ebuild.relative_path + ": '%s'" % atom)
+
+					if atom.operator == "~" and \
+						portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
+						qacat = 'dependency.badtilde'
+						self.qatracker.add_error(
+							qacat, "%s: %s uses the ~ operator"
+							" with a non-zero revision: '%s'" %
+							(ebuild.relative_path, mytype, atom))
+
+					check_missingslot(atom, mytype, ebuild.eapi, self.portdb, self.qatracker,
+						ebuild.relative_path, ebuild.metadata)
+
+			type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
+
+		for m, b in zip(type_list, badsyntax):
+			if m.endswith("DEPEND"):
+				qacat = "dependency.syntax"
+			else:
+				qacat = m + ".syntax"
+			self.qatracker.add_error(
+				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+	@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 4cf7ca1..6ff4eeb 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -19,13 +19,11 @@ 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.check_missingslot import check_missingslot
 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
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
-from repoman.qa_data import missingvars, suspect_virtual, suspect_rdepend
 from repoman.repos import repo_metadata
 from repoman.modules.scan.scan import scan
 from repoman.modules.vcs.vcs import vcs_files_to_cps
@@ -304,7 +302,7 @@ class Scanner(object):
 				('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
 				('thirdpartymirrors', 'ThirdPartyMirrors'),
 				('description', 'DescriptionChecks'), (None, 'KeywordChecks'),
-				('arches', 'ArchChecks'),
+				('arches', 'ArchChecks'), ('depend', 'DependChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -361,112 +359,9 @@ class Scanner(object):
 			badprovsyntax = False
 			# catpkg = catdir + "/" + y_ebuild
 
-			inherited_java_eclass = "java-pkg-2" in dynamic_data['ebuild'].inherited or \
-				"java-pkg-opt-2" in dynamic_data['ebuild'].inherited,
-			inherited_wxwidgets_eclass = "wxwidgets" in dynamic_data['ebuild'].inherited
-			# operator_tokens = set(["||", "(", ")"])
-			type_list, badsyntax = [], []
-			for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
-				mydepstr = dynamic_data['ebuild'].metadata[mytype]
-
-				buildtime = mytype in Package._buildtime_keys
-				runtime = mytype in Package._runtime_keys
-				token_class = None
-				if mytype.endswith("DEPEND"):
-					token_class = portage.dep.Atom
-
-				try:
-					atoms = portage.dep.use_reduce(
-						mydepstr, matchall=1, flat=True,
-						is_valid_flag=dynamic_data['pkg'].iuse.is_valid_flag, token_class=token_class)
-				except portage.exception.InvalidDependString as e:
-					atoms = None
-					badsyntax.append(str(e))
-
-				if atoms and mytype.endswith("DEPEND"):
-					if runtime and \
-						"test?" in mydepstr.split():
-						self.qatracker.add_error(
-							mytype + '.suspect',
-							"%s: 'test?' USE conditional in %s" %
-							(dynamic_data['ebuild'].relative_path, mytype))
-
-					for atom in atoms:
-						if atom == "||":
-							continue
-
-						is_blocker = atom.blocker
-
-						# Skip dependency.unknown for blockers, so that we
-						# don't encourage people to remove necessary blockers,
-						# as discussed in bug 382407. We use atom.without_use
-						# due to bug 525376.
-						if not is_blocker and \
-							not self.portdb.xmatch("match-all", atom.without_use) and \
-							not atom.cp.startswith("virtual/"):
-							unknown_pkgs.add((mytype, atom.unevaluated_atom))
-
-						if dynamic_data['catdir'] != "virtual":
-							if not is_blocker and \
-								atom.cp in suspect_virtual:
-								self.qatracker.add_error(
-									'virtual.suspect', dynamic_data['ebuild'].relative_path +
-									": %s: consider using '%s' instead of '%s'" %
-									(mytype, suspect_virtual[atom.cp], atom))
-							if not is_blocker and \
-								atom.cp.startswith("perl-core/"):
-								self.qatracker.add_error('dependency.perlcore',
-									dynamic_data['ebuild'].relative_path +
-									": %s: please use '%s' instead of '%s'" %
-									(mytype,
-									atom.replace("perl-core/","virtual/perl-"),
-									atom))
-
-						if buildtime and \
-							not is_blocker and \
-							not inherited_java_eclass and \
-							atom.cp == "virtual/jdk":
-							self.qatracker.add_error(
-								'java.eclassesnotused', dynamic_data['ebuild'].relative_path)
-						elif buildtime and \
-							not is_blocker and \
-							not inherited_wxwidgets_eclass and \
-							atom.cp == "x11-libs/wxGTK":
-							self.qatracker.add_error(
-								'wxwidgets.eclassnotused',
-								"%s: %ss on x11-libs/wxGTK without inheriting"
-								" wxwidgets.eclass" % (dynamic_data['ebuild'].relative_path, mytype))
-						elif runtime:
-							if not is_blocker and \
-								atom.cp in suspect_rdepend:
-								self.qatracker.add_error(
-									mytype + '.suspect',
-									dynamic_data['ebuild'].relative_path + ": '%s'" % atom)
-
-						if atom.operator == "~" and \
-							portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
-							qacat = 'dependency.badtilde'
-							self.qatracker.add_error(
-								qacat, "%s: %s uses the ~ operator"
-								" with a non-zero revision: '%s'" %
-								(dynamic_data['ebuild'].relative_path, mytype, atom))
-
-						check_missingslot(atom, mytype, dynamic_data['ebuild'].eapi, self.portdb, self.qatracker,
-							dynamic_data['ebuild'].relative_path, dynamic_data['ebuild'].metadata)
-
-				type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
-
-			for m, b in zip(type_list, badsyntax):
-				if m.endswith("DEPEND"):
-					qacat = "dependency.syntax"
-				else:
-					qacat = m + ".syntax"
-				self.qatracker.add_error(
-					qacat, "%s: %s: %s" % (dynamic_data['ebuild'].relative_path, m, b))
-
-			badlicsyntax = len([z for z in type_list if z == "LICENSE"])
-			badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
-			baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
+			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
+			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
 			badlicsyntax = badlicsyntax > 0
 			badprovsyntax = badprovsyntax > 0
 
@@ -629,7 +524,7 @@ class Scanner(object):
 									# aren't counted for *DEPEND.bad, so we
 									# ignore them here.
 									if not atom.blocker:
-										unknown_pkgs.discard(
+										dynamic_data['unknown_pkgs'].discard(
 											(mytype, atom.unevaluated_atom))
 
 								if not prof.sub_path:
@@ -674,9 +569,9 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and unknown_pkgs:
+			if not baddepsyntax and dynamic_data['unknown_pkgs']:
 				type_map = {}
-				for mytype, atom in unknown_pkgs:
+				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)
 				for mytype, atoms in type_map.items():
 					self.qatracker.add_error(


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-29  5:01 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-29  5:01 UTC (permalink / raw
  To: gentoo-commits

commit:     5514c7f91b65f07d5699535a99ed55bac9605c56
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 08:09:33 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Jan 29 04:52:59 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=5514c7f9

repoman: Create a new DependUnknown plugin class

 pym/repoman/modules/scan/depend/__init__.py |  9 +++++++++
 pym/repoman/modules/scan/depend/unknown.py  | 30 +++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 10 +---------
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index cddb7f1..9fd7970 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -28,6 +28,15 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'unknown-module': {
+			'name': "unknown",
+			'sourcefile': "unknown",
+			'class': "DependUnknown",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py
new file mode 100644
index 0000000..61d51b9
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/unknown.py
@@ -0,0 +1,30 @@
+# -*- coding:utf-8 -*-
+
+
+class DependUnknown(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		if not baddepsyntax and unknown_pkgs:
+			type_map = {}
+			for mytype, atom in unknown_pkgs:
+				type_map.setdefault(mytype, set()).add(atom)
+			for mytype, atoms in type_map.items():
+				self.qatracker.add_error(
+					"dependency.unknown", "%s: %s: %s"
+					% (ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
+		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 bd337fc..4472f88 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -292,6 +292,7 @@ class Scanner(object):
 				('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
 				# Options.is_forced() is used to bypass further checks
 				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
+				('unknown', 'DependUnknown'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -319,15 +320,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
-				type_map = {}
-				for mytype, atom in dynamic_data['unknown_pkgs']:
-					type_map.setdefault(mytype, set()).add(atom)
-				for mytype, atoms in type_map.items():
-					self.qatracker.add_error(
-						"dependency.unknown", "%s: %s: %s"
-						% (dynamic_data['ebuild'].relative_path, mytype, ", ".join(sorted(atoms))))
-
 		# check if there are unused local USE-descriptions in metadata.xml
 		# (unless there are any invalids, to avoid noise)
 		if dynamic_data['allvalid']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-30  6:58 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-30  6:58 UTC (permalink / raw
  To: gentoo-commits

commit:     32cd11a76a023009e6359d608b21e2dc3ab1c58e
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 20:38:11 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 06:33:55 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=32cd11a7

repoman: New DependChecks class plugin

Migrate code from _scan_ebuilds to the plugin system.

 pym/repoman/modules/scan/depend/__init__.py |  24 +++++
 pym/repoman/modules/scan/depend/depend.py   | 132 ++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 119 ++-----------------------
 3 files changed, 163 insertions(+), 112 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
new file mode 100644
index 0000000..ebc716c
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -0,0 +1,24 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Depend plug-in module for repoman.
+Performs Dependency checks on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+	'name': 'depend',
+	'description': doc,
+	'provides':{
+		'depend-module': {
+			'name': "depend",
+			'sourcefile': "depend",
+			'class': "DependChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
+	}
+}
+

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
new file mode 100644
index 0000000..8a0ff48
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -0,0 +1,132 @@
+
+from _emerge.Package import Package
+
+from repoman.check_missingslot import check_missingslot
+# import our initialized portage instance
+from repoman._portage import portage
+from repoman.qa_data import suspect_virtual, suspect_rdepend
+
+
+class DependChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+
+		unknown_pkgs = set()
+
+		inherited_java_eclass = "java-pkg-2" in ebuild.inherited or \
+			"java-pkg-opt-2" in ebuild.inherited,
+		inherited_wxwidgets_eclass = "wxwidgets" in ebuild.inherited
+		# operator_tokens = set(["||", "(", ")"])
+		type_list, badsyntax = [], []
+		for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
+			mydepstr = ebuild.metadata[mytype]
+
+			buildtime = mytype in Package._buildtime_keys
+			runtime = mytype in Package._runtime_keys
+			token_class = None
+			if mytype.endswith("DEPEND"):
+				token_class = portage.dep.Atom
+
+			try:
+				atoms = portage.dep.use_reduce(
+					mydepstr, matchall=1, flat=True,
+					is_valid_flag=pkg.iuse.is_valid_flag, token_class=token_class)
+			except portage.exception.InvalidDependString as e:
+				atoms = None
+				badsyntax.append(str(e))
+
+			if atoms and mytype.endswith("DEPEND"):
+				if runtime and \
+					"test?" in mydepstr.split():
+					self.qatracker.add_error(
+						mytype + '.suspect',
+						"%s: 'test?' USE conditional in %s" %
+						(ebuild.relative_path, mytype))
+
+				for atom in atoms:
+					if atom == "||":
+						continue
+
+					is_blocker = atom.blocker
+
+					# Skip dependency.unknown for blockers, so that we
+					# don't encourage people to remove necessary blockers,
+					# as discussed in bug 382407. We use atom.without_use
+					# due to bug 525376.
+					if not is_blocker and \
+						not self.portdb.xmatch("match-all", atom.without_use) and \
+						not atom.cp.startswith("virtual/"):
+						unknown_pkgs.add((mytype, atom.unevaluated_atom))
+
+					if kwargs.get('catdir') != "virtual":
+						if not is_blocker and \
+							atom.cp in suspect_virtual:
+							self.qatracker.add_error(
+								'virtual.suspect', ebuild.relative_path +
+								": %s: consider using '%s' instead of '%s'" %
+								(mytype, suspect_virtual[atom.cp], atom))
+						if not is_blocker and \
+							atom.cp.startswith("perl-core/"):
+							self.qatracker.add_error('dependency.perlcore',
+								ebuild.relative_path +
+								": %s: please use '%s' instead of '%s'" %
+								(mytype,
+								atom.replace("perl-core/","virtual/perl-"),
+								atom))
+
+					if buildtime and \
+						not is_blocker and \
+						not inherited_java_eclass and \
+						atom.cp == "virtual/jdk":
+						self.qatracker.add_error(
+							'java.eclassesnotused', ebuild.relative_path)
+					elif buildtime and \
+						not is_blocker and \
+						not inherited_wxwidgets_eclass and \
+						atom.cp == "x11-libs/wxGTK":
+						self.qatracker.add_error(
+							'wxwidgets.eclassnotused',
+							"%s: %ss on x11-libs/wxGTK without inheriting"
+							" wxwidgets.eclass" % (ebuild.relative_path, mytype))
+					elif runtime:
+						if not is_blocker and \
+							atom.cp in suspect_rdepend:
+							self.qatracker.add_error(
+								mytype + '.suspect',
+								ebuild.relative_path + ": '%s'" % atom)
+
+					if atom.operator == "~" and \
+						portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
+						qacat = 'dependency.badtilde'
+						self.qatracker.add_error(
+							qacat, "%s: %s uses the ~ operator"
+							" with a non-zero revision: '%s'" %
+							(ebuild.relative_path, mytype, atom))
+
+					check_missingslot(atom, mytype, ebuild.eapi, self.portdb, self.qatracker,
+						ebuild.relative_path, ebuild.metadata)
+
+			type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
+
+		for m, b in zip(type_list, badsyntax):
+			if m.endswith("DEPEND"):
+				qacat = "dependency.syntax"
+			else:
+				qacat = m + ".syntax"
+			self.qatracker.add_error(
+				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+	@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 7a1433a..40aafcc 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -19,13 +19,11 @@ 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.check_missingslot import check_missingslot
 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
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
-from repoman.qa_data import missingvars, suspect_virtual, suspect_rdepend
 from repoman.repos import repo_metadata
 from repoman.modules.scan.scan import scan
 from repoman.modules.vcs.vcs import vcs_files_to_cps
@@ -304,7 +302,7 @@ class Scanner(object):
 				('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
 				('thirdpartymirrors', 'ThirdPartyMirrors'),
 				('description', 'DescriptionChecks'), (None, 'KeywordChecks'),
-				('arches', 'ArchChecks'),
+				('arches', 'ArchChecks'), ('depend', 'DependChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -361,112 +359,9 @@ class Scanner(object):
 			badprovsyntax = False
 			# catpkg = catdir + "/" + y_ebuild
 
-			inherited_java_eclass = "java-pkg-2" in dynamic_data['ebuild'].inherited or \
-				"java-pkg-opt-2" in dynamic_data['ebuild'].inherited,
-			inherited_wxwidgets_eclass = "wxwidgets" in dynamic_data['ebuild'].inherited
-			# operator_tokens = set(["||", "(", ")"])
-			type_list, badsyntax = [], []
-			for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
-				mydepstr = dynamic_data['ebuild'].metadata[mytype]
-
-				buildtime = mytype in Package._buildtime_keys
-				runtime = mytype in Package._runtime_keys
-				token_class = None
-				if mytype.endswith("DEPEND"):
-					token_class = portage.dep.Atom
-
-				try:
-					atoms = portage.dep.use_reduce(
-						mydepstr, matchall=1, flat=True,
-						is_valid_flag=dynamic_data['pkg'].iuse.is_valid_flag, token_class=token_class)
-				except portage.exception.InvalidDependString as e:
-					atoms = None
-					badsyntax.append(str(e))
-
-				if atoms and mytype.endswith("DEPEND"):
-					if runtime and \
-						"test?" in mydepstr.split():
-						self.qatracker.add_error(
-							mytype + '.suspect',
-							"%s: 'test?' USE conditional in %s" %
-							(dynamic_data['ebuild'].relative_path, mytype))
-
-					for atom in atoms:
-						if atom == "||":
-							continue
-
-						is_blocker = atom.blocker
-
-						# Skip dependency.unknown for blockers, so that we
-						# don't encourage people to remove necessary blockers,
-						# as discussed in bug 382407. We use atom.without_use
-						# due to bug 525376.
-						if not is_blocker and \
-							not self.portdb.xmatch("match-all", atom.without_use) and \
-							not atom.cp.startswith("virtual/"):
-							unknown_pkgs.add((mytype, atom.unevaluated_atom))
-
-						if dynamic_data['catdir'] != "virtual":
-							if not is_blocker and \
-								atom.cp in suspect_virtual:
-								self.qatracker.add_error(
-									'virtual.suspect', dynamic_data['ebuild'].relative_path +
-									": %s: consider using '%s' instead of '%s'" %
-									(mytype, suspect_virtual[atom.cp], atom))
-							if not is_blocker and \
-								atom.cp.startswith("perl-core/"):
-								self.qatracker.add_error('dependency.perlcore',
-									dynamic_data['ebuild'].relative_path +
-									": %s: please use '%s' instead of '%s'" %
-									(mytype,
-									atom.replace("perl-core/","virtual/perl-"),
-									atom))
-
-						if buildtime and \
-							not is_blocker and \
-							not inherited_java_eclass and \
-							atom.cp == "virtual/jdk":
-							self.qatracker.add_error(
-								'java.eclassesnotused', dynamic_data['ebuild'].relative_path)
-						elif buildtime and \
-							not is_blocker and \
-							not inherited_wxwidgets_eclass and \
-							atom.cp == "x11-libs/wxGTK":
-							self.qatracker.add_error(
-								'wxwidgets.eclassnotused',
-								"%s: %ss on x11-libs/wxGTK without inheriting"
-								" wxwidgets.eclass" % (dynamic_data['ebuild'].relative_path, mytype))
-						elif runtime:
-							if not is_blocker and \
-								atom.cp in suspect_rdepend:
-								self.qatracker.add_error(
-									mytype + '.suspect',
-									dynamic_data['ebuild'].relative_path + ": '%s'" % atom)
-
-						if atom.operator == "~" and \
-							portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
-							qacat = 'dependency.badtilde'
-							self.qatracker.add_error(
-								qacat, "%s: %s uses the ~ operator"
-								" with a non-zero revision: '%s'" %
-								(dynamic_data['ebuild'].relative_path, mytype, atom))
-
-						check_missingslot(atom, mytype, dynamic_data['ebuild'].eapi, self.portdb, self.qatracker,
-							dynamic_data['ebuild'].relative_path, dynamic_data['ebuild'].metadata)
-
-				type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
-
-			for m, b in zip(type_list, badsyntax):
-				if m.endswith("DEPEND"):
-					qacat = "dependency.syntax"
-				else:
-					qacat = m + ".syntax"
-				self.qatracker.add_error(
-					qacat, "%s: %s: %s" % (dynamic_data['ebuild'].relative_path, m, b))
-
-			badlicsyntax = len([z for z in type_list if z == "LICENSE"])
-			badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
-			baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
+			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
+			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
 			badlicsyntax = badlicsyntax > 0
 			badprovsyntax = badprovsyntax > 0
 
@@ -629,7 +524,7 @@ class Scanner(object):
 									# aren't counted for *DEPEND.bad, so we
 									# ignore them here.
 									if not atom.blocker:
-										unknown_pkgs.discard(
+										dynamic_data['unknown_pkgs'].discard(
 											(mytype, atom.unevaluated_atom))
 
 								if not prof.sub_path:
@@ -674,9 +569,9 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and unknown_pkgs:
+			if not baddepsyntax and dynamic_data['unknown_pkgs']:
 				type_map = {}
-				for mytype, atom in unknown_pkgs:
+				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)
 				for mytype, atoms in type_map.items():
 					self.qatracker.add_error(


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-30  6:58 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-30  6:58 UTC (permalink / raw
  To: gentoo-commits

commit:     3c582beb1fc5fa5ba30ce7176c465243cf6ab0f5
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 08:09:33 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 06:51:57 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3c582beb

repoman: Create a new DependUnknown plugin class

 pym/repoman/modules/scan/depend/__init__.py |  9 +++++++++
 pym/repoman/modules/scan/depend/unknown.py  | 30 +++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 10 +---------
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index cddb7f1..9fd7970 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -28,6 +28,15 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'unknown-module': {
+			'name': "unknown",
+			'sourcefile': "unknown",
+			'class': "DependUnknown",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py
new file mode 100644
index 0000000..61d51b9
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/unknown.py
@@ -0,0 +1,30 @@
+# -*- coding:utf-8 -*-
+
+
+class DependUnknown(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		if not baddepsyntax and unknown_pkgs:
+			type_map = {}
+			for mytype, atom in unknown_pkgs:
+				type_map.setdefault(mytype, set()).add(atom)
+			for mytype, atoms in type_map.items():
+				self.qatracker.add_error(
+					"dependency.unknown", "%s: %s: %s"
+					% (ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
+		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 48b60a4..1e61eb6 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -290,6 +290,7 @@ class Scanner(object):
 				('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
 				# Options.is_forced() is used to bypass further checks
 				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
+				('unknown', 'DependUnknown'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -317,15 +318,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
-				type_map = {}
-				for mytype, atom in dynamic_data['unknown_pkgs']:
-					type_map.setdefault(mytype, set()).add(atom)
-				for mytype, atoms in type_map.items():
-					self.qatracker.add_error(
-						"dependency.unknown", "%s: %s: %s"
-						% (dynamic_data['ebuild'].relative_path, mytype, ", ".join(sorted(atoms))))
-
 		# check if there are unused local USE-descriptions in metadata.xml
 		# (unless there are any invalids, to avoid noise)
 		if dynamic_data['allvalid']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-30  6:58 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-30  6:58 UTC (permalink / raw
  To: gentoo-commits

commit:     ec283509924c7490e27c756286d379ef3196a6a1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 21:19:59 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 06:33:56 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ec283509

repoman: Migrate some additional Dependency code to the plugin

 pym/repoman/modules/scan/depend/depend.py | 13 ++++++++++++-
 pym/repoman/scanner.py                    | 22 +++-------------------
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
index 8a0ff48..7f1d007 100644
--- a/pym/repoman/modules/scan/depend/depend.py
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -1,3 +1,5 @@
+# -*- coding:utf-8 -*-
+
 
 from _emerge.Package import Package
 
@@ -121,7 +123,16 @@ class DependChecks(object):
 				qacat = m + ".syntax"
 			self.qatracker.add_error(
 				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
-		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+		# data required for some other tests
+		badlicsyntax = len([z for z in type_list if z == "LICENSE"])
+		badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
+		baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+		badlicsyntax = badlicsyntax > 0
+		#badprovsyntax = badprovsyntax > 0
+
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list,
+			'badlicsyntax': badlicsyntax, 'baddepsyntax': baddepsyntax}
 
 	@property
 	def runInPkgs(self):

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index 5c35519..804a3f2 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -327,26 +327,10 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if dynamic_data['live_ebuild'] and self.repo_settings.repo_config.name == "gentoo":
-				self.liveeclasscheck.check(
-					dynamic_data['pkg'], xpkg, dynamic_data['ebuild'], y_ebuild, dynamic_data['ebuild'].keywords, self.repo_metadata['pmaskdict'])
-
-			unknown_pkgs = set()
-			baddepsyntax = False
-			badlicsyntax = False
-			badprovsyntax = False
-			# catpkg = catdir + "/" + y_ebuild
-
-			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
-			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
-			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
-			badlicsyntax = badlicsyntax > 0
-			badprovsyntax = badprovsyntax > 0
-
 			used_useflags = used_useflags.union(dynamic_data['ebuild_UsedUseFlags'])
 
 			# license checks
-			if not badlicsyntax:
+			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)
@@ -452,7 +436,7 @@ class Scanner(object):
 				dep_settings.usemask = dep_settings._use_manager.getUseMask(
 					dynamic_data['pkg'], stable=dep_settings._parent_stable)
 
-				if not baddepsyntax:
+				if not dynamic_data['baddepsyntax']:
 					ismasked = not dynamic_data['ebuild'].archs or \
 						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
 						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
@@ -542,7 +526,7 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and dynamic_data['unknown_pkgs']:
+			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-30  6:58 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-30  6:58 UTC (permalink / raw
  To: gentoo-commits

commit:     fffc9f5c90f89c88210961e784ca6b69855a178a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 07:57:36 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 06:51:57 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=fffc9f5c

repoman: Move the large depency checks loop to a new plugin ProfileDependsChecks class

 pym/repoman/modules/scan/depend/__init__.py |   9 ++
 pym/repoman/modules/scan/depend/profile.py  | 211 ++++++++++++++++++++++++++++
 pym/repoman/repos.py                        |   1 +
 pym/repoman/scanner.py                      | 181 +-----------------------
 4 files changed, 228 insertions(+), 174 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index ebc716c..cddb7f1 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -19,6 +19,15 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'profile-module': {
+			'name': "profile",
+			'sourcefile': "profile",
+			'class': "ProfileDependsChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/profile.py b/pym/repoman/modules/scan/depend/profile.py
new file mode 100644
index 0000000..91c52cc
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/profile.py
@@ -0,0 +1,211 @@
+# -*- coding:utf-8 -*-
+
+
+import copy
+from pprint import pformat
+
+from _emerge.Package import Package
+
+# import our initialized portage instance
+from repoman._portage import portage
+from portage.dep import Atom
+
+
+def sort_key(item):
+	return item[2].sub_path
+
+
+class ProfileDependsChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+		self.profiles = kwargs.get('profiles')
+		self.options = kwargs.get('options')
+		self.repo_settings = kwargs.get('repo_settings')
+		self.include_arches = kwargs.get('include_arches')
+		self.caches = kwargs.get('caches')
+		self.repoman_incrementals = kwargs.get('repoman_incrementals')
+		self.env = kwargs.get('env')
+		self.have = kwargs.get('have')
+		self.dev_keywords = kwargs.get('dev_keywords')
+
+	def check(self, **kwargs):
+		arches = kwargs.get('arches')
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		relevant_profiles = []
+		for keyword, arch, groups in arches:
+			if arch not in self.profiles:
+				# A missing profile will create an error further down
+				# during the KEYWORDS verification.
+				continue
+
+			if self.include_arches is not None:
+				if arch not in self.include_arches:
+					continue
+
+			relevant_profiles.extend(
+				(keyword, groups, prof) for prof in self.profiles[arch])
+
+		relevant_profiles.sort(key=sort_key)
+
+		for keyword, groups, prof in relevant_profiles:
+
+			is_stable_profile = prof.status == "stable"
+			is_dev_profile = prof.status == "dev" and \
+				self.options.include_dev
+			is_exp_profile = prof.status == "exp" and \
+				self.options.include_exp_profiles == 'y'
+			if not (is_stable_profile or is_dev_profile or is_exp_profile):
+				continue
+
+			dep_settings = self.caches['arch'].get(prof.sub_path)
+			if dep_settings is None:
+				dep_settings = portage.config(
+					config_profile_path=prof.abs_path,
+					config_incrementals=self.repoman_incrementals,
+					config_root=self.repo_settings.config_root,
+					local_config=False,
+					_unmatched_removal=self.options.unmatched_removal,
+					env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
+				dep_settings.categories = self.repo_settings.repoman_settings.categories
+				if self.options.without_mask:
+					dep_settings._mask_manager_obj = \
+						copy.deepcopy(dep_settings._mask_manager)
+					dep_settings._mask_manager._pmaskdict.clear()
+				self.caches['arch'][prof.sub_path] = dep_settings
+
+			xmatch_cache_key = (prof.sub_path, tuple(groups))
+			xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
+			if xcache is None:
+				self.portdb.melt()
+				self.portdb.freeze()
+				xcache = self.portdb.xcache
+				xcache.update(self.caches['shared_xmatch'])
+				self.caches['arch_xmatch'][xmatch_cache_key] = xcache
+
+			self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
+			self.portdb.settings = dep_settings
+			self.portdb.xcache = xcache
+
+			dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
+			# just in case, prevent config.reset() from nuking these.
+			dep_settings.backup_changes("ACCEPT_KEYWORDS")
+
+			# This attribute is used in dbapi._match_use() to apply
+			# use.stable.{mask,force} settings based on the stable
+			# status of the parent package. This is required in order
+			# for USE deps of unstable packages to be resolved correctly,
+			# since otherwise use.stable.{mask,force} settings of
+			# dependencies may conflict (see bug #456342).
+			dep_settings._parent_stable = dep_settings._isStable(pkg)
+
+			# Handle package.use*.{force,mask) calculation, for use
+			# in dep_check.
+			dep_settings.useforce = dep_settings._use_manager.getUseForce(
+				pkg, stable=dep_settings._parent_stable)
+			dep_settings.usemask = dep_settings._use_manager.getUseMask(
+				pkg, stable=dep_settings._parent_stable)
+
+			if not baddepsyntax:
+				ismasked = not ebuild.archs or \
+					pkg.cpv not in self.portdb.xmatch("match-visible",
+					Atom("%s::%s" % (pkg.cp, self.repo_settings.repo_config.name)))
+				if ismasked:
+					if not self.have['pmasked']:
+						self.have['pmasked'] = bool(dep_settings._getMaskAtom(
+							pkg.cpv, ebuild.metadata))
+					if self.options.ignore_masked:
+						continue
+					# we are testing deps for a masked package; give it some lee-way
+					suffix = "masked"
+					matchmode = "minimum-all-ignore-profile"
+				else:
+					suffix = ""
+					matchmode = "minimum-visible"
+
+				if not self.have['dev_keywords']:
+					self.have['dev_keywords'] = \
+						bool(self.dev_keywords.intersection(ebuild.keywords))
+
+				if prof.status == "dev":
+					suffix = suffix + "indev"
+
+				for mytype in Package._dep_keys:
+
+					mykey = "dependency.bad" + suffix
+					myvalue = ebuild.metadata[mytype]
+					if not myvalue:
+						continue
+
+					success, atoms = portage.dep_check(
+						myvalue, self.portdb, dep_settings,
+						use="all", mode=matchmode, trees=self.repo_settings.trees)
+
+					if success:
+						if atoms:
+
+							# Don't bother with dependency.unknown for
+							# cases in which *DEPEND.bad is triggered.
+							for atom in atoms:
+								# dep_check returns all blockers and they
+								# aren't counted for *DEPEND.bad, so we
+								# ignore them here.
+								if not atom.blocker:
+									unknown_pkgs.discard(
+										(mytype, atom.unevaluated_atom))
+
+							if not prof.sub_path:
+								# old-style virtuals currently aren't
+								# resolvable with empty profile, since
+								# 'virtuals' mappings are unavailable
+								# (it would be expensive to search
+								# for PROVIDE in all ebuilds)
+								atoms = [
+									atom for atom in atoms if not (
+										atom.cp.startswith('virtual/')
+										and not self.portdb.cp_list(atom.cp))]
+
+							# we have some unsolvable deps
+							# remove ! deps, which always show up as unsatisfiable
+							atoms = [
+								str(atom.unevaluated_atom)
+								for atom in atoms if not atom.blocker]
+
+							# if we emptied out our list, continue:
+							if not atoms:
+								continue
+							if self.options.output_style in ['column']:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s) %s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, repr(atoms)))
+							else:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s)\n%s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, pformat(atoms, indent=6)))
+					else:
+						if self.options.output_style in ['column']:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s) %s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, repr(atoms)))
+						else:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s)\n%s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, pformat(atoms, indent=6)))
+		return {'continue': False}
+
+	@property
+	def runInPkgs(self):
+		return (False, [])
+
+	@property
+	def runInEbuilds(self):
+		return (True, [self.check])

diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py
index a34f785..39f53c1 100644
--- a/pym/repoman/repos.py
+++ b/pym/repoman/repos.py
@@ -28,6 +28,7 @@ class RepoSettings(object):
 		self, config_root, portdir, portdir_overlay,
 		repoman_settings=None, vcs_settings=None, options=None,
 		qawarnings=None):
+		self.config_root = config_root
 		self.repoman_settings = repoman_settings
 		self.vcs_settings = vcs_settings
 

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index b9c53a0..48b60a4 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -2,17 +2,12 @@
 
 from __future__ import print_function, unicode_literals
 
-import copy
 import logging
 from itertools import chain
-from pprint import pformat
-
-from _emerge.Package import Package
 
 import portage
 from portage import normalize_path
 from portage import os
-from portage.dep import Atom
 from portage.output import green
 from repoman.modules.commit import repochecks
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
@@ -33,10 +28,6 @@ MODULE_CONTROLLER = Modules(path=MODULES_PATH, namepath="repoman.modules.scan")
 MODULE_NAMES = MODULE_CONTROLLER.module_names[:]
 
 
-def sort_key(item):
-	return item[2].sub_path
-
-
 class Scanner(object):
 	'''Primary scan class.  Operates all the small Q/A tests and checks'''
 
@@ -197,6 +188,12 @@ class Scanner(object):
 			"checks": self.checks,
 			"repo_metadata": self.repo_metadata,
 			"profiles": self.profiles,
+			"include_arches": self.include_arches,
+			"caches": self.caches,
+			"repoman_incrementals": self.repoman_incrementals,
+			"env": self.env,
+			"have": self.have,
+			"dev_keywords": self.dev_keywords,
 		}
 		# initialize the plugin checks here
 		self.modules = {}
@@ -292,7 +289,7 @@ class Scanner(object):
 				('license', 'LicenseChecks'), ('restrict', 'RestrictChecks'),
 				('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
 				# Options.is_forced() is used to bypass further checks
-				('options', 'Options'),
+				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -320,170 +317,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			relevant_profiles = []
-			for keyword, arch, groups in dynamic_data['arches']:
-				if arch not in self.profiles:
-					# A missing profile will create an error further down
-					# during the KEYWORDS verification.
-					continue
-
-				if self.include_arches is not None:
-					if arch not in self.include_arches:
-						continue
-
-				relevant_profiles.extend(
-					(keyword, groups, prof) for prof in self.profiles[arch])
-
-			relevant_profiles.sort(key=sort_key)
-
-			for keyword, groups, prof in relevant_profiles:
-
-				is_stable_profile = prof.status == "stable"
-				is_dev_profile = prof.status == "dev" and \
-					self.options.include_dev
-				is_exp_profile = prof.status == "exp" and \
-					self.options.include_exp_profiles == 'y'
-				if not (is_stable_profile or is_dev_profile or is_exp_profile):
-					continue
-
-				dep_settings = self.caches['arch'].get(prof.sub_path)
-				if dep_settings is None:
-					dep_settings = portage.config(
-						config_profile_path=prof.abs_path,
-						config_incrementals=self.repoman_incrementals,
-						config_root=self.config_root,
-						local_config=False,
-						_unmatched_removal=self.options.unmatched_removal,
-						env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
-					dep_settings.categories = self.repo_settings.repoman_settings.categories
-					if self.options.without_mask:
-						dep_settings._mask_manager_obj = \
-							copy.deepcopy(dep_settings._mask_manager)
-						dep_settings._mask_manager._pmaskdict.clear()
-					self.caches['arch'][prof.sub_path] = dep_settings
-
-				xmatch_cache_key = (prof.sub_path, tuple(groups))
-				xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
-				if xcache is None:
-					self.portdb.melt()
-					self.portdb.freeze()
-					xcache = self.portdb.xcache
-					xcache.update(self.caches['shared_xmatch'])
-					self.caches['arch_xmatch'][xmatch_cache_key] = xcache
-
-				self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
-				self.portdb.settings = dep_settings
-				self.portdb.xcache = xcache
-
-				dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
-				# just in case, prevent config.reset() from nuking these.
-				dep_settings.backup_changes("ACCEPT_KEYWORDS")
-
-				# This attribute is used in dbapi._match_use() to apply
-				# use.stable.{mask,force} settings based on the stable
-				# status of the parent package. This is required in order
-				# for USE deps of unstable packages to be resolved correctly,
-				# since otherwise use.stable.{mask,force} settings of
-				# dependencies may conflict (see bug #456342).
-				dep_settings._parent_stable = dep_settings._isStable(dynamic_data['pkg'])
-
-				# Handle package.use*.{force,mask) calculation, for use
-				# in dep_check.
-				dep_settings.useforce = dep_settings._use_manager.getUseForce(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-				dep_settings.usemask = dep_settings._use_manager.getUseMask(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-
-				if not dynamic_data['baddepsyntax']:
-					ismasked = not dynamic_data['ebuild'].archs or \
-						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
-						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
-					if ismasked:
-						if not self.have['pmasked']:
-							self.have['pmasked'] = bool(dep_settings._getMaskAtom(
-								dynamic_data['pkg'].cpv, dynamic_data['pkg']._metadata))
-						if self.options.ignore_masked:
-							continue
-						# we are testing deps for a masked package; give it some lee-way
-						suffix = "masked"
-						matchmode = "minimum-all-ignore-profile"
-					else:
-						suffix = ""
-						matchmode = "minimum-visible"
-
-					if not self.have['dev_keywords']:
-						self.have['dev_keywords'] = \
-							bool(self.dev_keywords.intersection(dynamic_data['ebuild'].keywords))
-
-					if prof.status == "dev":
-						suffix = suffix + "indev"
-
-					for mytype in Package._dep_keys:
-
-						mykey = "dependency.bad" + suffix
-						myvalue = dynamic_data['ebuild'].metadata[mytype]
-						if not myvalue:
-							continue
-
-						success, atoms = portage.dep_check(
-							myvalue, self.portdb, dep_settings,
-							use="all", mode=matchmode, trees=self.repo_settings.trees)
-
-						if success:
-							if atoms:
-
-								# Don't bother with dependency.unknown for
-								# cases in which *DEPEND.bad is triggered.
-								for atom in atoms:
-									# dep_check returns all blockers and they
-									# aren't counted for *DEPEND.bad, so we
-									# ignore them here.
-									if not atom.blocker:
-										dynamic_data['unknown_pkgs'].discard(
-											(mytype, atom.unevaluated_atom))
-
-								if not prof.sub_path:
-									# old-style virtuals currently aren't
-									# resolvable with empty profile, since
-									# 'virtuals' mappings are unavailable
-									# (it would be expensive to search
-									# for PROVIDE in all ebuilds)
-									atoms = [
-										atom for atom in atoms if not (
-											atom.cp.startswith('virtual/')
-											and not self.portdb.cp_list(atom.cp))]
-
-								# we have some unsolvable deps
-								# remove ! deps, which always show up as unsatisfiable
-								atoms = [
-									str(atom.unevaluated_atom)
-									for atom in atoms if not atom.blocker]
-
-								# if we emptied out our list, continue:
-								if not atoms:
-									continue
-								if self.options.output_style in ['column']:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s) %s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, repr(atoms)))
-								else:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s)\n%s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, pformat(atoms, indent=6)))
-						else:
-							if self.options.output_style in ['column']:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s) %s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, repr(atoms)))
-							else:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s)\n%s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, pformat(atoms, indent=6)))
-
 			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-30  8:00 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-30  8:00 UTC (permalink / raw
  To: gentoo-commits

commit:     72261db29238b4100d0bffe9f08409a41abf4902
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 07:57:36 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 07:50:20 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=72261db2

repoman: Move the large depency checks loop to a new plugin ProfileDependsChecks class

 pym/repoman/modules/scan/depend/__init__.py |   9 ++
 pym/repoman/modules/scan/depend/profile.py  | 211 ++++++++++++++++++++++++++++
 pym/repoman/repos.py                        |   1 +
 pym/repoman/scanner.py                      | 181 +-----------------------
 4 files changed, 228 insertions(+), 174 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index ebc716c..cddb7f1 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -19,6 +19,15 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'profile-module': {
+			'name': "profile",
+			'sourcefile': "profile",
+			'class': "ProfileDependsChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/profile.py b/pym/repoman/modules/scan/depend/profile.py
new file mode 100644
index 0000000..91c52cc
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/profile.py
@@ -0,0 +1,211 @@
+# -*- coding:utf-8 -*-
+
+
+import copy
+from pprint import pformat
+
+from _emerge.Package import Package
+
+# import our initialized portage instance
+from repoman._portage import portage
+from portage.dep import Atom
+
+
+def sort_key(item):
+	return item[2].sub_path
+
+
+class ProfileDependsChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+		self.profiles = kwargs.get('profiles')
+		self.options = kwargs.get('options')
+		self.repo_settings = kwargs.get('repo_settings')
+		self.include_arches = kwargs.get('include_arches')
+		self.caches = kwargs.get('caches')
+		self.repoman_incrementals = kwargs.get('repoman_incrementals')
+		self.env = kwargs.get('env')
+		self.have = kwargs.get('have')
+		self.dev_keywords = kwargs.get('dev_keywords')
+
+	def check(self, **kwargs):
+		arches = kwargs.get('arches')
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		relevant_profiles = []
+		for keyword, arch, groups in arches:
+			if arch not in self.profiles:
+				# A missing profile will create an error further down
+				# during the KEYWORDS verification.
+				continue
+
+			if self.include_arches is not None:
+				if arch not in self.include_arches:
+					continue
+
+			relevant_profiles.extend(
+				(keyword, groups, prof) for prof in self.profiles[arch])
+
+		relevant_profiles.sort(key=sort_key)
+
+		for keyword, groups, prof in relevant_profiles:
+
+			is_stable_profile = prof.status == "stable"
+			is_dev_profile = prof.status == "dev" and \
+				self.options.include_dev
+			is_exp_profile = prof.status == "exp" and \
+				self.options.include_exp_profiles == 'y'
+			if not (is_stable_profile or is_dev_profile or is_exp_profile):
+				continue
+
+			dep_settings = self.caches['arch'].get(prof.sub_path)
+			if dep_settings is None:
+				dep_settings = portage.config(
+					config_profile_path=prof.abs_path,
+					config_incrementals=self.repoman_incrementals,
+					config_root=self.repo_settings.config_root,
+					local_config=False,
+					_unmatched_removal=self.options.unmatched_removal,
+					env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
+				dep_settings.categories = self.repo_settings.repoman_settings.categories
+				if self.options.without_mask:
+					dep_settings._mask_manager_obj = \
+						copy.deepcopy(dep_settings._mask_manager)
+					dep_settings._mask_manager._pmaskdict.clear()
+				self.caches['arch'][prof.sub_path] = dep_settings
+
+			xmatch_cache_key = (prof.sub_path, tuple(groups))
+			xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
+			if xcache is None:
+				self.portdb.melt()
+				self.portdb.freeze()
+				xcache = self.portdb.xcache
+				xcache.update(self.caches['shared_xmatch'])
+				self.caches['arch_xmatch'][xmatch_cache_key] = xcache
+
+			self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
+			self.portdb.settings = dep_settings
+			self.portdb.xcache = xcache
+
+			dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
+			# just in case, prevent config.reset() from nuking these.
+			dep_settings.backup_changes("ACCEPT_KEYWORDS")
+
+			# This attribute is used in dbapi._match_use() to apply
+			# use.stable.{mask,force} settings based on the stable
+			# status of the parent package. This is required in order
+			# for USE deps of unstable packages to be resolved correctly,
+			# since otherwise use.stable.{mask,force} settings of
+			# dependencies may conflict (see bug #456342).
+			dep_settings._parent_stable = dep_settings._isStable(pkg)
+
+			# Handle package.use*.{force,mask) calculation, for use
+			# in dep_check.
+			dep_settings.useforce = dep_settings._use_manager.getUseForce(
+				pkg, stable=dep_settings._parent_stable)
+			dep_settings.usemask = dep_settings._use_manager.getUseMask(
+				pkg, stable=dep_settings._parent_stable)
+
+			if not baddepsyntax:
+				ismasked = not ebuild.archs or \
+					pkg.cpv not in self.portdb.xmatch("match-visible",
+					Atom("%s::%s" % (pkg.cp, self.repo_settings.repo_config.name)))
+				if ismasked:
+					if not self.have['pmasked']:
+						self.have['pmasked'] = bool(dep_settings._getMaskAtom(
+							pkg.cpv, ebuild.metadata))
+					if self.options.ignore_masked:
+						continue
+					# we are testing deps for a masked package; give it some lee-way
+					suffix = "masked"
+					matchmode = "minimum-all-ignore-profile"
+				else:
+					suffix = ""
+					matchmode = "minimum-visible"
+
+				if not self.have['dev_keywords']:
+					self.have['dev_keywords'] = \
+						bool(self.dev_keywords.intersection(ebuild.keywords))
+
+				if prof.status == "dev":
+					suffix = suffix + "indev"
+
+				for mytype in Package._dep_keys:
+
+					mykey = "dependency.bad" + suffix
+					myvalue = ebuild.metadata[mytype]
+					if not myvalue:
+						continue
+
+					success, atoms = portage.dep_check(
+						myvalue, self.portdb, dep_settings,
+						use="all", mode=matchmode, trees=self.repo_settings.trees)
+
+					if success:
+						if atoms:
+
+							# Don't bother with dependency.unknown for
+							# cases in which *DEPEND.bad is triggered.
+							for atom in atoms:
+								# dep_check returns all blockers and they
+								# aren't counted for *DEPEND.bad, so we
+								# ignore them here.
+								if not atom.blocker:
+									unknown_pkgs.discard(
+										(mytype, atom.unevaluated_atom))
+
+							if not prof.sub_path:
+								# old-style virtuals currently aren't
+								# resolvable with empty profile, since
+								# 'virtuals' mappings are unavailable
+								# (it would be expensive to search
+								# for PROVIDE in all ebuilds)
+								atoms = [
+									atom for atom in atoms if not (
+										atom.cp.startswith('virtual/')
+										and not self.portdb.cp_list(atom.cp))]
+
+							# we have some unsolvable deps
+							# remove ! deps, which always show up as unsatisfiable
+							atoms = [
+								str(atom.unevaluated_atom)
+								for atom in atoms if not atom.blocker]
+
+							# if we emptied out our list, continue:
+							if not atoms:
+								continue
+							if self.options.output_style in ['column']:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s) %s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, repr(atoms)))
+							else:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s)\n%s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, pformat(atoms, indent=6)))
+					else:
+						if self.options.output_style in ['column']:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s) %s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, repr(atoms)))
+						else:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s)\n%s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, pformat(atoms, indent=6)))
+		return {'continue': False}
+
+	@property
+	def runInPkgs(self):
+		return (False, [])
+
+	@property
+	def runInEbuilds(self):
+		return (True, [self.check])

diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py
index a34f785..39f53c1 100644
--- a/pym/repoman/repos.py
+++ b/pym/repoman/repos.py
@@ -28,6 +28,7 @@ class RepoSettings(object):
 		self, config_root, portdir, portdir_overlay,
 		repoman_settings=None, vcs_settings=None, options=None,
 		qawarnings=None):
+		self.config_root = config_root
 		self.repoman_settings = repoman_settings
 		self.vcs_settings = vcs_settings
 

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index b9c53a0..48b60a4 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -2,17 +2,12 @@
 
 from __future__ import print_function, unicode_literals
 
-import copy
 import logging
 from itertools import chain
-from pprint import pformat
-
-from _emerge.Package import Package
 
 import portage
 from portage import normalize_path
 from portage import os
-from portage.dep import Atom
 from portage.output import green
 from repoman.modules.commit import repochecks
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
@@ -33,10 +28,6 @@ MODULE_CONTROLLER = Modules(path=MODULES_PATH, namepath="repoman.modules.scan")
 MODULE_NAMES = MODULE_CONTROLLER.module_names[:]
 
 
-def sort_key(item):
-	return item[2].sub_path
-
-
 class Scanner(object):
 	'''Primary scan class.  Operates all the small Q/A tests and checks'''
 
@@ -197,6 +188,12 @@ class Scanner(object):
 			"checks": self.checks,
 			"repo_metadata": self.repo_metadata,
 			"profiles": self.profiles,
+			"include_arches": self.include_arches,
+			"caches": self.caches,
+			"repoman_incrementals": self.repoman_incrementals,
+			"env": self.env,
+			"have": self.have,
+			"dev_keywords": self.dev_keywords,
 		}
 		# initialize the plugin checks here
 		self.modules = {}
@@ -292,7 +289,7 @@ class Scanner(object):
 				('license', 'LicenseChecks'), ('restrict', 'RestrictChecks'),
 				('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
 				# Options.is_forced() is used to bypass further checks
-				('options', 'Options'),
+				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -320,170 +317,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			relevant_profiles = []
-			for keyword, arch, groups in dynamic_data['arches']:
-				if arch not in self.profiles:
-					# A missing profile will create an error further down
-					# during the KEYWORDS verification.
-					continue
-
-				if self.include_arches is not None:
-					if arch not in self.include_arches:
-						continue
-
-				relevant_profiles.extend(
-					(keyword, groups, prof) for prof in self.profiles[arch])
-
-			relevant_profiles.sort(key=sort_key)
-
-			for keyword, groups, prof in relevant_profiles:
-
-				is_stable_profile = prof.status == "stable"
-				is_dev_profile = prof.status == "dev" and \
-					self.options.include_dev
-				is_exp_profile = prof.status == "exp" and \
-					self.options.include_exp_profiles == 'y'
-				if not (is_stable_profile or is_dev_profile or is_exp_profile):
-					continue
-
-				dep_settings = self.caches['arch'].get(prof.sub_path)
-				if dep_settings is None:
-					dep_settings = portage.config(
-						config_profile_path=prof.abs_path,
-						config_incrementals=self.repoman_incrementals,
-						config_root=self.config_root,
-						local_config=False,
-						_unmatched_removal=self.options.unmatched_removal,
-						env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
-					dep_settings.categories = self.repo_settings.repoman_settings.categories
-					if self.options.without_mask:
-						dep_settings._mask_manager_obj = \
-							copy.deepcopy(dep_settings._mask_manager)
-						dep_settings._mask_manager._pmaskdict.clear()
-					self.caches['arch'][prof.sub_path] = dep_settings
-
-				xmatch_cache_key = (prof.sub_path, tuple(groups))
-				xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
-				if xcache is None:
-					self.portdb.melt()
-					self.portdb.freeze()
-					xcache = self.portdb.xcache
-					xcache.update(self.caches['shared_xmatch'])
-					self.caches['arch_xmatch'][xmatch_cache_key] = xcache
-
-				self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
-				self.portdb.settings = dep_settings
-				self.portdb.xcache = xcache
-
-				dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
-				# just in case, prevent config.reset() from nuking these.
-				dep_settings.backup_changes("ACCEPT_KEYWORDS")
-
-				# This attribute is used in dbapi._match_use() to apply
-				# use.stable.{mask,force} settings based on the stable
-				# status of the parent package. This is required in order
-				# for USE deps of unstable packages to be resolved correctly,
-				# since otherwise use.stable.{mask,force} settings of
-				# dependencies may conflict (see bug #456342).
-				dep_settings._parent_stable = dep_settings._isStable(dynamic_data['pkg'])
-
-				# Handle package.use*.{force,mask) calculation, for use
-				# in dep_check.
-				dep_settings.useforce = dep_settings._use_manager.getUseForce(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-				dep_settings.usemask = dep_settings._use_manager.getUseMask(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-
-				if not dynamic_data['baddepsyntax']:
-					ismasked = not dynamic_data['ebuild'].archs or \
-						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
-						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
-					if ismasked:
-						if not self.have['pmasked']:
-							self.have['pmasked'] = bool(dep_settings._getMaskAtom(
-								dynamic_data['pkg'].cpv, dynamic_data['pkg']._metadata))
-						if self.options.ignore_masked:
-							continue
-						# we are testing deps for a masked package; give it some lee-way
-						suffix = "masked"
-						matchmode = "minimum-all-ignore-profile"
-					else:
-						suffix = ""
-						matchmode = "minimum-visible"
-
-					if not self.have['dev_keywords']:
-						self.have['dev_keywords'] = \
-							bool(self.dev_keywords.intersection(dynamic_data['ebuild'].keywords))
-
-					if prof.status == "dev":
-						suffix = suffix + "indev"
-
-					for mytype in Package._dep_keys:
-
-						mykey = "dependency.bad" + suffix
-						myvalue = dynamic_data['ebuild'].metadata[mytype]
-						if not myvalue:
-							continue
-
-						success, atoms = portage.dep_check(
-							myvalue, self.portdb, dep_settings,
-							use="all", mode=matchmode, trees=self.repo_settings.trees)
-
-						if success:
-							if atoms:
-
-								# Don't bother with dependency.unknown for
-								# cases in which *DEPEND.bad is triggered.
-								for atom in atoms:
-									# dep_check returns all blockers and they
-									# aren't counted for *DEPEND.bad, so we
-									# ignore them here.
-									if not atom.blocker:
-										dynamic_data['unknown_pkgs'].discard(
-											(mytype, atom.unevaluated_atom))
-
-								if not prof.sub_path:
-									# old-style virtuals currently aren't
-									# resolvable with empty profile, since
-									# 'virtuals' mappings are unavailable
-									# (it would be expensive to search
-									# for PROVIDE in all ebuilds)
-									atoms = [
-										atom for atom in atoms if not (
-											atom.cp.startswith('virtual/')
-											and not self.portdb.cp_list(atom.cp))]
-
-								# we have some unsolvable deps
-								# remove ! deps, which always show up as unsatisfiable
-								atoms = [
-									str(atom.unevaluated_atom)
-									for atom in atoms if not atom.blocker]
-
-								# if we emptied out our list, continue:
-								if not atoms:
-									continue
-								if self.options.output_style in ['column']:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s) %s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, repr(atoms)))
-								else:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s)\n%s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, pformat(atoms, indent=6)))
-						else:
-							if self.options.output_style in ['column']:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s) %s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, repr(atoms)))
-							else:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s)\n%s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, pformat(atoms, indent=6)))
-
 			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-31 20:03 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-31 20:03 UTC (permalink / raw
  To: gentoo-commits

commit:     f2044f0420f1a44064cb149455007b0ffebe85a0
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 20:38:11 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 20:25:07 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=f2044f04

repoman: New DependChecks class plugin

Migrate code from _scan_ebuilds to the plugin system.

 pym/repoman/modules/scan/depend/__init__.py |  24 +++++
 pym/repoman/modules/scan/depend/depend.py   | 132 ++++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 119 ++-----------------------
 3 files changed, 163 insertions(+), 112 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
new file mode 100644
index 0000000..ebc716c
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -0,0 +1,24 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Depend plug-in module for repoman.
+Performs Dependency checks on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+	'name': 'depend',
+	'description': doc,
+	'provides':{
+		'depend-module': {
+			'name': "depend",
+			'sourcefile': "depend",
+			'class': "DependChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
+	}
+}
+

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
new file mode 100644
index 0000000..8a0ff48
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -0,0 +1,132 @@
+
+from _emerge.Package import Package
+
+from repoman.check_missingslot import check_missingslot
+# import our initialized portage instance
+from repoman._portage import portage
+from repoman.qa_data import suspect_virtual, suspect_rdepend
+
+
+class DependChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+
+		unknown_pkgs = set()
+
+		inherited_java_eclass = "java-pkg-2" in ebuild.inherited or \
+			"java-pkg-opt-2" in ebuild.inherited,
+		inherited_wxwidgets_eclass = "wxwidgets" in ebuild.inherited
+		# operator_tokens = set(["||", "(", ")"])
+		type_list, badsyntax = [], []
+		for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
+			mydepstr = ebuild.metadata[mytype]
+
+			buildtime = mytype in Package._buildtime_keys
+			runtime = mytype in Package._runtime_keys
+			token_class = None
+			if mytype.endswith("DEPEND"):
+				token_class = portage.dep.Atom
+
+			try:
+				atoms = portage.dep.use_reduce(
+					mydepstr, matchall=1, flat=True,
+					is_valid_flag=pkg.iuse.is_valid_flag, token_class=token_class)
+			except portage.exception.InvalidDependString as e:
+				atoms = None
+				badsyntax.append(str(e))
+
+			if atoms and mytype.endswith("DEPEND"):
+				if runtime and \
+					"test?" in mydepstr.split():
+					self.qatracker.add_error(
+						mytype + '.suspect',
+						"%s: 'test?' USE conditional in %s" %
+						(ebuild.relative_path, mytype))
+
+				for atom in atoms:
+					if atom == "||":
+						continue
+
+					is_blocker = atom.blocker
+
+					# Skip dependency.unknown for blockers, so that we
+					# don't encourage people to remove necessary blockers,
+					# as discussed in bug 382407. We use atom.without_use
+					# due to bug 525376.
+					if not is_blocker and \
+						not self.portdb.xmatch("match-all", atom.without_use) and \
+						not atom.cp.startswith("virtual/"):
+						unknown_pkgs.add((mytype, atom.unevaluated_atom))
+
+					if kwargs.get('catdir') != "virtual":
+						if not is_blocker and \
+							atom.cp in suspect_virtual:
+							self.qatracker.add_error(
+								'virtual.suspect', ebuild.relative_path +
+								": %s: consider using '%s' instead of '%s'" %
+								(mytype, suspect_virtual[atom.cp], atom))
+						if not is_blocker and \
+							atom.cp.startswith("perl-core/"):
+							self.qatracker.add_error('dependency.perlcore',
+								ebuild.relative_path +
+								": %s: please use '%s' instead of '%s'" %
+								(mytype,
+								atom.replace("perl-core/","virtual/perl-"),
+								atom))
+
+					if buildtime and \
+						not is_blocker and \
+						not inherited_java_eclass and \
+						atom.cp == "virtual/jdk":
+						self.qatracker.add_error(
+							'java.eclassesnotused', ebuild.relative_path)
+					elif buildtime and \
+						not is_blocker and \
+						not inherited_wxwidgets_eclass and \
+						atom.cp == "x11-libs/wxGTK":
+						self.qatracker.add_error(
+							'wxwidgets.eclassnotused',
+							"%s: %ss on x11-libs/wxGTK without inheriting"
+							" wxwidgets.eclass" % (ebuild.relative_path, mytype))
+					elif runtime:
+						if not is_blocker and \
+							atom.cp in suspect_rdepend:
+							self.qatracker.add_error(
+								mytype + '.suspect',
+								ebuild.relative_path + ": '%s'" % atom)
+
+					if atom.operator == "~" and \
+						portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
+						qacat = 'dependency.badtilde'
+						self.qatracker.add_error(
+							qacat, "%s: %s uses the ~ operator"
+							" with a non-zero revision: '%s'" %
+							(ebuild.relative_path, mytype, atom))
+
+					check_missingslot(atom, mytype, ebuild.eapi, self.portdb, self.qatracker,
+						ebuild.relative_path, ebuild.metadata)
+
+			type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
+
+		for m, b in zip(type_list, badsyntax):
+			if m.endswith("DEPEND"):
+				qacat = "dependency.syntax"
+			else:
+				qacat = m + ".syntax"
+			self.qatracker.add_error(
+				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+	@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 829dba1..8081c1e 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -19,13 +19,11 @@ 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.check_missingslot import check_missingslot
 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
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
-from repoman.qa_data import missingvars, suspect_virtual, suspect_rdepend
 from repoman.repos import repo_metadata
 from repoman.modules.scan.scan import scan
 from repoman.modules.vcs.vcs import vcs_files_to_cps
@@ -304,7 +302,7 @@ class Scanner(object):
 				('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
 				('thirdpartymirrors', 'ThirdPartyMirrors'),
 				('description', 'DescriptionChecks'), (None, 'KeywordChecks'),
-				('arches', 'ArchChecks'),
+				('arches', 'ArchChecks'), ('depend', 'DependChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -361,112 +359,9 @@ class Scanner(object):
 			badprovsyntax = False
 			# catpkg = catdir + "/" + y_ebuild
 
-			inherited_java_eclass = "java-pkg-2" in dynamic_data['ebuild'].inherited or \
-				"java-pkg-opt-2" in dynamic_data['ebuild'].inherited,
-			inherited_wxwidgets_eclass = "wxwidgets" in dynamic_data['ebuild'].inherited
-			# operator_tokens = set(["||", "(", ")"])
-			type_list, badsyntax = [], []
-			for mytype in Package._dep_keys + ("LICENSE", "PROPERTIES", "PROVIDE"):
-				mydepstr = dynamic_data['ebuild'].metadata[mytype]
-
-				buildtime = mytype in Package._buildtime_keys
-				runtime = mytype in Package._runtime_keys
-				token_class = None
-				if mytype.endswith("DEPEND"):
-					token_class = portage.dep.Atom
-
-				try:
-					atoms = portage.dep.use_reduce(
-						mydepstr, matchall=1, flat=True,
-						is_valid_flag=dynamic_data['pkg'].iuse.is_valid_flag, token_class=token_class)
-				except portage.exception.InvalidDependString as e:
-					atoms = None
-					badsyntax.append(str(e))
-
-				if atoms and mytype.endswith("DEPEND"):
-					if runtime and \
-						"test?" in mydepstr.split():
-						self.qatracker.add_error(
-							mytype + '.suspect',
-							"%s: 'test?' USE conditional in %s" %
-							(dynamic_data['ebuild'].relative_path, mytype))
-
-					for atom in atoms:
-						if atom == "||":
-							continue
-
-						is_blocker = atom.blocker
-
-						# Skip dependency.unknown for blockers, so that we
-						# don't encourage people to remove necessary blockers,
-						# as discussed in bug 382407. We use atom.without_use
-						# due to bug 525376.
-						if not is_blocker and \
-							not self.portdb.xmatch("match-all", atom.without_use) and \
-							not atom.cp.startswith("virtual/"):
-							unknown_pkgs.add((mytype, atom.unevaluated_atom))
-
-						if dynamic_data['catdir'] != "virtual":
-							if not is_blocker and \
-								atom.cp in suspect_virtual:
-								self.qatracker.add_error(
-									'virtual.suspect', dynamic_data['ebuild'].relative_path +
-									": %s: consider using '%s' instead of '%s'" %
-									(mytype, suspect_virtual[atom.cp], atom))
-							if not is_blocker and \
-								atom.cp.startswith("perl-core/"):
-								self.qatracker.add_error('dependency.perlcore',
-									dynamic_data['ebuild'].relative_path +
-									": %s: please use '%s' instead of '%s'" %
-									(mytype,
-									atom.replace("perl-core/","virtual/perl-"),
-									atom))
-
-						if buildtime and \
-							not is_blocker and \
-							not inherited_java_eclass and \
-							atom.cp == "virtual/jdk":
-							self.qatracker.add_error(
-								'java.eclassesnotused', dynamic_data['ebuild'].relative_path)
-						elif buildtime and \
-							not is_blocker and \
-							not inherited_wxwidgets_eclass and \
-							atom.cp == "x11-libs/wxGTK":
-							self.qatracker.add_error(
-								'wxwidgets.eclassnotused',
-								"%s: %ss on x11-libs/wxGTK without inheriting"
-								" wxwidgets.eclass" % (dynamic_data['ebuild'].relative_path, mytype))
-						elif runtime:
-							if not is_blocker and \
-								atom.cp in suspect_rdepend:
-								self.qatracker.add_error(
-									mytype + '.suspect',
-									dynamic_data['ebuild'].relative_path + ": '%s'" % atom)
-
-						if atom.operator == "~" and \
-							portage.versions.catpkgsplit(atom.cpv)[3] != "r0":
-							qacat = 'dependency.badtilde'
-							self.qatracker.add_error(
-								qacat, "%s: %s uses the ~ operator"
-								" with a non-zero revision: '%s'" %
-								(dynamic_data['ebuild'].relative_path, mytype, atom))
-
-						check_missingslot(atom, mytype, dynamic_data['ebuild'].eapi, self.portdb, self.qatracker,
-							dynamic_data['ebuild'].relative_path, dynamic_data['ebuild'].metadata)
-
-				type_list.extend([mytype] * (len(badsyntax) - len(type_list)))
-
-			for m, b in zip(type_list, badsyntax):
-				if m.endswith("DEPEND"):
-					qacat = "dependency.syntax"
-				else:
-					qacat = m + ".syntax"
-				self.qatracker.add_error(
-					qacat, "%s: %s: %s" % (dynamic_data['ebuild'].relative_path, m, b))
-
-			badlicsyntax = len([z for z in type_list if z == "LICENSE"])
-			badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
-			baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
+			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
+			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
 			badlicsyntax = badlicsyntax > 0
 			badprovsyntax = badprovsyntax > 0
 
@@ -629,7 +524,7 @@ class Scanner(object):
 									# aren't counted for *DEPEND.bad, so we
 									# ignore them here.
 									if not atom.blocker:
-										unknown_pkgs.discard(
+										dynamic_data['unknown_pkgs'].discard(
 											(mytype, atom.unevaluated_atom))
 
 								if not prof.sub_path:
@@ -674,9 +569,9 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and unknown_pkgs:
+			if not baddepsyntax and dynamic_data['unknown_pkgs']:
 				type_map = {}
-				for mytype, atom in unknown_pkgs:
+				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)
 				for mytype, atoms in type_map.items():
 					self.qatracker.add_error(


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-01-31 20:03 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-01-31 20:03 UTC (permalink / raw
  To: gentoo-commits

commit:     d1d01faf13dc051a4b8f6b6cdbe6b5b4e064b2c4
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 07:57:36 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 20:25:23 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d1d01faf

repoman: Move the large depency checks loop to a new plugin ProfileDependsChecks class

 pym/repoman/modules/scan/depend/__init__.py |   9 ++
 pym/repoman/modules/scan/depend/profile.py  | 211 ++++++++++++++++++++++++++++
 pym/repoman/repos.py                        |   1 +
 pym/repoman/scanner.py                      | 181 +-----------------------
 4 files changed, 228 insertions(+), 174 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index ebc716c..cddb7f1 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -19,6 +19,15 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'profile-module': {
+			'name': "profile",
+			'sourcefile': "profile",
+			'class': "ProfileDependsChecks",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/profile.py b/pym/repoman/modules/scan/depend/profile.py
new file mode 100644
index 0000000..91c52cc
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/profile.py
@@ -0,0 +1,211 @@
+# -*- coding:utf-8 -*-
+
+
+import copy
+from pprint import pformat
+
+from _emerge.Package import Package
+
+# import our initialized portage instance
+from repoman._portage import portage
+from portage.dep import Atom
+
+
+def sort_key(item):
+	return item[2].sub_path
+
+
+class ProfileDependsChecks(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+		self.portdb = kwargs.get('portdb')
+		self.profiles = kwargs.get('profiles')
+		self.options = kwargs.get('options')
+		self.repo_settings = kwargs.get('repo_settings')
+		self.include_arches = kwargs.get('include_arches')
+		self.caches = kwargs.get('caches')
+		self.repoman_incrementals = kwargs.get('repoman_incrementals')
+		self.env = kwargs.get('env')
+		self.have = kwargs.get('have')
+		self.dev_keywords = kwargs.get('dev_keywords')
+
+	def check(self, **kwargs):
+		arches = kwargs.get('arches')
+		ebuild = kwargs.get('ebuild')
+		pkg = kwargs.get('pkg')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		relevant_profiles = []
+		for keyword, arch, groups in arches:
+			if arch not in self.profiles:
+				# A missing profile will create an error further down
+				# during the KEYWORDS verification.
+				continue
+
+			if self.include_arches is not None:
+				if arch not in self.include_arches:
+					continue
+
+			relevant_profiles.extend(
+				(keyword, groups, prof) for prof in self.profiles[arch])
+
+		relevant_profiles.sort(key=sort_key)
+
+		for keyword, groups, prof in relevant_profiles:
+
+			is_stable_profile = prof.status == "stable"
+			is_dev_profile = prof.status == "dev" and \
+				self.options.include_dev
+			is_exp_profile = prof.status == "exp" and \
+				self.options.include_exp_profiles == 'y'
+			if not (is_stable_profile or is_dev_profile or is_exp_profile):
+				continue
+
+			dep_settings = self.caches['arch'].get(prof.sub_path)
+			if dep_settings is None:
+				dep_settings = portage.config(
+					config_profile_path=prof.abs_path,
+					config_incrementals=self.repoman_incrementals,
+					config_root=self.repo_settings.config_root,
+					local_config=False,
+					_unmatched_removal=self.options.unmatched_removal,
+					env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
+				dep_settings.categories = self.repo_settings.repoman_settings.categories
+				if self.options.without_mask:
+					dep_settings._mask_manager_obj = \
+						copy.deepcopy(dep_settings._mask_manager)
+					dep_settings._mask_manager._pmaskdict.clear()
+				self.caches['arch'][prof.sub_path] = dep_settings
+
+			xmatch_cache_key = (prof.sub_path, tuple(groups))
+			xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
+			if xcache is None:
+				self.portdb.melt()
+				self.portdb.freeze()
+				xcache = self.portdb.xcache
+				xcache.update(self.caches['shared_xmatch'])
+				self.caches['arch_xmatch'][xmatch_cache_key] = xcache
+
+			self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
+			self.portdb.settings = dep_settings
+			self.portdb.xcache = xcache
+
+			dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
+			# just in case, prevent config.reset() from nuking these.
+			dep_settings.backup_changes("ACCEPT_KEYWORDS")
+
+			# This attribute is used in dbapi._match_use() to apply
+			# use.stable.{mask,force} settings based on the stable
+			# status of the parent package. This is required in order
+			# for USE deps of unstable packages to be resolved correctly,
+			# since otherwise use.stable.{mask,force} settings of
+			# dependencies may conflict (see bug #456342).
+			dep_settings._parent_stable = dep_settings._isStable(pkg)
+
+			# Handle package.use*.{force,mask) calculation, for use
+			# in dep_check.
+			dep_settings.useforce = dep_settings._use_manager.getUseForce(
+				pkg, stable=dep_settings._parent_stable)
+			dep_settings.usemask = dep_settings._use_manager.getUseMask(
+				pkg, stable=dep_settings._parent_stable)
+
+			if not baddepsyntax:
+				ismasked = not ebuild.archs or \
+					pkg.cpv not in self.portdb.xmatch("match-visible",
+					Atom("%s::%s" % (pkg.cp, self.repo_settings.repo_config.name)))
+				if ismasked:
+					if not self.have['pmasked']:
+						self.have['pmasked'] = bool(dep_settings._getMaskAtom(
+							pkg.cpv, ebuild.metadata))
+					if self.options.ignore_masked:
+						continue
+					# we are testing deps for a masked package; give it some lee-way
+					suffix = "masked"
+					matchmode = "minimum-all-ignore-profile"
+				else:
+					suffix = ""
+					matchmode = "minimum-visible"
+
+				if not self.have['dev_keywords']:
+					self.have['dev_keywords'] = \
+						bool(self.dev_keywords.intersection(ebuild.keywords))
+
+				if prof.status == "dev":
+					suffix = suffix + "indev"
+
+				for mytype in Package._dep_keys:
+
+					mykey = "dependency.bad" + suffix
+					myvalue = ebuild.metadata[mytype]
+					if not myvalue:
+						continue
+
+					success, atoms = portage.dep_check(
+						myvalue, self.portdb, dep_settings,
+						use="all", mode=matchmode, trees=self.repo_settings.trees)
+
+					if success:
+						if atoms:
+
+							# Don't bother with dependency.unknown for
+							# cases in which *DEPEND.bad is triggered.
+							for atom in atoms:
+								# dep_check returns all blockers and they
+								# aren't counted for *DEPEND.bad, so we
+								# ignore them here.
+								if not atom.blocker:
+									unknown_pkgs.discard(
+										(mytype, atom.unevaluated_atom))
+
+							if not prof.sub_path:
+								# old-style virtuals currently aren't
+								# resolvable with empty profile, since
+								# 'virtuals' mappings are unavailable
+								# (it would be expensive to search
+								# for PROVIDE in all ebuilds)
+								atoms = [
+									atom for atom in atoms if not (
+										atom.cp.startswith('virtual/')
+										and not self.portdb.cp_list(atom.cp))]
+
+							# we have some unsolvable deps
+							# remove ! deps, which always show up as unsatisfiable
+							atoms = [
+								str(atom.unevaluated_atom)
+								for atom in atoms if not atom.blocker]
+
+							# if we emptied out our list, continue:
+							if not atoms:
+								continue
+							if self.options.output_style in ['column']:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s) %s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, repr(atoms)))
+							else:
+								self.qatracker.add_error(mykey,
+									"%s: %s: %s(%s)\n%s"
+									% (ebuild.relative_path, mytype, keyword,
+										prof, pformat(atoms, indent=6)))
+					else:
+						if self.options.output_style in ['column']:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s) %s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, repr(atoms)))
+						else:
+							self.qatracker.add_error(mykey,
+								"%s: %s: %s(%s)\n%s"
+								% (ebuild.relative_path, mytype, keyword,
+									prof, pformat(atoms, indent=6)))
+		return {'continue': False}
+
+	@property
+	def runInPkgs(self):
+		return (False, [])
+
+	@property
+	def runInEbuilds(self):
+		return (True, [self.check])

diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py
index a34f785..39f53c1 100644
--- a/pym/repoman/repos.py
+++ b/pym/repoman/repos.py
@@ -28,6 +28,7 @@ class RepoSettings(object):
 		self, config_root, portdir, portdir_overlay,
 		repoman_settings=None, vcs_settings=None, options=None,
 		qawarnings=None):
+		self.config_root = config_root
 		self.repoman_settings = repoman_settings
 		self.vcs_settings = vcs_settings
 

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index 2625de4..b82cefb 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -2,17 +2,12 @@
 
 from __future__ import print_function, unicode_literals
 
-import copy
 import logging
 from itertools import chain
-from pprint import pformat
-
-from _emerge.Package import Package
 
 import portage
 from portage import normalize_path
 from portage import os
-from portage.dep import Atom
 from portage.output import green
 from repoman.modules.commit import repochecks
 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
@@ -33,10 +28,6 @@ MODULE_CONTROLLER = Modules(path=MODULES_PATH, namepath="repoman.modules.scan")
 MODULE_NAMES = MODULE_CONTROLLER.module_names[:]
 
 
-def sort_key(item):
-	return item[2].sub_path
-
-
 class Scanner(object):
 	'''Primary scan class.  Operates all the small Q/A tests and checks'''
 
@@ -197,6 +188,12 @@ class Scanner(object):
 			"checks": self.checks,
 			"repo_metadata": self.repo_metadata,
 			"profiles": self.profiles,
+			"include_arches": self.include_arches,
+			"caches": self.caches,
+			"repoman_incrementals": self.repoman_incrementals,
+			"env": self.env,
+			"have": self.have,
+			"dev_keywords": self.dev_keywords,
 		}
 		# initialize the plugin checks here
 		self.modules = {}
@@ -292,7 +289,7 @@ class Scanner(object):
 				('license', 'LicenseChecks'), ('restrict', 'RestrictChecks'),
 				('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
 				# Options.is_forced() is used to bypass further checks
-				('options', 'Options'),
+				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -320,170 +317,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			relevant_profiles = []
-			for keyword, arch, groups in dynamic_data['arches']:
-				if arch not in self.profiles:
-					# A missing profile will create an error further down
-					# during the KEYWORDS verification.
-					continue
-
-				if self.include_arches is not None:
-					if arch not in self.include_arches:
-						continue
-
-				relevant_profiles.extend(
-					(keyword, groups, prof) for prof in self.profiles[arch])
-
-			relevant_profiles.sort(key=sort_key)
-
-			for keyword, groups, prof in relevant_profiles:
-
-				is_stable_profile = prof.status == "stable"
-				is_dev_profile = prof.status == "dev" and \
-					self.options.include_dev
-				is_exp_profile = prof.status == "exp" and \
-					self.options.include_exp_profiles == 'y'
-				if not (is_stable_profile or is_dev_profile or is_exp_profile):
-					continue
-
-				dep_settings = self.caches['arch'].get(prof.sub_path)
-				if dep_settings is None:
-					dep_settings = portage.config(
-						config_profile_path=prof.abs_path,
-						config_incrementals=self.repoman_incrementals,
-						config_root=self.config_root,
-						local_config=False,
-						_unmatched_removal=self.options.unmatched_removal,
-						env=self.env, repositories=self.repo_settings.repoman_settings.repositories)
-					dep_settings.categories = self.repo_settings.repoman_settings.categories
-					if self.options.without_mask:
-						dep_settings._mask_manager_obj = \
-							copy.deepcopy(dep_settings._mask_manager)
-						dep_settings._mask_manager._pmaskdict.clear()
-					self.caches['arch'][prof.sub_path] = dep_settings
-
-				xmatch_cache_key = (prof.sub_path, tuple(groups))
-				xcache = self.caches['arch_xmatch'].get(xmatch_cache_key)
-				if xcache is None:
-					self.portdb.melt()
-					self.portdb.freeze()
-					xcache = self.portdb.xcache
-					xcache.update(self.caches['shared_xmatch'])
-					self.caches['arch_xmatch'][xmatch_cache_key] = xcache
-
-				self.repo_settings.trees[self.repo_settings.root]["porttree"].settings = dep_settings
-				self.portdb.settings = dep_settings
-				self.portdb.xcache = xcache
-
-				dep_settings["ACCEPT_KEYWORDS"] = " ".join(groups)
-				# just in case, prevent config.reset() from nuking these.
-				dep_settings.backup_changes("ACCEPT_KEYWORDS")
-
-				# This attribute is used in dbapi._match_use() to apply
-				# use.stable.{mask,force} settings based on the stable
-				# status of the parent package. This is required in order
-				# for USE deps of unstable packages to be resolved correctly,
-				# since otherwise use.stable.{mask,force} settings of
-				# dependencies may conflict (see bug #456342).
-				dep_settings._parent_stable = dep_settings._isStable(dynamic_data['pkg'])
-
-				# Handle package.use*.{force,mask) calculation, for use
-				# in dep_check.
-				dep_settings.useforce = dep_settings._use_manager.getUseForce(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-				dep_settings.usemask = dep_settings._use_manager.getUseMask(
-					dynamic_data['pkg'], stable=dep_settings._parent_stable)
-
-				if not dynamic_data['baddepsyntax']:
-					ismasked = not dynamic_data['ebuild'].archs or \
-						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
-						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
-					if ismasked:
-						if not self.have['pmasked']:
-							self.have['pmasked'] = bool(dep_settings._getMaskAtom(
-								dynamic_data['pkg'].cpv, dynamic_data['pkg']._metadata))
-						if self.options.ignore_masked:
-							continue
-						# we are testing deps for a masked package; give it some lee-way
-						suffix = "masked"
-						matchmode = "minimum-all-ignore-profile"
-					else:
-						suffix = ""
-						matchmode = "minimum-visible"
-
-					if not self.have['dev_keywords']:
-						self.have['dev_keywords'] = \
-							bool(self.dev_keywords.intersection(dynamic_data['ebuild'].keywords))
-
-					if prof.status == "dev":
-						suffix = suffix + "indev"
-
-					for mytype in Package._dep_keys:
-
-						mykey = "dependency.bad" + suffix
-						myvalue = dynamic_data['ebuild'].metadata[mytype]
-						if not myvalue:
-							continue
-
-						success, atoms = portage.dep_check(
-							myvalue, self.portdb, dep_settings,
-							use="all", mode=matchmode, trees=self.repo_settings.trees)
-
-						if success:
-							if atoms:
-
-								# Don't bother with dependency.unknown for
-								# cases in which *DEPEND.bad is triggered.
-								for atom in atoms:
-									# dep_check returns all blockers and they
-									# aren't counted for *DEPEND.bad, so we
-									# ignore them here.
-									if not atom.blocker:
-										dynamic_data['unknown_pkgs'].discard(
-											(mytype, atom.unevaluated_atom))
-
-								if not prof.sub_path:
-									# old-style virtuals currently aren't
-									# resolvable with empty profile, since
-									# 'virtuals' mappings are unavailable
-									# (it would be expensive to search
-									# for PROVIDE in all ebuilds)
-									atoms = [
-										atom for atom in atoms if not (
-											atom.cp.startswith('virtual/')
-											and not self.portdb.cp_list(atom.cp))]
-
-								# we have some unsolvable deps
-								# remove ! deps, which always show up as unsatisfiable
-								atoms = [
-									str(atom.unevaluated_atom)
-									for atom in atoms if not atom.blocker]
-
-								# if we emptied out our list, continue:
-								if not atoms:
-									continue
-								if self.options.output_style in ['column']:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s) %s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, repr(atoms)))
-								else:
-									self.qatracker.add_error(mykey,
-										"%s: %s: %s(%s)\n%s"
-										% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-											prof, pformat(atoms, indent=6)))
-						else:
-							if self.options.output_style in ['column']:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s) %s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, repr(atoms)))
-							else:
-								self.qatracker.add_error(mykey,
-									"%s: %s: %s(%s)\n%s"
-									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
-										prof, pformat(atoms, indent=6)))
-
 			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-03-07 21:53 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-03-07 21:53 UTC (permalink / raw
  To: gentoo-commits

commit:     f71e5099608242138eff2f4f9d24cbfd82fb98dc
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  3 21:19:59 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Mar  7 21:20:54 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=f71e5099

repoman: Migrate some additional Dependency code to the plugin

 pym/repoman/modules/scan/depend/depend.py | 13 ++++++++++++-
 pym/repoman/scanner.py                    | 22 +++-------------------
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/depend.py b/pym/repoman/modules/scan/depend/depend.py
index 4cb8709..2f90eee 100644
--- a/pym/repoman/modules/scan/depend/depend.py
+++ b/pym/repoman/modules/scan/depend/depend.py
@@ -1,3 +1,5 @@
+# -*- coding:utf-8 -*-
+
 
 from _emerge.Package import Package
 
@@ -121,7 +123,16 @@ class DependChecks(object):
 				qacat = m + ".syntax"
 			self.qatracker.add_error(
 				qacat, "%s: %s: %s" % (ebuild.relative_path, m, b))
-		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list}
+
+		# data required for some other tests
+		badlicsyntax = len([z for z in type_list if z == "LICENSE"])
+		badprovsyntax = len([z for z in type_list if z == "PROVIDE"])
+		baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax
+		badlicsyntax = badlicsyntax > 0
+		#badprovsyntax = badprovsyntax > 0
+
+		return {'continue': False, 'unknown_pkgs': unknown_pkgs, 'type_list': type_list,
+			'badlicsyntax': badlicsyntax, 'baddepsyntax': baddepsyntax}
 
 	@property
 	def runInEbuilds(self):

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index 1a2de05..467e6e1 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -327,26 +327,10 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if dynamic_data['live_ebuild'] and self.repo_settings.repo_config.name == "gentoo":
-				self.liveeclasscheck.check(
-					dynamic_data['pkg'], xpkg, dynamic_data['ebuild'], y_ebuild, dynamic_data['ebuild'].keywords, self.repo_metadata['pmaskdict'])
-
-			unknown_pkgs = set()
-			baddepsyntax = False
-			badlicsyntax = False
-			badprovsyntax = False
-			# catpkg = catdir + "/" + y_ebuild
-
-			badlicsyntax = len([z for z in dynamic_data['type_list'] if z == "LICENSE"])
-			badprovsyntax = len([z for z in dynamic_data['type_list'] if z == "PROVIDE"])
-			baddepsyntax = len(dynamic_data['type_list']) != badlicsyntax + badprovsyntax
-			badlicsyntax = badlicsyntax > 0
-			badprovsyntax = badprovsyntax > 0
-
 			used_useflags = used_useflags.union(dynamic_data['ebuild_UsedUseFlags'])
 
 			# license checks
-			if not badlicsyntax:
+			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)
@@ -452,7 +436,7 @@ class Scanner(object):
 				dep_settings.usemask = dep_settings._use_manager.getUseMask(
 					dynamic_data['pkg'], stable=dep_settings._parent_stable)
 
-				if not baddepsyntax:
+				if not dynamic_data['baddepsyntax']:
 					ismasked = not dynamic_data['ebuild'].archs or \
 						dynamic_data['pkg'].cpv not in self.portdb.xmatch("match-visible",
 						Atom("%s::%s" % (dynamic_data['pkg'].cp, self.repo_settings.repo_config.name)))
@@ -542,7 +526,7 @@ class Scanner(object):
 									% (dynamic_data['ebuild'].relative_path, mytype, keyword,
 										prof, pformat(atoms, indent=6)))
 
-			if not baddepsyntax and dynamic_data['unknown_pkgs']:
+			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
 				type_map = {}
 				for mytype, atom in dynamic_data['unknown_pkgs']:
 					type_map.setdefault(mytype, set()).add(atom)


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-03-07 21:53 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-03-07 21:53 UTC (permalink / raw
  To: gentoo-commits

commit:     66b6e342f08b2e36270ee3c50ae3f94670a429fc
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 08:09:33 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Mar  7 21:21:25 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=66b6e342

repoman: Create a new DependUnknown plugin class

 pym/repoman/modules/scan/depend/__init__.py |  9 +++++++++
 pym/repoman/modules/scan/depend/unknown.py  | 26 ++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 10 +---------
 3 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index cddb7f1..9fd7970 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -28,6 +28,15 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'unknown-module': {
+			'name': "unknown",
+			'sourcefile': "unknown",
+			'class': "DependUnknown",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py
new file mode 100644
index 0000000..b61a6e2
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/unknown.py
@@ -0,0 +1,26 @@
+# -*- coding:utf-8 -*-
+
+
+class DependUnknown(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		if not baddepsyntax and unknown_pkgs:
+			type_map = {}
+			for mytype, atom in unknown_pkgs:
+				type_map.setdefault(mytype, set()).add(atom)
+			for mytype, atoms in type_map.items():
+				self.qatracker.add_error(
+					"dependency.unknown", "%s: %s: %s"
+					% (ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
+		return {'continue': False}
+
+	@property
+	def runInEbuilds(self):
+		return (True, [self.check])

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index b82cefb..ca1de5f 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -290,6 +290,7 @@ class Scanner(object):
 				('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
 				# Options.is_forced() is used to bypass further checks
 				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
+				('unknown', 'DependUnknown'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -317,15 +318,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
-				type_map = {}
-				for mytype, atom in dynamic_data['unknown_pkgs']:
-					type_map.setdefault(mytype, set()).add(atom)
-				for mytype, atoms in type_map.items():
-					self.qatracker.add_error(
-						"dependency.unknown", "%s: %s: %s"
-						% (dynamic_data['ebuild'].relative_path, mytype, ", ".join(sorted(atoms))))
-
 		# check if there are unused local USE-descriptions in metadata.xml
 		# (unless there are any invalids, to avoid noise)
 		if dynamic_data['allvalid']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-03-11  0:41 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-03-11  0:41 UTC (permalink / raw
  To: gentoo-commits

commit:     2fe8907da06ac81a168832c8b87dedd809c8735a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 08:09:33 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Mar 10 23:47:35 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=2fe8907d

repoman: Create a new DependUnknown plugin class

 pym/repoman/modules/scan/depend/__init__.py |  9 +++++++++
 pym/repoman/modules/scan/depend/unknown.py  | 26 ++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 10 +---------
 3 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index cddb7f1..9fd7970 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -28,6 +28,15 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'unknown-module': {
+			'name': "unknown",
+			'sourcefile': "unknown",
+			'class': "DependUnknown",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py
new file mode 100644
index 0000000..b61a6e2
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/unknown.py
@@ -0,0 +1,26 @@
+# -*- coding:utf-8 -*-
+
+
+class DependUnknown(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		if not baddepsyntax and unknown_pkgs:
+			type_map = {}
+			for mytype, atom in unknown_pkgs:
+				type_map.setdefault(mytype, set()).add(atom)
+			for mytype, atoms in type_map.items():
+				self.qatracker.add_error(
+					"dependency.unknown", "%s: %s: %s"
+					% (ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
+		return {'continue': False}
+
+	@property
+	def runInEbuilds(self):
+		return (True, [self.check])

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index c1f5751..4f4f78b 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -290,6 +290,7 @@ class Scanner(object):
 				('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
 				# Options.is_forced() is used to bypass further checks
 				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
+				('unknown', 'DependUnknown'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -317,15 +318,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
-				type_map = {}
-				for mytype, atom in dynamic_data['unknown_pkgs']:
-					type_map.setdefault(mytype, set()).add(atom)
-				for mytype, atoms in type_map.items():
-					self.qatracker.add_error(
-						"dependency.unknown", "%s: %s: %s"
-						% (dynamic_data['ebuild'].relative_path, mytype, ", ".join(sorted(atoms))))
-
 		# check if there are unused local USE-descriptions in metadata.xml
 		# (unless there are any invalids, to avoid noise)
 		if dynamic_data['allvalid']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
@ 2016-03-12 18:10 Brian Dolbec
  0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2016-03-12 18:10 UTC (permalink / raw
  To: gentoo-commits

commit:     6ae20cc6f72a48a44b052c63b193cf0166912f5d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 08:09:33 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Mar 12 17:57:38 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=6ae20cc6

repoman: Create a new DependUnknown plugin class

 pym/repoman/modules/scan/depend/__init__.py |  9 +++++++++
 pym/repoman/modules/scan/depend/unknown.py  | 26 ++++++++++++++++++++++++++
 pym/repoman/scanner.py                      | 10 +---------
 3 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/pym/repoman/modules/scan/depend/__init__.py b/pym/repoman/modules/scan/depend/__init__.py
index cddb7f1..9fd7970 100644
--- a/pym/repoman/modules/scan/depend/__init__.py
+++ b/pym/repoman/modules/scan/depend/__init__.py
@@ -28,6 +28,15 @@ module_spec = {
 			'func_desc': {
 			},
 		},
+		'unknown-module': {
+			'name': "unknown",
+			'sourcefile': "unknown",
+			'class': "DependUnknown",
+			'description': doc,
+			'functions': ['check'],
+			'func_desc': {
+			},
+		},
 	}
 }
 

diff --git a/pym/repoman/modules/scan/depend/unknown.py b/pym/repoman/modules/scan/depend/unknown.py
new file mode 100644
index 0000000..b61a6e2
--- /dev/null
+++ b/pym/repoman/modules/scan/depend/unknown.py
@@ -0,0 +1,26 @@
+# -*- coding:utf-8 -*-
+
+
+class DependUnknown(object):
+
+	def __init__(self, **kwargs):
+		self.qatracker = kwargs.get('qatracker')
+
+	def check(self, **kwargs):
+		ebuild = kwargs.get('ebuild')
+		baddepsyntax = kwargs.get('baddepsyntax')
+		unknown_pkgs = kwargs.get('unknown_pkgs')
+
+		if not baddepsyntax and unknown_pkgs:
+			type_map = {}
+			for mytype, atom in unknown_pkgs:
+				type_map.setdefault(mytype, set()).add(atom)
+			for mytype, atoms in type_map.items():
+				self.qatracker.add_error(
+					"dependency.unknown", "%s: %s: %s"
+					% (ebuild.relative_path, mytype, ", ".join(sorted(atoms))))
+		return {'continue': False}
+
+	@property
+	def runInEbuilds(self):
+		return (True, [self.check])

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index c1f5751..4f4f78b 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -290,6 +290,7 @@ class Scanner(object):
 				('mtime', 'MtimeChecks'), ('multicheck', 'MultiCheck'),
 				# Options.is_forced() is used to bypass further checks
 				('options', 'Options'), ('profile', 'ProfileDependsChecks'),
+				('unknown', 'DependUnknown'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -317,15 +318,6 @@ class Scanner(object):
 			if y_ebuild_continue:
 				continue
 
-			if not dynamic_data['baddepsyntax'] and dynamic_data['unknown_pkgs']:
-				type_map = {}
-				for mytype, atom in dynamic_data['unknown_pkgs']:
-					type_map.setdefault(mytype, set()).add(atom)
-				for mytype, atoms in type_map.items():
-					self.qatracker.add_error(
-						"dependency.unknown", "%s: %s: %s"
-						% (dynamic_data['ebuild'].relative_path, mytype, ", ".join(sorted(atoms))))
-
 		# check if there are unused local USE-descriptions in metadata.xml
 		# (unless there are any invalids, to avoid noise)
 		if dynamic_data['allvalid']:


^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2016-03-12 18:10 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-31 20:03 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/ Brian Dolbec
  -- strict thread matches above, loose matches on Subject: below --
2016-03-12 18:10 Brian Dolbec
2016-03-11  0:41 Brian Dolbec
2016-03-07 21:53 Brian Dolbec
2016-03-07 21:53 Brian Dolbec
2016-01-31 20:03 Brian Dolbec
2016-01-30  8:00 Brian Dolbec
2016-01-30  6:58 Brian Dolbec
2016-01-30  6:58 Brian Dolbec
2016-01-30  6:58 Brian Dolbec
2016-01-30  6:58 Brian Dolbec
2016-01-29  5:01 Brian Dolbec
2016-01-29  5:01 Brian Dolbec
2016-01-27 23:15 Brian Dolbec
2016-01-23  1:42 Brian Dolbec
2016-01-23  1:42 Brian Dolbec
2016-01-21 19:42 Brian Dolbec
2016-01-21 18:30 Brian Dolbec
2016-01-18 19:23 Brian Dolbec
2016-01-11  8:01 Brian Dolbec
2016-01-11  6:31 Brian Dolbec
2016-01-11  6:31 Brian Dolbec
2016-01-10 20:17 Brian Dolbec
2016-01-10 20:17 Brian Dolbec
2016-01-10  3:26 Brian Dolbec
2016-01-10  3:26 Brian Dolbec
2016-01-10  3:26 Brian Dolbec
2016-01-06  4:21 Brian Dolbec
2016-01-06  4:21 Brian Dolbec
2016-01-06  4:21 Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox