raise portage.exception.IncorrectParameter(
"Invalid ebuild path: '%s'" % myebuild)
+ # Make a backup of PORTAGE_TMPDIR prior to calling config.reset()
+ # so that the caller can override it.
+ tmpdir = mysettings["PORTAGE_TMPDIR"]
+
if mydo != "depend":
"""For performance reasons, setcpv only triggers reset when it
detects a package-specific change in config. For the ebuild
mysettings.reset(use_cache=use_cache)
mysettings.setcpv(mycpv, use_cache=use_cache, mydb=mydbapi)
+ # config.reset() might have reverted a change made by the caller,
+ # so restore it to it's original value.
+ mysettings["PORTAGE_TMPDIR"] = tmpdir
+
mysettings["EBUILD_PHASE"] = mydo
mysettings["PORTAGE_MASTER_PID"] = str(os.getpid())
logfile=None
builddir_lock = None
+ tmpdir = None
+ tmpdir_orig = None
try:
if mydo in ("digest", "manifest", "help"):
# Temporarily exempt the depend phase from manifest checks, in case
# aux_get calls trigger cache generation.
_doebuild_manifest_exempt_depend += 1
+ # If we don't need much space and we don't need a constant location,
+ # we can temporarily override PORTAGE_TMPDIR with a random temp dir
+ # so that there's no need for locking and it can be used even if the
+ # user isn't in the portage group.
+ if mydo in ("info",):
+ from tempfile import mkdtemp
+ tmpdir = mkdtemp()
+ tmpdir_orig = mysettings["PORTAGE_TMPDIR"]
+ mysettings["PORTAGE_TMPDIR"] = tmpdir
+
doebuild_environment(myebuild, mydo, myroot, mysettings, debug,
use_cache, mydbapi)
# Build directory creation isn't required for any of these.
have_build_dirs = False
- if mydo not in ("digest", "fetch", "help", "info", "manifest"):
+ if mydo not in ("digest", "fetch", "help", "manifest"):
mystatus = prepare_build_dirs(myroot, mysettings, cleanup)
if mystatus:
return mystatus
have_build_dirs = True
# PORTAGE_LOG_FILE is set above by the prepare_build_dirs() call.
- logfile = mysettings.get("PORTAGE_LOG_FILE", None)
+ logfile = mysettings.get("PORTAGE_LOG_FILE")
+ if logfile and not os.access(os.path.dirname(logfile), os.W_OK):
+ logfile = None
if mydo == "unmerge":
return unmerge(mysettings["CATEGORY"],
mysettings["PF"], myroot, mysettings, vartree=vartree)
return retval
finally:
+ if tmpdir:
+ mysettings["PORTAGE_TMPDIR"] = tmpdir_orig
+ shutil.rmtree(tmpdir)
if builddir_lock:
portage.locks.unlockdir(builddir_lock)