summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-11-29 20:24:05 +0000
committerZac Medico <zmedico@gentoo.org>2007-11-29 20:24:05 +0000
commit4f4287014f5742bd08b8c950d7cfdf2fd52ea921 (patch)
treee85dead2e3f2fb16fa6a271163edb448c517d6f8 /pym
parent7533586dcc2c0351da28da56b9e6a2a1b9ea004d (diff)
downloadportage-4f4287014f5742bd08b8c950d7cfdf2fd52ea921.tar.gz
portage-4f4287014f5742bd08b8c950d7cfdf2fd52ea921.tar.bz2
portage-4f4287014f5742bd08b8c950d7cfdf2fd52ea921.zip
Move environment.bz2 extraction from ebuild.sh to doebuild() on
the python side. The python will be able to use it's awareness of the ${T}/environment to decide what type of ebuild environment should be generated. For example, if the ebuild environment should be able to unset variables that have been inherited from the calling environment, the existence of ${T}/environment will indicate that the ebuild environment should be isolated from the calling environment. svn path=/main/trunk/; revision=8753
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/__init__.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 8970f476b..94ab57780 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -4302,6 +4302,42 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
if logfile and not os.access(os.path.dirname(logfile), os.W_OK):
logfile = None
if have_build_dirs:
+ env_file = os.path.join(mysettings["T"], "environment")
+ env_stat = None
+ saved_env = None
+ try:
+ env_stat = os.stat(env_file)
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+ if not env_stat:
+ saved_env = os.path.join(
+ os.path.dirname(myebuild), "environment.bz2")
+ if not os.path.isfile(saved_env):
+ saved_env = None
+ if saved_env:
+ retval = os.system(
+ "bzip2 -dc '%s' > '%s'" % (saved_env, env_file))
+ try:
+ env_stat = os.stat(env_file)
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+ if os.WIFEXITED(retval) and \
+ os.WEXITSTATUS(retval) == os.EX_OK and \
+ env_stat and env_stat.st_size > 0:
+ pass
+ else:
+ writemsg("!!! Error extracting saved environment: '%s'" % \
+ saved_env, noiselevel=-1)
+ try:
+ os.unlink(env_file)
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
_doebuild_exit_status_unlink(
mysettings.get("EBUILD_EXIT_STATUS_FILE"))
else: