# 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
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.
#
# 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
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}"