public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/
Date: Wed, 27 Jan 2016 23:15:33 +0000 (UTC)	[thread overview]
Message-ID: <1453934662.403c638f1a29097eb8de9e541c531e0d5ae7fc67.dolsen@gentoo> (raw)

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(


             reply	other threads:[~2016-01-27 23:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-27 23:15 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-03-12 18:10 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/depend/, pym/repoman/ 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-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-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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453934662.403c638f1a29097eb8de9e541c531e0d5ae7fc67.dolsen@gentoo \
    --to=dolsen@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox