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):
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:
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