Fix bug #460304.
authorZac Medico <zmedico@gentoo.org>
Tue, 5 Mar 2013 00:56:28 +0000 (16:56 -0800)
committerZac Medico <zmedico@gentoo.org>
Tue, 5 Mar 2013 00:56:28 +0000 (16:56 -0800)
pym/_emerge/depgraph.py
pym/portage/tests/resolver/test_slot_abi.py

index dddada072595ae086558bfbac8f6a0948480f3e9..90332851a6036fd74522dd39cc698106ae8682eb 100644 (file)
@@ -1189,6 +1189,8 @@ class depgraph(object):
                for replacement_parent in self._iter_similar_available(dep.parent,
                        dep.parent.slot_atom):
 
+                       selected_atoms = None
+
                        for atom in replacement_parent.validated_atoms:
                                if not atom.slot_operator == "=" or \
                                        atom.blocker or \
@@ -1198,6 +1200,7 @@ class depgraph(object):
                                # Discard USE deps, we're only searching for an approximate
                                # pattern, and dealing with USE states is too complex for
                                # this purpose.
+                               unevaluated_atom = atom.unevaluated_atom
                                atom = atom.without_use
 
                                if replacement_parent.built and \
@@ -1247,6 +1250,17 @@ class depgraph(object):
                                                # slot conflict).
                                                insignificant = True
 
+                                       if not insignificant:
+                                               # Evaluate USE conditionals and || deps, in order
+                                               # to see if this atom is really desirable, since
+                                               # otherwise we may trigger an undesirable rebuild
+                                               # as in bug #460304.
+                                               if selected_atoms is None:
+                                                       selected_atoms = self._select_atoms_probe(
+                                                               dep.child.root, replacement_parent)
+                                               if unevaluated_atom not in selected_atoms:
+                                                       continue
+
                                        if debug:
                                                msg = []
                                                msg.append("")
@@ -1393,6 +1407,18 @@ class depgraph(object):
 
                return available_pkg is not None
 
+       def _select_atoms_probe(self, root, pkg):
+               selected_atoms = []
+               use = self._pkg_use_enabled(pkg)
+               for k in pkg._dep_keys:
+                       v = pkg._metadata.get(k)
+                       if not v:
+                               continue
+                       selected_atoms.extend(self._select_atoms(
+                               root, v, myuse=use, parent=pkg)[pkg])
+               return frozenset(x.unevaluated_atom for
+                       x in selected_atoms)
+
        def _iter_similar_available(self, graph_pkg, atom):
                """
                Given a package that's in the graph, do a rough check to
index ca3662d6d828579fcc46bc4eaf2144959499dacc..7263504b859dd58088715c00e0923f7517882609 100644 (file)
@@ -290,7 +290,33 @@ class SlotAbiTestCase(TestCase):
                                ["@world"],
                                options = {"--update": True, "--deep": True},
                                success = True,
-                               mergelist = ["net-misc/networkmanager-0.9.6.4-r1"]),
+                               mergelist = []),
+
+               )
+
+               playground = ResolverPlayground(ebuilds=ebuilds,
+                       installed=installed, user_config=user_config, world=world,
+                       debug=False)
+               try:
+                       for test_case in test_cases:
+                               playground.run_TestCase(test_case)
+                               self.assertEqual(test_case.test_success, True, test_case.fail_msg)
+               finally:
+                       playground.cleanup()
+
+               user_config = {
+                       "make.conf" : ("USE=\"-wimax\"",)
+               }
+
+               test_cases = (
+
+                       # Demonstrate bug #460304 again, but with inverted USE
+                       # settings this time.
+                       ResolverPlaygroundTestCase(
+                               ["@world"],
+                               options = {"--update": True, "--deep": True},
+                               success = True,
+                               mergelist = ['dev-libs/libnl-3.2.14', 'net-misc/networkmanager-0.9.6.4-r1']),
 
                )