calc_depclean: use runtime_slot_op priorities
authorZac Medico <zmedico@gentoo.org>
Sun, 7 Jul 2013 19:10:34 +0000 (12:10 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 7 Jul 2013 19:14:54 +0000 (12:14 -0700)
pym/_emerge/UnmergeDepPriority.py
pym/_emerge/actions.py
pym/portage/tests/resolver/test_depclean_order.py [new file with mode: 0644]

index 0457ea904e285862e10412dcb90348975652e1c6..ec44a67a17e718d1cf04d13bad8929e0f1d10ad6 100644 (file)
@@ -37,6 +37,8 @@ class UnmergeDepPriority(AbstractDepPriority):
        def __str__(self):
                if self.ignored:
                        return "ignored"
+               if self.runtime_slot_op:
+                       return "hard slot op"
                myvalue = self.__int__()
                if myvalue > self.SOFT:
                        return "hard"
index 034613e9f0f3741307d22bb3b20654cd6ecc6a62..730868e72450b8d974a837b06cf82097bbb6cc84 100644 (file)
@@ -1147,7 +1147,8 @@ def calc_depclean(settings, trees, ldpath_mtimes,
                                                "installed", root_config, installed=True)
                                        if not resolver._add_pkg(pkg,
                                                Dependency(parent=consumer_pkg,
-                                               priority=UnmergeDepPriority(runtime=True),
+                                               priority=UnmergeDepPriority(runtime=True,
+                                                       runtime_slot_op=True),
                                                root=pkg.root)):
                                                resolver.display_problems()
                                                return 1, [], False, 0
@@ -1235,7 +1236,15 @@ def calc_depclean(settings, trees, ldpath_mtimes,
                                                continue
                                        for child_node in matches:
                                                if child_node in clean_set:
-                                                       graph.add(child_node, node, priority=priority)
+
+                                                       mypriority = priority.copy()
+                                                       if atom.slot_operator_built:
+                                                               if mypriority.buildtime:
+                                                                       mypriority.buildtime_slot_op = True
+                                                               if mypriority.runtime:
+                                                                       mypriority.runtime_slot_op = True
+
+                                                       graph.add(child_node, node, priority=mypriority)
 
                if debug:
                        writemsg_level("\nunmerge digraph:\n\n",
diff --git a/pym/portage/tests/resolver/test_depclean_order.py b/pym/portage/tests/resolver/test_depclean_order.py
new file mode 100644 (file)
index 0000000..9511d29
--- /dev/null
@@ -0,0 +1,57 @@
+# Copyright 2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+from portage.tests.resolver.ResolverPlayground import ResolverPlayground, ResolverPlaygroundTestCase
+
+class SimpleDepcleanTestCase(TestCase):
+
+       def testSimpleDepclean(self):
+
+               ebuilds = {
+                       "dev-libs/A-1": {
+                               "EAPI": "5",
+                               "RDEPEND": "dev-libs/B:=",
+                       },
+                       "dev-libs/B-1": {
+                               "EAPI": "5",
+                               "RDEPEND": "dev-libs/A",
+                       },
+                       "dev-libs/C-1": {},
+               }
+
+               installed = {
+                       "dev-libs/A-1": {
+                               "EAPI": "5",
+                               "RDEPEND": "dev-libs/B:0/0=",
+                       },
+                       "dev-libs/B-1": {
+                               "EAPI": "5",
+                               "RDEPEND": "dev-libs/A",
+                       },
+                       "dev-libs/C-1": {},
+               }
+
+               world = (
+                       "dev-libs/C",
+               )
+
+               test_cases = (
+                       # Remove dev-libs/A-1 first because of dev-libs/B:0/0= (built
+                       # slot-operator dep).
+                       ResolverPlaygroundTestCase(
+                               [],
+                               options={"--depclean": True},
+                               success=True,
+                               ordered=True,
+                               cleanlist=["dev-libs/A-1", "dev-libs/B-1"]),
+                       )
+
+               playground = ResolverPlayground(ebuilds=ebuilds,
+                       installed=installed, world=world)
+               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()