From 4f4287014f5742bd08b8c950d7cfdf2fd52ea921 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 29 Nov 2007 20:24:05 +0000 Subject: 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 --- pym/portage/__init__.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'pym') 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: -- cgit v1.2.3-1-g7c22