public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/_emerge/
@ 2011-05-31  2:18 Zac Medico
  0 siblings, 0 replies; 8+ messages in thread
From: Zac Medico @ 2011-05-31  2:18 UTC (permalink / raw
  To: gentoo-commits

commit:     4f66159887fc4e3ec8bd87ae0f08ba249f98631b
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue May 31 02:16:43 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue May 31 02:16:43 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4f661598

dep_zapdeps: use digraph for preference selection

This is required in order for dep_zapdeps to work as intended for
solving cases of bug #264434 in which there is an installed
package that may need to be uninstalled in order to resolve blockers.
It fixes a failure to resolve blockers when attempting to replace
media-video/ffmpeg with media-video/libav (symptom is similar to
bug #339164, but with new-style virtual instead of old-style PROVIDE
virtual).

---
 pym/_emerge/depgraph.py      |    3 +++
 pym/portage/dep/dep_check.py |   11 +++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index de75eb1..d05b564 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -450,6 +450,8 @@ class _dynamic_depgraph_config(object):
 			# have already been made.
 			self._graph_trees[myroot]["porttree"]   = graph_tree
 			self._graph_trees[myroot]["vartree"]    = graph_tree
+			self._graph_trees[myroot]["graph_db"]   = graph_tree.dbapi
+			self._graph_trees[myroot]["graph"]      = self.digraph
 			def filtered_tree():
 				pass
 			filtered_tree.dbapi = _dep_check_composite_db(depgraph, myroot)
@@ -473,6 +475,7 @@ class _dynamic_depgraph_config(object):
 			# unresolvable direct circular dependencies can be detected and
 			# avoided when possible.
 			self._filtered_trees[myroot]["graph_db"] = graph_tree.dbapi
+			self._filtered_trees[myroot]["graph"]    = self.digraph
 			self._filtered_trees[myroot]["vartree"] = \
 				depgraph._frozen_config.trees[myroot]["vartree"]
 

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 53fce12..01d5021 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -317,6 +317,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 	parent   = trees[myroot].get("parent")
 	priority = trees[myroot].get("priority")
 	graph_db = trees[myroot].get("graph_db")
+	graph    = trees[myroot].get("graph")
 	vardb = None
 	if "vartree" in trees[myroot]:
 		vardb = trees[myroot]["vartree"].dbapi
@@ -417,8 +418,14 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 				all_in_graph = True
 				for slot_atom in slot_map:
 					# New-style virtuals have zero cost to install.
-					if not graph_db.match(slot_atom) and \
-						not slot_atom.startswith("virtual/"):
+					if slot_atom.startswith("virtual/"):
+						continue
+					# We check if the matched package has actually been
+					# added to the digraph, in order to distinguish between
+					# those packages and installed packages that may need
+					# to be uninstalled in order to resolve blockers.
+					graph_matches = graph_db.match_pkgs(slot_atom)
+					if not graph_matches or graph_matches[-1] not in graph:
 						all_in_graph = False
 						break
 				circular_atom = None



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/_emerge/
@ 2014-08-28 16:07 Zac Medico
  0 siblings, 0 replies; 8+ messages in thread
From: Zac Medico @ 2014-08-28 16:07 UTC (permalink / raw
  To: gentoo-commits

commit:     617a64f77055ddda1dd86a506cf98f5adc545fae
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 28 00:07:10 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Aug 28 16:02:42 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=617a64f7

dep_check: fix bug #515230

This fixes dep_check so that graph packages do not mask non-graph
packages (in the same slot) unless the graph packages also match the
dependency atom being satisfied. This requires logic changes in both
_dep_check_composite_db._visible and dep_zapdeps.

Also, fix _dep_check_composite_db match / _cpv_pkg_map
interactions to ensure correct match results.

X-Gentoo-Bug: 515230
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=515230

---
 pym/_emerge/depgraph.py      | 30 +++++++++++++++++++-----------
 pym/portage/dep/dep_check.py | 10 +++++-----
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index a10297a..845a43a 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -8259,18 +8259,20 @@ class _dep_check_composite_db(dbapi):
 
 		return ret
 
-	def match(self, atom):
+	def match_pkgs(self, atom):
 		cache_key = (atom, atom.unevaluated_atom)
 		ret = self._match_cache.get(cache_key)
 		if ret is not None:
+			for pkg in ret:
+				self._cpv_pkg_map[pkg.cpv] = pkg
 			return ret[:]
 
+		atom_set = InternalPackageSet(initial_atoms=(atom,))
 		ret = []
 		pkg, existing = self._depgraph._select_package(self._root, atom)
 
-		if pkg is not None and self._visible(pkg):
-			self._cpv_pkg_map[pkg.cpv] = pkg
-			ret.append(pkg.cpv)
+		if pkg is not None and self._visible(pkg, atom_set):
+			ret.append(pkg)
 
 		if pkg is not None and \
 			atom.slot is None and \
@@ -8301,18 +8303,19 @@ class _dep_check_composite_db(dbapi):
 					self._root, slot_atom)
 				if not pkg:
 					continue
-				if not self._visible(pkg):
+				if not self._visible(pkg, atom_set):
 					continue
-				self._cpv_pkg_map[pkg.cpv] = pkg
-				ret.append(pkg.cpv)
+				ret.append(pkg)
 
 			if len(ret) > 1:
-				self._cpv_sort_ascending(ret)
+				ret.sort()
 
 		self._match_cache[cache_key] = ret
+		for pkg in ret:
+			self._cpv_pkg_map[pkg.cpv] = pkg
 		return ret[:]
 
-	def _visible(self, pkg):
+	def _visible(self, pkg, atom_set):
 		if pkg.installed and not self._depgraph._want_installed_pkg(pkg):
 			return False
 		if pkg.installed and \
@@ -8350,6 +8353,11 @@ class _dep_check_composite_db(dbapi):
 		elif in_graph != pkg:
 			# Mask choices for packages that would trigger a slot
 			# conflict with a previously selected package.
+			if not atom_set.findAtomForPackage(in_graph,
+				modified_use=self._depgraph._pkg_use_enabled(in_graph)):
+				# Only mask if the graph package matches the given
+				# atom (fixes bug #515230).
+				return True
 			return False
 		return True
 
@@ -8357,8 +8365,8 @@ class _dep_check_composite_db(dbapi):
 		metadata = self._cpv_pkg_map[cpv]._metadata
 		return [metadata.get(x, "") for x in wants]
 
-	def match_pkgs(self, atom):
-		return [self._cpv_pkg_map[cpv] for cpv in self.match(atom)]
+	def match(self, atom):
+		return [pkg.cpv for pkg in self.match_pkgs(atom)]
 
 def ambiguous_package_name(arg, atoms, root_config, spinner, myopts):
 

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index b79c5bc..22eed96 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2013 Gentoo Foundation
+# Copyright 2010-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import unicode_literals
@@ -414,16 +414,16 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 						unsat_use_non_installed.append(this_choice)
 			else:
 				all_in_graph = True
-				for slot_atom in slot_map:
+				for atom in atoms:
 					# New-style virtuals have zero cost to install.
-					if slot_atom.startswith("virtual/"):
+					if atom.blocker or atom.cp.startswith("virtual/"):
 						continue
 					# We check if the matched package has actually been
 					# added to the digraph, in order to distinguish between
 					# those packages and installed packages that may need
 					# to be uninstalled in order to resolve blockers.
-					graph_matches = graph_db.match_pkgs(slot_atom)
-					if not graph_matches or graph_matches[-1] not in graph:
+					if not any(pkg in graph for pkg in
+						graph_db.match_pkgs(atom)):
 						all_in_graph = False
 						break
 				circular_atom = None


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/_emerge/
@ 2012-06-09  0:27 Zac Medico
  0 siblings, 0 replies; 8+ messages in thread
From: Zac Medico @ 2012-06-09  0:27 UTC (permalink / raw
  To: gentoo-commits

commit:     50e4d62e296c2579682d2cf11a29ada83c1323db
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  8 22:08:19 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jun  9 00:27:12 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=50e4d62e

depgraph: pass use_reduce result to dep_check

This allows us to avoid extraneous use_reduce/paren_enclose calls.

---
 pym/_emerge/depgraph.py      |   58 +++++++++++++++++------------------------
 pym/portage/dep/__init__.py  |    7 +++-
 pym/portage/dep/dep_check.py |   15 ++++++----
 3 files changed, 38 insertions(+), 42 deletions(-)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 935c376..2e98be8 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -1456,7 +1456,10 @@ class depgraph(object):
 
 				try:
 					dep_string = portage.dep.use_reduce(dep_string,
-						uselist=self._pkg_use_enabled(pkg), is_valid_flag=pkg.iuse.is_valid_flag)
+						uselist=self._pkg_use_enabled(pkg),
+						is_valid_flag=pkg.iuse.is_valid_flag,
+						opconvert=True, token_class=Atom,
+						eapi=pkg.metadata['EAPI'])
 				except portage.exception.InvalidDependString as e:
 					if not pkg.installed:
 						# should have been masked before it was selected
@@ -1468,7 +1471,9 @@ class depgraph(object):
 					# practical to ignore this issue for installed packages.
 					try:
 						dep_string = portage.dep.use_reduce(dep_string,
-							uselist=self._pkg_use_enabled(pkg))
+							uselist=self._pkg_use_enabled(pkg),
+							opconvert=True, token_class=Atom,
+							eapi=pkg.metadata['EAPI'])
 					except portage.exception.InvalidDependString as e:
 						self._dynamic_config._masked_installed.add(pkg)
 						del e
@@ -1489,9 +1494,6 @@ class depgraph(object):
 				if not dep_string:
 					continue
 
-				dep_string = portage.dep.paren_enclose(dep_string,
-					unevaluated_atom=True)
-
 				if not self._add_pkg_dep_string(
 					pkg, dep_root, dep_priority, dep_string,
 					allow_unsatisfied):
@@ -1525,7 +1527,9 @@ class depgraph(object):
 		if debug:
 			writemsg_level("\nParent:    %s\n" % (pkg,),
 				noiselevel=-1, level=logging.DEBUG)
-			writemsg_level("Depstring: %s\n" % (dep_string,),
+			dep_repr = portage.dep.paren_enclose(dep_string,
+				unevaluated_atom=True, opconvert=True)
+			writemsg_level("Depstring: %s\n" % (dep_repr,),
 				noiselevel=-1, level=logging.DEBUG)
 			writemsg_level("Priority:  %s\n" % (dep_priority,),
 				noiselevel=-1, level=logging.DEBUG)
@@ -1847,34 +1851,22 @@ class depgraph(object):
 		Yields non-disjunctive deps. Raises InvalidDependString when 
 		necessary.
 		"""
-		i = 0
-		while i < len(dep_struct):
-			x = dep_struct[i]
+		for x in dep_struct:
 			if isinstance(x, list):
-				for y in self._queue_disjunctive_deps(
-					pkg, dep_root, dep_priority, x):
-					yield y
-			elif x == "||":
-				self._queue_disjunction(pkg, dep_root, dep_priority,
-					[ x, dep_struct[ i + 1 ] ] )
-				i += 1
+				if x and x[0] == "||":
+					self._queue_disjunction(pkg, dep_root, dep_priority, [x])
+				else:
+					for y in self._queue_disjunctive_deps(
+						pkg, dep_root, dep_priority, x):
+						yield y
 			else:
-				try:
-					x = portage.dep.Atom(x, eapi=pkg.metadata["EAPI"])
-				except portage.exception.InvalidAtom:
-					if not pkg.installed:
-						raise portage.exception.InvalidDependString(
-							"invalid atom: '%s'" % x)
+				# Note: Eventually this will check for PROPERTIES=virtual
+				# or whatever other metadata gets implemented for this
+				# purpose.
+				if x.cp.startswith('virtual/'):
+					self._queue_disjunction(pkg, dep_root, dep_priority, [x])
 				else:
-					# Note: Eventually this will check for PROPERTIES=virtual
-					# or whatever other metadata gets implemented for this
-					# purpose.
-					if x.cp.startswith('virtual/'):
-						self._queue_disjunction( pkg, dep_root,
-							dep_priority, [ str(x) ] )
-					else:
-						yield str(x)
-			i += 1
+					yield x
 
 	def _queue_disjunction(self, pkg, dep_root, dep_priority, dep_struct):
 		self._dynamic_config._dep_disjunctive_stack.append(
@@ -1887,10 +1879,8 @@ class depgraph(object):
 		"""
 		pkg, dep_root, dep_priority, dep_struct = \
 			self._dynamic_config._dep_disjunctive_stack.pop()
-		dep_string = portage.dep.paren_enclose(dep_struct,
-			unevaluated_atom=True)
 		if not self._add_pkg_dep_string(
-			pkg, dep_root, dep_priority, dep_string, allow_unsatisfied):
+			pkg, dep_root, dep_priority, dep_struct, allow_unsatisfied):
 			return 0
 		return 1
 

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 4cd0813..ade3a73 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -250,7 +250,7 @@ class paren_normalize(list):
 					self._zap_parens(x, dest)
 		return dest
 
-def paren_enclose(mylist, unevaluated_atom=False):
+def paren_enclose(mylist, unevaluated_atom=False, opconvert=False):
 	"""
 	Convert a list to a string with sublists enclosed with parens.
 
@@ -267,7 +267,10 @@ def paren_enclose(mylist, unevaluated_atom=False):
 	mystrparts = []
 	for x in mylist:
 		if isinstance(x, list):
-			mystrparts.append("( "+paren_enclose(x)+" )")
+			if opconvert and x and x[0] == "||":
+				mystrparts.append("%s ( %s )" % (x[0], paren_enclose(x[1:])))
+			else:
+				mystrparts.append("( %s )" % paren_enclose(x))
 		else:
 			if unevaluated_atom:
 				x = getattr(x, 'unevaluated_atom', x)

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 99a5eb0..d575ab3 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -611,12 +611,15 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
 		if not current_parent.installed:
 			eapi = current_parent.metadata['EAPI']
 
-	try:
-		mysplit = use_reduce(depstring, uselist=myusesplit, masklist=mymasks, \
-			matchall=(use=="all"), excludeall=useforce, opconvert=True, \
-			token_class=Atom, eapi=eapi)
-	except InvalidDependString as e:
-		return [0, _unicode_decode("%s") % (e,)]
+	if isinstance(depstring, list):
+		mysplit = depstring
+	else:
+		try:
+			mysplit = use_reduce(depstring, uselist=myusesplit,
+			masklist=mymasks, matchall=(use=="all"), excludeall=useforce,
+			opconvert=True, token_class=Atom, eapi=eapi)
+		except InvalidDependString as e:
+			return [0, _unicode_decode("%s") % (e,)]
 
 	if mysplit == []:
 		#dependencies were reduced to nothing



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/_emerge/
@ 2012-06-08 22:08 Zac Medico
  0 siblings, 0 replies; 8+ messages in thread
From: Zac Medico @ 2012-06-08 22:08 UTC (permalink / raw
  To: gentoo-commits

commit:     25dee769cf7bef29a21e5357bee9188c46391121
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  8 22:08:19 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jun  8 22:08:19 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=25dee769

depgraph: pass use_reduce result to dep_check

This allows us to avoid extraneous use_reduce/paren_enclose calls.

---
 pym/_emerge/depgraph.py      |   58 +++++++++++++++++------------------------
 pym/portage/dep/__init__.py  |    7 +++-
 pym/portage/dep/dep_check.py |   15 ++++++----
 3 files changed, 38 insertions(+), 42 deletions(-)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 935c376..9d3ca33 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -1456,7 +1456,10 @@ class depgraph(object):
 
 				try:
 					dep_string = portage.dep.use_reduce(dep_string,
-						uselist=self._pkg_use_enabled(pkg), is_valid_flag=pkg.iuse.is_valid_flag)
+						uselist=self._pkg_use_enabled(pkg),
+						is_valid_flag=pkg.iuse.is_valid_flag,
+						opconvert=True, token_class=Atom,
+						eapi=pkg.metadata['EAPI'])
 				except portage.exception.InvalidDependString as e:
 					if not pkg.installed:
 						# should have been masked before it was selected
@@ -1468,7 +1471,9 @@ class depgraph(object):
 					# practical to ignore this issue for installed packages.
 					try:
 						dep_string = portage.dep.use_reduce(dep_string,
-							uselist=self._pkg_use_enabled(pkg))
+							uselist=self._pkg_use_enabled(pkg),
+							opconvert=True, token_class=Atom,
+							eapi=pkg.metadata['EAPI'])
 					except portage.exception.InvalidDependString as e:
 						self._dynamic_config._masked_installed.add(pkg)
 						del e
@@ -1489,9 +1494,6 @@ class depgraph(object):
 				if not dep_string:
 					continue
 
-				dep_string = portage.dep.paren_enclose(dep_string,
-					unevaluated_atom=True)
-
 				if not self._add_pkg_dep_string(
 					pkg, dep_root, dep_priority, dep_string,
 					allow_unsatisfied):
@@ -1525,7 +1527,9 @@ class depgraph(object):
 		if debug:
 			writemsg_level("\nParent:    %s\n" % (pkg,),
 				noiselevel=-1, level=logging.DEBUG)
-			writemsg_level("Depstring: %s\n" % (dep_string,),
+			dep_repr = portage.dep.paren_enclose(dep_string,
+				unevaluated_atom=True, opconvert=True)
+			writemsg_level("Depstring: %s\n" % (dep_repr,),
 				noiselevel=-1, level=logging.DEBUG)
 			writemsg_level("Priority:  %s\n" % (dep_priority,),
 				noiselevel=-1, level=logging.DEBUG)
@@ -1847,34 +1851,22 @@ class depgraph(object):
 		Yields non-disjunctive deps. Raises InvalidDependString when 
 		necessary.
 		"""
-		i = 0
-		while i < len(dep_struct):
-			x = dep_struct[i]
+		for x in dep_struct:
 			if isinstance(x, list):
-				for y in self._queue_disjunctive_deps(
-					pkg, dep_root, dep_priority, x):
-					yield y
-			elif x == "||":
-				self._queue_disjunction(pkg, dep_root, dep_priority,
-					[ x, dep_struct[ i + 1 ] ] )
-				i += 1
+				if x and x[0] == "||":
+					self._queue_disjunction(pkg, dep_root, dep_priority, x)
+				else:
+					for y in self._queue_disjunctive_deps(
+						pkg, dep_root, dep_priority, x):
+						yield y
 			else:
-				try:
-					x = portage.dep.Atom(x, eapi=pkg.metadata["EAPI"])
-				except portage.exception.InvalidAtom:
-					if not pkg.installed:
-						raise portage.exception.InvalidDependString(
-							"invalid atom: '%s'" % x)
+				# Note: Eventually this will check for PROPERTIES=virtual
+				# or whatever other metadata gets implemented for this
+				# purpose.
+				if x.cp.startswith('virtual/'):
+					self._queue_disjunction(pkg, dep_root, dep_priority, [x])
 				else:
-					# Note: Eventually this will check for PROPERTIES=virtual
-					# or whatever other metadata gets implemented for this
-					# purpose.
-					if x.cp.startswith('virtual/'):
-						self._queue_disjunction( pkg, dep_root,
-							dep_priority, [ str(x) ] )
-					else:
-						yield str(x)
-			i += 1
+					yield x
 
 	def _queue_disjunction(self, pkg, dep_root, dep_priority, dep_struct):
 		self._dynamic_config._dep_disjunctive_stack.append(
@@ -1887,10 +1879,8 @@ class depgraph(object):
 		"""
 		pkg, dep_root, dep_priority, dep_struct = \
 			self._dynamic_config._dep_disjunctive_stack.pop()
-		dep_string = portage.dep.paren_enclose(dep_struct,
-			unevaluated_atom=True)
 		if not self._add_pkg_dep_string(
-			pkg, dep_root, dep_priority, dep_string, allow_unsatisfied):
+			pkg, dep_root, dep_priority, dep_struct, allow_unsatisfied):
 			return 0
 		return 1
 

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 4cd0813..ade3a73 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -250,7 +250,7 @@ class paren_normalize(list):
 					self._zap_parens(x, dest)
 		return dest
 
-def paren_enclose(mylist, unevaluated_atom=False):
+def paren_enclose(mylist, unevaluated_atom=False, opconvert=False):
 	"""
 	Convert a list to a string with sublists enclosed with parens.
 
@@ -267,7 +267,10 @@ def paren_enclose(mylist, unevaluated_atom=False):
 	mystrparts = []
 	for x in mylist:
 		if isinstance(x, list):
-			mystrparts.append("( "+paren_enclose(x)+" )")
+			if opconvert and x and x[0] == "||":
+				mystrparts.append("%s ( %s )" % (x[0], paren_enclose(x[1:])))
+			else:
+				mystrparts.append("( %s )" % paren_enclose(x))
 		else:
 			if unevaluated_atom:
 				x = getattr(x, 'unevaluated_atom', x)

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 99a5eb0..d575ab3 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -611,12 +611,15 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
 		if not current_parent.installed:
 			eapi = current_parent.metadata['EAPI']
 
-	try:
-		mysplit = use_reduce(depstring, uselist=myusesplit, masklist=mymasks, \
-			matchall=(use=="all"), excludeall=useforce, opconvert=True, \
-			token_class=Atom, eapi=eapi)
-	except InvalidDependString as e:
-		return [0, _unicode_decode("%s") % (e,)]
+	if isinstance(depstring, list):
+		mysplit = depstring
+	else:
+		try:
+			mysplit = use_reduce(depstring, uselist=myusesplit,
+			masklist=mymasks, matchall=(use=="all"), excludeall=useforce,
+			opconvert=True, token_class=Atom, eapi=eapi)
+		except InvalidDependString as e:
+			return [0, _unicode_decode("%s") % (e,)]
 
 	if mysplit == []:
 		#dependencies were reduced to nothing



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/_emerge/
@ 2012-05-12 23:27 Zac Medico
  0 siblings, 0 replies; 8+ messages in thread
From: Zac Medico @ 2012-05-12 23:27 UTC (permalink / raw
  To: gentoo-commits

commit:     895e2cda1b83d282131eb4b12278654cc6bca141
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May 12 23:27:32 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 12 23:27:32 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=895e2cda

match_from_list: handle Package.UNKNOWN_REPO

---
 pym/_emerge/Package.py      |    7 ++++---
 pym/portage/dep/__init__.py |    5 ++++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py
index e4d416c..ec0c3f6 100644
--- a/pym/_emerge/Package.py
+++ b/pym/_emerge/Package.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import sys
@@ -8,7 +8,8 @@ from portage import _encodings, _unicode_decode, _unicode_encode
 from portage.cache.mappings import slot_dict_class
 from portage.const import EBUILD_PHASES
 from portage.dep import Atom, check_required_use, use_reduce, \
-	paren_enclose, _slot_re, _slot_separator, _repo_separator
+	paren_enclose, _slot_re, _slot_separator, _repo_separator, \
+	_unknown_repo
 from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
 from portage.exception import InvalidDependString
 from portage.repository.config import _gen_valid_repo
@@ -38,7 +39,7 @@ class Package(Task):
 
 	_dep_keys = ('DEPEND', 'PDEPEND', 'RDEPEND',)
 	_use_conditional_misc_keys = ('LICENSE', 'PROPERTIES', 'RESTRICT')
-	UNKNOWN_REPO = "__unknown__"
+	UNKNOWN_REPO = _unknown_repo
 
 	def __init__(self, **kwargs):
 		Task.__init__(self, **kwargs)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index de8d1c4..d4888e0 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -54,6 +54,8 @@ if sys.hexversion >= 0x3000000:
 # stable keywords, make these warnings unconditional.
 _internal_warnings = False
 
+_unknown_repo = "__unknown__"
+
 def cpvequal(cpv1, cpv2):
 	"""
 	
@@ -2086,7 +2088,8 @@ def match_from_list(mydep, candidate_list):
 			repo = getattr(x, "repo", False)
 			if repo is False:
 				repo = dep_getrepo(x)
-			if repo is not None and repo != mydep.repo:
+			if repo is not None and repo != _unknown_repo and \
+				repo != mydep.repo:
 				continue
 			mylist.append(x)
 



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/_emerge/
@ 2011-02-13  7:39 Zac Medico
  0 siblings, 0 replies; 8+ messages in thread
From: Zac Medico @ 2011-02-13  7:39 UTC (permalink / raw
  To: gentoo-commits

commit:     37b9c61f2d16d09a4ae1bcb61d63af4e64b667f4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 13 07:36:07 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Feb 13 07:36:07 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=37b9c61f

depgraph: avoid atom hash collisions in dep_check

Atoms are stored in the graph as (atom, id(atom)) tuples since each
atom is considered to be a unique entity. For example, atoms that
appear identical may behave differently in USE matching, depending on
their unevaluated form. Also, specially generated virtual atoms may
appear identical while having different _orig_atom attributes.

---
 pym/_emerge/depgraph.py      |   15 ++++++++-------
 pym/portage/dep/dep_check.py |   24 ++++++++++++++++--------
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index e571763..bec9ffd 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -2146,7 +2146,7 @@ class depgraph(object):
 		if parent is None:
 			selected_atoms = mycheck[1]
 		else:
-			chosen_atoms = frozenset(mycheck[1])
+			chosen_atom_ids = frozenset(id(atom) for atom in mycheck[1])
 			selected_atoms = OrderedDict()
 			node_stack = [(parent, None, None)]
 			traversed_nodes = set()
@@ -2169,13 +2169,14 @@ class depgraph(object):
 						depth=node.depth, parent=node_parent,
 						priority=node_priority, root=node.root)
 
-				child_atoms = atom_graph.child_nodes(node)
-				selected_atoms[k] = [atom for atom in \
-					child_atoms if atom in chosen_atoms]
-				for child_atom in child_atoms:
-					if child_atom not in chosen_atoms:
+				child_atoms = []
+				selected_atoms[k] = child_atoms
+				for atom_node in atom_graph.child_nodes(node):
+					child_atom = atom_node[0]
+					if id(child_atom) not in chosen_atom_ids:
 						continue
-					for child_node in atom_graph.child_nodes(child_atom):
+					child_atoms.append(child_atom)
+					for child_node in atom_graph.child_nodes(atom_node):
 						if child_node in traversed_nodes:
 							continue
 						if not portage.match_from_list(

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 200f016..4d26f51 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -28,6 +28,12 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 	mytrees = trees[myroot]
 	portdb = mytrees["porttree"].dbapi
 	pkg_use_enabled = mytrees.get("pkg_use_enabled")
+	# Atoms are stored in the graph as (atom, id(atom)) tuples
+	# since each atom is considered to be a unique entity. For
+	# example, atoms that appear identical may behave differently
+	# in USE matching, depending on their unevaluated form. Also,
+	# specially generated virtual atoms may appear identical while
+	# having different _orig_atom attributes.
 	atom_graph = mytrees.get("atom_graph")
 	parent = mytrees.get("parent")
 	virt_parent = mytrees.get("virt_parent")
@@ -67,7 +73,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 		if not mykey.startswith("virtual/"):
 			newsplit.append(x)
 			if atom_graph is not None:
-				atom_graph.add(x, graph_parent)
+				atom_graph.add((x, id(x)), graph_parent)
 			continue
 		mychoices = myvirtuals.get(mykey, [])
 		if x.blocker:
@@ -76,7 +82,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 			# maintaining a cache of blocker atoms.
 			newsplit.append(x)
 			if atom_graph is not None:
-				atom_graph.add(x, graph_parent)
+				atom_graph.add((x, id(x)), graph_parent)
 			continue
 
 		if repoman or not hasattr(portdb, 'match_pkgs') or \
@@ -115,7 +121,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 			# dependency that needs to be satisfied.
 			newsplit.append(x)
 			if atom_graph is not None:
-				atom_graph.add(x, graph_parent)
+				atom_graph.add((x, id(x)), graph_parent)
 			continue
 
 		a = []
@@ -174,8 +180,9 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 			mycheck[1].append(virt_atom)
 			a.append(mycheck[1])
 			if atom_graph is not None:
-				atom_graph.add(virt_atom, graph_parent)
-				atom_graph.add(pkg, virt_atom)
+				virt_atom_node = (virt_atom, id(virt_atom))
+				atom_graph.add(virt_atom_node, graph_parent)
+				atom_graph.add(pkg, virt_atom_node)
 		# Plain old-style virtuals.  New-style virtuals are preferred.
 		if not pkgs:
 				for y in mychoices:
@@ -187,7 +194,8 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 						portdb.aux_get(matches[-1], ['PROVIDE'])[0].split():
 						a.append(new_atom)
 						if atom_graph is not None:
-							atom_graph.add(new_atom, graph_parent)
+							atom_graph.add((new_atom, id(new_atom)),
+								graph_parent)
 
 		if not a and mychoices:
 			# Check for a virtual package.provided match.
@@ -197,12 +205,12 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 					pprovideddict.get(new_atom.cp, [])):
 					a.append(new_atom)
 					if atom_graph is not None:
-						atom_graph.add(new_atom, graph_parent)
+						atom_graph.add((new_atom, id(new_atom)), graph_parent)
 
 		if not a:
 			newsplit.append(x)
 			if atom_graph is not None:
-				atom_graph.add(x, graph_parent)
+				atom_graph.add((x, id(x)), graph_parent)
 		elif len(a) == 1:
 			newsplit.append(a[0])
 		else:



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/_emerge/
@ 2011-02-13  1:54 Zac Medico
  0 siblings, 0 replies; 8+ messages in thread
From: Zac Medico @ 2011-02-13  1:54 UTC (permalink / raw
  To: gentoo-commits

commit:     c42004eb552c9117d221b0e2063e8696efca35dc
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 13 01:52:11 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Feb 13 01:52:11 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c42004eb

depgraph: return virtual edges from select_atoms

---
 pym/_emerge/depgraph.py      |   78 ++++++++++++++++++++++-------------------
 pym/portage/dep/dep_check.py |    7 ++--
 2 files changed, 46 insertions(+), 39 deletions(-)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index fb54f50..e571763 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -12,7 +12,7 @@ import textwrap
 from itertools import chain
 
 import portage
-from portage import os
+from portage import os, OrderedDict
 from portage import _unicode_decode
 from portage.const import PORTAGE_PACKAGE_ATOM
 from portage.dbapi import dbapi
@@ -1277,31 +1277,16 @@ class depgraph(object):
 		# by dep_zapdeps. We preserve actual parent/child relationships
 		# here in order to avoid distorting the dependency graph like
 		# <=portage-2.1.6.x did.
-		while selected_atoms:
-
-			# Since _select_atoms currently doesn't return parent
-			# info for recursively traversed virtuals, the parent
-			# is not known here. However, this package may have
-			# already been added to graph above, so we add packages
-			# with parents first. This way, parents are already
-			# recorded before a given package is added, which allows
-			# us to avoid triggering a slot conflict before the
-			# parent is known.
-			for virt_pkg, atoms in selected_atoms.items():
-				try:
-					if self._dynamic_config.digraph.parent_nodes(virt_pkg):
-						break
-				except KeyError:
-					pass
+		for virt_dep, atoms in selected_atoms.items():
 
-			selected_atoms.pop(virt_pkg)
+			virt_pkg = virt_dep.child
 
 			if debug:
 				writemsg_level("Candidates: %s: %s\n" % \
 					(virt_pkg.cpv, [str(x) for x in atoms]),
 					noiselevel=-1, level=logging.DEBUG)
 
-			if not self._add_pkg(virt_pkg, None):
+			if not self._add_pkg(virt_pkg, virt_dep):
 				return 0
 
 			for atom, child in self._minimize_children(
@@ -2162,26 +2147,47 @@ class depgraph(object):
 			selected_atoms = mycheck[1]
 		else:
 			chosen_atoms = frozenset(mycheck[1])
-			selected_atoms = {parent : []}
-			for node in atom_graph:
-				if isinstance(node, Atom):
-					continue
+			selected_atoms = OrderedDict()
+			node_stack = [(parent, None, None)]
+			traversed_nodes = set()
+			while node_stack:
+				node, node_parent, parent_atom = node_stack.pop()
+				traversed_nodes.add(node)
 				if node is parent:
-					pkg = parent
+					k = parent
 				else:
-					pkg, virt_atom = node
-					if virt_atom not in chosen_atoms:
-						continue
-					if not portage.match_from_list(virt_atom, [pkg]):
-						# Typically this means that the atom
-						# specifies USE deps that are unsatisfied
-						# by the selected package. The caller will
-						# record this as an unsatisfied dependency
-						# when necessary.
+					if node_parent is parent:
+						if priority is None:
+							node_priority = None
+						else:
+							node_priority = priority.copy()
+					else:
+						# virtuals only have runtime deps
+						node_priority = self._priority(runtime=True)
+					k = Dependency(atom=parent_atom,
+						blocker=parent_atom.blocker, child=node,
+						depth=node.depth, parent=node_parent,
+						priority=node_priority, root=node.root)
+
+				child_atoms = atom_graph.child_nodes(node)
+				selected_atoms[k] = [atom for atom in \
+					child_atoms if atom in chosen_atoms]
+				for child_atom in child_atoms:
+					if child_atom not in chosen_atoms:
 						continue
-
-				selected_atoms[pkg] = [atom for atom in \
-					atom_graph.child_nodes(node) if atom in chosen_atoms]
+					for child_node in atom_graph.child_nodes(child_atom):
+						if child_node in traversed_nodes:
+							continue
+						if not portage.match_from_list(
+							child_atom, [child_node]):
+							# Typically this means that the atom
+							# specifies USE deps that are unsatisfied
+							# by the selected package. The caller will
+							# record this as an unsatisfied dependency
+							# when necessary.
+							continue
+						child_node.depth = node.depth + 1
+						node_stack.append((child_node, node, child_atom))
 
 		return selected_atoms
 

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index ed85be6..200f016 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -36,7 +36,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 	if parent is not None:
 		if virt_parent is not None:
 			graph_parent = virt_parent
-			parent = virt_parent[0]
+			parent = virt_parent
 		else:
 			graph_parent = parent
 		eapi = parent.metadata["EAPI"]
@@ -154,7 +154,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 					% (depstring,), noiselevel=-1, level=logging.DEBUG)
 
 			# Set EAPI used for validation in dep_check() recursion.
-			mytrees["virt_parent"] = (pkg, virt_atom)
+			mytrees["virt_parent"] = pkg
 
 			try:
 				mycheck = dep_check(depstring, mydbapi, mysettings,
@@ -175,6 +175,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 			a.append(mycheck[1])
 			if atom_graph is not None:
 				atom_graph.add(virt_atom, graph_parent)
+				atom_graph.add(pkg, virt_atom)
 		# Plain old-style virtuals.  New-style virtuals are preferred.
 		if not pkgs:
 				for y in mychoices:
@@ -560,7 +561,7 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
 	eapi = None
 	if parent is not None:
 		if virt_parent is not None:
-			current_parent = virt_parent[0]
+			current_parent = virt_parent
 		else:
 			current_parent = parent
 



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/_emerge/
@ 2011-02-12  0:16 Zac Medico
  0 siblings, 0 replies; 8+ messages in thread
From: Zac Medico @ 2011-02-12  0:16 UTC (permalink / raw
  To: gentoo-commits

commit:     5b16e0d800f34dc90cdd8c505172ad16b97f0af4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 00:09:22 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 00:09:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5b16e0d8

depgraph: fix distorted display of virtuals

As mentioned in bug #353933, comment #4, special new-style virtual
atoms generated/distorted by _expand_new_virtuals() can prevent
extract_affecting_use() from working properly. This is fixed by
saving the original atoms so that the depgraph can map them back
into place at the appropriate step in dependency evaluation.

---
 pym/_emerge/depgraph.py      |   13 +++++++++++++
 pym/portage/dep/dep_check.py |    6 ++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 0cfd113..91ec250 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -1240,6 +1240,12 @@ class depgraph(object):
 		for atom, child in self._minimize_children(
 			pkg, dep_priority, root_config, selected_atoms[pkg]):
 
+			# If this was a specially generated virtual atom
+			# from dep_check, map it back to the original, in
+			# order to avoid distortion in places like display
+			# or conflict resolution code.
+			atom = getattr(atom, '_orig_atom', atom)
+
 			if ignore_blockers and atom.blocker:
 				# For --with-bdeps, ignore build-time only blockers
 				# that originate from built packages.
@@ -1290,6 +1296,13 @@ class depgraph(object):
 
 			for atom, child in self._minimize_children(
 				pkg, self._priority(runtime=True), root_config, atoms):
+
+				# If this was a specially generated virtual atom
+				# from dep_check, map it back to the original, in
+				# order to avoid distortion in places like display
+				# or conflict resolution code.
+				atom = getattr(atom, '_orig_atom', atom)
+
 				# This is a GLEP 37 virtual, so its deps are all runtime.
 				mypriority = self._priority(runtime=True)
 				if not atom.blocker:

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 6d2d99d..ed85be6 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -135,6 +135,12 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 						pkg_use_enabled(parent))
 			else:
 				virt_atom = Atom(virt_atom)
+
+			# Allow the depgraph to map this atom back to the
+			# original, in order to avoid distortion in places
+			# like display or conflict resolution code.
+			virt_atom.__dict__['_orig_atom'] = x
+
 			# According to GLEP 37, RDEPEND is the only dependency
 			# type that is valid for new-style virtuals. Repoman
 			# should enforce this.



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

end of thread, other threads:[~2014-08-28 16:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-31  2:18 [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/_emerge/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2014-08-28 16:07 Zac Medico
2012-06-09  0:27 Zac Medico
2012-06-08 22:08 Zac Medico
2012-05-12 23:27 Zac Medico
2011-02-13  7:39 Zac Medico
2011-02-13  1:54 Zac Medico
2011-02-12  0:16 Zac Medico

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