Add support for file paths as arguments to emerge. If an argument starts
authorZac Medico <zmedico@gentoo.org>
Fri, 28 Mar 2008 09:43:03 +0000 (09:43 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 28 Mar 2008 09:43:03 +0000 (09:43 -0000)
with / and it's not recognized as a tbz2 or ebuild then we try to find
and owner in the vdb and generate a slot atom from it. Thanks to solar
for the suggestion. (trunk r9367)

svn path=/main/branches/2.1.2/; revision=9535

bin/emerge

index 2bdfbc61e25d9c2eb96921b50c64f5c5434d82a7..a7c843b951fb933f6b70d012ecf813a02764838f 100755 (executable)
@@ -1469,6 +1469,7 @@ class depgraph:
                self._reinstall_nodes = {}
                self.mydbapi = {}
                self.trees = {}
+               self._trees_orig = trees
                self.roots = {}
                for myroot in trees:
                        self.trees[myroot] = {}
@@ -2010,6 +2011,34 @@ class depgraph:
                                        None, "--onlydeps" not in self.myopts, arg=x):
                                        return (0,myfavorites)
                                arg_atoms.append((x, "="+mykey))
+                       elif x.startswith(os.path.sep):
+                               if not x.startswith(myroot):
+                                       portage.writemsg(("\n\n!!! '%s' does not start with" + \
+                                               " $ROOT.\n") % x, noiselevel=-1)
+                                       return 0, []
+                               relative_path = x[len(myroot):]
+                               vartree = self._trees_orig[myroot]["vartree"]
+                               owner_cpv = None
+                               for cpv in vardb.cpv_all():
+                                       self.spinner.update()
+                                       cat, pf = portage.catsplit(cpv)
+                                       if portage.dblink(cat, pf, myroot,
+                                               pkgsettings, vartree=vartree).isowner(
+                                               relative_path, myroot):
+                                               owner_cpv = cpv
+                                               break
+                               if owner_cpv is None:
+                                       portage.writemsg(("\n\n!!! '%s' is not claimed " + \
+                                               "by any package.\n") % x, noiselevel=-1)
+                                       return 0, []
+                               slot = vardb.aux_get(owner_cpv, ["SLOT"])[0]
+                               if not slot:
+                                       # portage now masks packages with missing slot, but it's
+                                       # possible that one was installed by an older version
+                                       atom = portage.cpv_getkey(owner_cpv)
+                               else:
+                                       atom = "%s:%s" % (portage.cpv_getkey(owner_cpv), slot)
+                               arg_atoms.append((x, atom))
                        else:
                                if not is_valid_package_atom(x):
                                        portage.writemsg("\n\n!!! '%s' is not a valid package atom.\n" % x,