dep_zapdeps: use digraph for preference selection
authorZac Medico <zmedico@gentoo.org>
Tue, 31 May 2011 02:16:43 +0000 (19:16 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 31 May 2011 02:16:43 +0000 (19:16 -0700)
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
pym/portage/dep/dep_check.py

index de75eb131bf95b7f03e1bd6815b1623d735b2ef6..d05b5642a30dcc9cdc861bf8dc4b4b2fbf3814a9 100644 (file)
@@ -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"]
 
index 53fce128ebd791d95a001f84fc6e0354f1d8c5a8..01d502149b6f0397ce4747707f8abc7e548cdb0e 100644 (file)
@@ -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