Fix multislot handling for depclean (bug #382823)
authorZac Medico <zmedico@gentoo.org>
Thu, 15 Sep 2011 05:09:04 +0000 (22:09 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 15 Sep 2011 05:09:04 +0000 (22:09 -0700)
pym/_emerge/depgraph.py
pym/portage/tests/resolver/test_multislot.py

index 1e311e8f70f1f7ba568b9bccd53139b2f1e58ecc..f25a22deac3c18e9f0235db215092579ca4ab252 100644 (file)
@@ -3263,11 +3263,20 @@ class depgraph(object):
                # satisfied rather than forcing a rebuild.
                installed = pkg_type == 'installed'
                if installed and not cpv_list and atom.slot:
+
+                       if "remove" in self._dynamic_config.myparams:
+                               # We need to search the portdbapi, which is not in our
+                               # normal dbs list, in order to find the real SLOT.
+                               portdb = self._frozen_config.trees[root_config.root]["porttree"].dbapi
+                               db_keys = list(portdb._aux_cache_keys)
+                               dbs = [(portdb, "ebuild", False, False, db_keys)]
+                       else:
+                               dbs = self._dynamic_config._filtered_trees[root_config.root]["dbs"]
+
                        for cpv in db.match(atom.cp):
                                slot_available = False
                                for other_db, other_type, other_built, \
-                                       other_installed, other_keys in \
-                                       self._dynamic_config._filtered_trees[root_config.root]["dbs"]:
+                                       other_installed, other_keys in dbs:
                                        try:
                                                if atom.slot == \
                                                        other_db.aux_get(cpv, ["SLOT"])[0]:
@@ -4064,11 +4073,12 @@ class depgraph(object):
                """
                Select packages that are installed.
                """
-               vardb = self._dynamic_config._graph_trees[root]["vartree"].dbapi
-               matches = vardb.match_pkgs(atom)
+               matches = list(self._iter_match_pkgs(self._frozen_config.roots[root],
+                       "installed", atom))
                if not matches:
                        return None, None
                if len(matches) > 1:
+                       matches.reverse() # ascending order
                        unmasked = [pkg for pkg in matches if \
                                self._pkg_visibility_check(pkg)]
                        if unmasked:
index 8615419b5f644d27dc73fd74fa65f6e63213f86d..1331edf252537b4211191b180710ca4bc57a355c 100644 (file)
@@ -14,12 +14,18 @@ class MultSlotTestCase(TestCase):
 
                ebuilds = {
                        "sys-devel/gcc-4.4.4": { "SLOT": "4.4" },
+                       "dev-util/nvidia-cuda-toolkit-4.0" : { "RDEPEND": "sys-devel/gcc:4.4"},
                        }
 
                installed = {
                        "sys-devel/gcc-4.4.4": { "SLOT": "i686-pc-linux-gnu-4.4.4" },
+                       "dev-util/nvidia-cuda-toolkit-4.0" : { "RDEPEND": "sys-devel/gcc:4.4"},
                        }
 
+               world = (
+                       "dev-util/nvidia-cuda-toolkit",
+               )
+
                options = {'--update' : True, '--deep' : True, '--selective' : True}
 
                test_cases = (
@@ -28,9 +34,17 @@ class MultSlotTestCase(TestCase):
                                        options = options,
                                        mergelist = [],
                                        success = True),
+
+                               # depclean test for bug #382823
+                               ResolverPlaygroundTestCase(
+                                       [],
+                                       options = {"--depclean": True},
+                                       success = True,
+                                       cleanlist = []),
                        )
 
-               playground = ResolverPlayground(ebuilds=ebuilds, installed=installed)
+               playground = ResolverPlayground(ebuilds=ebuilds, installed=installed,
+                       world=world)
 
                try:
                        for test_case in test_cases: