For bug #48195, fall back to the installed packages when there are no other choices...
authorZac Medico <zmedico@gentoo.org>
Fri, 6 Oct 2006 10:26:54 +0000 (10:26 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 6 Oct 2006 10:26:54 +0000 (10:26 -0000)
svn path=/main/trunk/; revision=4605

bin/emerge

index 6192ca36c83029423ee428630f422e38a48b8889..b2322829a82f7bf16dd0bee8858ad4e5c5d6e978 100755 (executable)
@@ -678,6 +678,7 @@ class depgraph:
                                        "--getbinpkg" in self.myopts,
                                        "--getbinpkgonly" in self.myopts)
                self.args_keys = []
+               self.global_updates = {}
 
        def create(self, mybigkey, myparent=None, addme=1, myuse=None,
                priority=digraph.HARD, rev_dep=False, arg=None):
@@ -741,7 +742,9 @@ class depgraph:
                self.useFlags[myroot][mykey] = myuse
 
                merging=1
-               if addme:
+               if mytype == "installed":
+                       merging = 0
+               if addme and mytype != "installed":
                # this is where we add the node to the list of packages to merge
                        if "selective" in self.myparams or not arg:
                                if "empty" not in self.myparams and vardbapi.cpv_exists(mykey):
@@ -1154,6 +1157,42 @@ class depgraph:
                                        matched_packages.append(
                                                ["ebuild", myroot, myeb, None])
 
+                               if not matched_packages:
+                                       """Fall back to the installed package database.  This is a
+                                       last resort because the metadata tends to diverge from that
+                                       of the ebuild in the tree."""
+                                       myeb_inst = portage.best(vardb.match(x))
+                                       if myeb_inst:
+                                               binpkguseflags = vardb.aux_get(
+                                                       myeb_inst, ["USE"])[0].split()
+                                               matched_packages.append(
+                                                       ["installed", myroot, myeb_inst, binpkguseflags])
+                                               """Now make sure that *DEPEND atoms are up to date.
+                                               This is done on the fly for single packages only when
+                                               necessary, since it can be time consuming to run this
+                                               on all installed packages."""
+                                               from portage_update import grab_updates, \
+                                                       parse_updates, update_dbentries
+                                               if myroot not in self.global_updates:
+                                                       updpath = os.path.join(
+                                                               pkgsettings["PORTDIR"], "profiles", "updates")
+                                                       try:
+                                                               rawupdates = grab_updates(updpath)
+                                                       except portage_exception.DirectoryNotFound:
+                                                               rawupdates = []
+                                                       upd_commands = []
+                                                       for mykey, mystat, mycontent in rawupdates:
+                                                               commands, errors = parse_updates(mycontent)
+                                                               upd_commands.extend(commands)
+                                                       self.global_updates[myroot] = upd_commands
+                                               upd_commands = self.global_updates[myroot]
+                                               aux_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
+                                               aux_vals = vardb.aux_get(myeb_inst, aux_keys)
+                                               aux_dict = dict(zip(aux_keys, aux_vals))
+                                               updates = update_dbentries(upd_commands, aux_dict)
+                                               if updates:
+                                                       vardb.aux_update(myeb_inst, updates)
+
                                if not matched_packages:
                                        if raise_on_missing:
                                                raise ValueError