Bug #200775 - Save more portage generated environment
authorZac Medico <zmedico@gentoo.org>
Fri, 30 Nov 2007 11:08:19 +0000 (11:08 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 30 Nov 2007 11:08:19 +0000 (11:08 -0000)
variables that are in environment.bz2 so that they are
available for use by tools such as epm. (trunk r8765)

svn path=/main/branches/2.1.2/; revision=8766

bin/ebuild.sh
bin/isolated-functions.sh

index 78c423278690748edb872d1e84943b9113f70e98..2a5a1a53dab02c95f889ce75da486545c9179d39 100755 (executable)
@@ -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}"
index 62824b2bc11e252d332d01fbb70de203d3144f21..43ad1c384d600e4ea2b1dc16c42f747c6f688bdb 100644 (file)
@@ -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