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

Reply via email to