Add support for file paths as arguments to emerge. If an argument starts
authorZac Medico <zmedico@gentoo.org>
Fri, 22 Feb 2008 22:20:50 +0000 (22:20 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 22 Feb 2008 22:20:50 +0000 (22:20 -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.

svn path=/main/trunk/; revision=9367

pym/_emerge/__init__.py

index a1728cb58701b61f9b3b05b709dc42140c675b58..78da2f3298fb3951ffd92cf2a818a3f677104480 100644 (file)
@@ -1429,6 +1429,7 @@ class depgraph(object):
                self._reinstall_nodes = {}
                self.mydbapi = {}
                self.trees = {}
+               self._trees_orig = trees
                self.roots = {}
                # Contains a filtered view of preferred packages that are selected
                # from available repositories.
@@ -2123,6 +2124,35 @@ class depgraph(object):
                                        cpv=mykey, metadata=metadata, onlydeps=onlydeps)
                                args.append(PackageArg(arg=x, package=pkg,
                                        root_config=root_config))
+                       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)
+                               args.append(AtomArg(arg=atom, atom=atom,
+                                       root_config=root_config))
                        else:
                                if x in ("system", "world"):
                                        x = SETPREFIX + x