From: Zac Medico Date: Fri, 30 Nov 2007 11:05:59 +0000 (-0000) Subject: Bug #200775 - Save more portage generated environment X-Git-Tag: v2.2_pre1~265 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9415d6aeffb300d885713dc4d312afdeb26ba454;p=portage.git Bug #200775 - Save more portage generated environment variables that are in environment.bz2 so that they are available for use by tools such as epm. svn path=/main/trunk/; revision=8765 --- diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 78c423278..2a5a1a53d 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -984,7 +984,8 @@ dyn_install() { # the global environment though, in case the user wants to repeat # this phase (like with FEATURES=noauto and the ebuild command). unset S _E_DOCDESTTREE_ _E_EXEDESTTREE_ - save_ebuild_env | filter_readonly_variables --filter-sandbox > environment + save_ebuild_env | filter_readonly_variables \ + --filter-sandbox --allow-extra-vars > environment ) bzip2 -f9 environment @@ -1349,19 +1350,21 @@ READONLY_EBUILD_METADATA="DEPEND DESCRIPTION EAPI HOMEPAGE INHERITED IUSE KEYWORDS LICENSE PDEPEND PROVIDE RDEPEND RESTRICT SLOT SRC_URI" -READONLY_PORTAGE_VARS="A CATEGORY D EBUILD EBUILD_PHASE \ - EBUILD_SH_ARGS EMERGE_FROM FILESDIR P PF PN \ +READONLY_PORTAGE_VARS="D EBUILD EBUILD_PHASE \ + EBUILD_SH_ARGS EMERGE_FROM FILESDIR \ PORTAGE_BIN_PATH PORTAGE_PYM_PATH PORTAGE_MUTABLE_FILTERED_VARS \ - PORTAGE_TMPDIR PR PV PVR T WORKDIR" + PORTAGE_SAVED_READONLY_VARS PORTAGE_TMPDIR T WORKDIR" + +PORTAGE_SAVED_READONLY_VARS="A CATEGORY P PF PN PR PV PVR" # Variables that portage sets but doesn't mark readonly. # In order to prevent changed values from causing unexpected # interference, they are filtered out of the environment when # it is saved or loaded (any mutations do not persist). -PORTAGE_MUTABLE_FILTERED_VARS="AA" +PORTAGE_MUTABLE_FILTERED_VARS="AA HOSTNAME" # @FUNCTION: filter_readonly_variables -# @DESCRIPTION: [--filter-sandbox] +# @DESCRIPTION: [--filter-sandbox] [--allow-extra-vars] # Read an environment from stdin and echo to stdout while filtering readonly # variables. # @@ -1369,6 +1372,9 @@ PORTAGE_MUTABLE_FILTERED_VARS="AA" # is only desired in certain cases, such as during preprocessing or when # saving environment.bz2 for a binary or installed package. # +# ---allow-extra-vars causes some extra vars to be allowd through, such +# as ${PORTAGE_SAVED_READONLY_VARS} and ${PORTAGE_MUTABLE_FILTERED_VARS}. +# # In bash-3.2_p20+ an attempt to assign BASH_*, FUNCNAME, GROUPS or any # readonly variable cause the shell to exit while executing the "source" # builtin command. To avoid this problem, this function filters those @@ -1381,12 +1387,19 @@ filter_readonly_variables() { SANDBOX_DEBUG_LOG SANDBOX_DISABLED SANDBOX_LIB SANDBOX_LOG" filtered_vars="${readonly_bash_vars} ${READONLY_PORTAGE_VARS} - ${PORTAGE_MUTABLE_FILTERED_VARS} BASH_[_[:alnum:]]*" + BASH_[_[:alnum:]]*" if hasq --filter-sandbox $* ; then filtered_vars="${filtered_vars} SANDBOX_[_[:alnum:]]*" else filtered_vars="${filtered_vars} ${filtered_sandbox_vars}" fi + if ! hasq --allow-extra-vars $* ; then + filtered_vars=" + ${filtered_vars} + ${PORTAGE_SAVED_READONLY_VARS} + ${PORTAGE_MUTABLE_FILTERED_VARS} + " + fi set -f for x in ${filtered_vars} ; do var_grep="${var_grep}|${x}" diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 62824b2bc..43ad1c384 100755 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -391,7 +391,7 @@ save_ebuild_env() { ( # misc variables set by bash - unset BASH HOSTNAME HOSTTYPE IFS MACHTYPE OLDPWD \ + unset BASH HOSTTYPE IFS MACHTYPE OLDPWD \ OPTERR OPTIND OSTYPE PS4 PWD SHELL SHLVL # misc variables inherited from the calling environment