diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-11-25 06:33:40 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-11-25 06:33:40 +0000 |
commit | 01a6bb2dc23ad83b074b495ef96d9e3c5bb4b35c (patch) | |
tree | 52e9a8efc396a96a7cfd60c9876e059776677e51 /pym | |
parent | 37169b5033f66181850e0681703b388b037e90a2 (diff) | |
download | portage-01a6bb2dc23ad83b074b495ef96d9e3c5bb4b35c.tar.gz portage-01a6bb2dc23ad83b074b495ef96d9e3c5bb4b35c.tar.bz2 portage-01a6bb2dc23ad83b074b495ef96d9e3c5bb4b35c.zip |
Implement loading of environment.bz2 for the pkg_info() phase.
Since a temporary directory is required for processing of
${T}/environment, and we want a user who's not in the portage
group to be able to run the pkg_info() phase, PORTAGE_TMPDIR
is temporarily overridden with a directory created by mkdtemp.
To make this work, doebuild() creates the tempdir and cleans
it up in a finally block. (trunk r8649)
svn path=/main/branches/2.1.2/; revision=8650
Diffstat (limited to 'pym')
-rw-r--r-- | pym/portage.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/pym/portage.py b/pym/portage.py index 3d5515148..f82074f74 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -3544,6 +3544,10 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m 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 @@ -3552,6 +3556,10 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m 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()) @@ -3997,12 +4005,24 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, 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) @@ -4094,13 +4114,15 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, # 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) @@ -4363,6 +4385,9 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, return retval finally: + if tmpdir: + mysettings["PORTAGE_TMPDIR"] = tmpdir_orig + shutil.rmtree(tmpdir) if builddir_lock: portage_locks.unlockdir(builddir_lock) |