For bug #150361, implement greedy matching of command line atoms against relevant...
authorZac Medico <zmedico@gentoo.org>
Sun, 8 Oct 2006 21:43:43 +0000 (21:43 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 8 Oct 2006 21:43:43 +0000 (21:43 -0000)
svn path=/main/trunk/; revision=4621

bin/emerge

index c60cd35bb06cc6ade84cd43b68739d5d8558881a..150b8732a8b5fefa16599f3f50e4c0c009d6d0e0 100755 (executable)
@@ -950,6 +950,38 @@ class depgraph:
                                        print
                                        sys.exit(1)
 
+               if "--update" in self.myopts:
+                       """Make sure all installed slots are updated when possible. Do this
+                       with --emptytree also, to ensure that all slots are remerged."""
+                       vardb = self.trees[self.target_root]["vartree"].dbapi
+                       greedy_atoms = []
+                       raw_greedy = []
+                       for i in xrange(len(self.args_keys)):
+                               myatom = self.args_keys[i]
+                               greedy_atoms.append(myatom)
+                               raw_greedy.append(raw_args[i])
+                               myslots = set()
+                               for cpv in vardb.match(myatom):
+                                       myslots.add(vardb.aux_get(cpv, ["SLOT"])[0])
+                               if len(myslots) > 1:
+                                       for myslot in myslots:
+                                               myslot_atom = "%s:%s" % \
+                                                       (portage.dep_getkey(myatom), myslot)
+                                               available = False
+                                               if "--usepkgonly" not in self.myopts and \
+                                                       self.trees[self.target_root][
+                                                       "porttree"].dbapi.match(myslot_atom):
+                                                       available = True
+                                               elif "--usepkg" in self.myopts and \
+                                                       self.trees[self.target_root][
+                                                       "bintree"].dbapi.match(myslot_atom):
+                                                       available = True
+                                               if available:
+                                                       greedy_atoms.append(myslot_atom)
+                                                       raw_greedy.append(raw_args[i])
+                       self.args_keys = greedy_atoms
+                       raw_args = raw_greedy
+
                for i in xrange(len(self.args_keys)):
                                mykey = self.args_keys[i]
                                try: