Check if ebuild path is in vdb and check that vdb finds it okay rather than always...
authorJason Stubbs <jstubbs@gentoo.org>
Sat, 15 Oct 2005 12:51:29 +0000 (12:51 -0000)
committerJason Stubbs <jstubbs@gentoo.org>
Sat, 15 Oct 2005 12:51:29 +0000 (12:51 -0000)
If PORTDIR_OVERLAY needs to be adjusted, recheck to make sure the ebuild is found correctly.
Pass which tree should be used to doebuild so that aux_get() are performed on the correct tree.

svn path=/main/branches/2.0/; revision=2135

bin/ebuild

index 559d4af3480808a8574eefc4ab0c027d4b04ae24..c79068ff0a8969e102fc771eb3a7419801f348bd 100755 (executable)
@@ -21,10 +21,8 @@ if "merge" in pargs:
 os.environ["PORTAGE_CALLER"]="ebuild"
 sys.path = ["/usr/lib/portage/pym"]+sys.path
 
-import portage, portage_util
+import portage, portage_util, portage_const
 
-
-root = os.path.normpath(os.environ.get("ROOT", "") + "/")
 ebuild = os.path.realpath(pargs.pop(0))
 
 if not os.path.exists(ebuild):
@@ -35,12 +33,31 @@ ebuild_split = ebuild.split("/")
 del ebuild_split[-2]
 cpv = "/".join(ebuild_split[-2:])[:-7]
 
-portage_ebuild = portage.portdb.findname(cpv)
+if ebuild.startswith(portage.root + portage_const.VDB_PATH):
+       mytree = "vartree"
+
+       portage_ebuild = portage.db[portage.root][mytree].dbapi.findname(cpv)
+
+       if os.path.realpath(portage_ebuild) != ebuild:
+               print "!!! Portage seems to think that %s is at %s" % (cpv, portage_ebuild)
+               sys.exit(1)
+
+else:
+       mytree = "porttree"
+
+       portage_ebuild = portage.portdb.findname(cpv)
+
+       if not portage_ebuild or os.path.realpath(portage_ebuild) != ebuild:
+               overlay = "/".join(ebuild_split[:-2])
+               os.environ["PORTDIR_OVERLAY"] = os.environ.get("PORTDIR_OVERLAY","") + " " + overlay
+               print "Appending %s to PORTDIR_OVERLAY..." % overlay
+
+               reload(portage)
+               portage_ebuild = portage.portdb.findname(cpv)
 
-if not portage_ebuild or os.path.realpath(portage_ebuild) != ebuild:
-       os.environ["PORTDIR_OVERLAY"] = "/".join(ebuild_split[:-2])
-       print "Adjusting PORTDIR_OVERLAY to '%s'..." % os.environ["PORTDIR_OVERLAY"]
-       reload(portage)
+               if not portage_ebuild or portageos.path.realpath(portage_ebuild) != ebuild:
+                       print "!!! %s does not seem to have a valid PORTDIR structure." % overlay
+                       sys.exit(1)
 
 
 if len(pargs) > 1 and "config" in pargs:
@@ -51,7 +68,7 @@ if len(pargs) > 1 and "config" in pargs:
 for arg in pargs:
        try:
                tmpsettings = portage.config(clone=portage.settings)
-               a = portage.doebuild(ebuild, arg, root, tmpsettings, debug=debug, cleanup=("noauto" not in portage.features))
+               a = portage.doebuild(ebuild, arg, portage.root, tmpsettings, debug=debug, cleanup=("noauto" not in portage.features), tree=mytree)
        except KeyboardInterrupt:
                print "Interrupted."
                a = 1