For bug #155559, force depclean dep_check calls to preference installed packages.
authorZac Medico <zmedico@gentoo.org>
Sat, 18 Nov 2006 13:28:36 +0000 (13:28 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 18 Nov 2006 13:28:36 +0000 (13:28 -0000)
svn path=/main/trunk/; revision=5085

bin/emerge

index cfa1b1995108af4cf711c73d7a5ee529e1123859..ae2c7a06ebb7ded2acc860b2d4b094a48607f82f 100755 (executable)
@@ -3887,6 +3887,19 @@ def action_depclean(settings, trees, ldpath_mtimes,
        unresolveable = {}
        aux_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
 
+       fake_vardb = portage.fakedbapi(settings=settings)
+       fakedb_auxkeys = aux_keys[:]
+       fakedb_auxkeys.append("SLOT")
+       for cpv in myvarlist:
+               try:
+                       # Prefer live ebuild metadata when available.
+                       aux_vals = portdb.aux_get(cpv, fakedb_auxkeys)
+               except KeyError:
+                       aux_vals = vardb.aux_get(cpv, fakedb_auxkeys)
+               fake_vardb.cpv_inject(cpv, metadata=dict(zip(fakedb_auxkeys, aux_vals)))
+       # HACK: Ensure that installed packages are preferenced by dep_check().
+       trees[settings["ROOT"]]["porttree"].dbapi = fake_vardb
+
        while remaining_atoms:
                atom, parent, priority = remaining_atoms.pop()
                pkgs = vardb.match(atom)
@@ -3920,6 +3933,9 @@ def action_depclean(settings, trees, ldpath_mtimes,
                                for atom in atoms:
                                        remaining_atoms.append((atom, pkg, priority))
 
+       # Restore the portdb back to normal (see fake_vardb above).
+       trees[settings["ROOT"]]["porttree"].dbapi = portdb
+
        if "--quiet" not in myopts:
                print "\b\b... done!\n"