From bdc8db06f61f3b4e7caf28f55b274ff303e7e0b9 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 27 Aug 2014 17:07:10 -0700 Subject: [PATCH] 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 | 9 +++++---- 2 files changed, 24 insertions(+), 15 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..957511f 100644 --- a/pym/portage/dep/dep_check.py +++ b/pym/portage/dep/dep_check.py @@ -414,16 +414,17 @@ 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: + graph_matches = graph_db.match_pkgs(atom) + if not graph_matches or \ + not any(pkg in graph for pkg in graph_matches): all_in_graph = False break circular_atom = None -- 1.8.1.5