preprocess_ebuild_env() {
filter_readonly_variables --filter-sandbox < "${T}"/environment \
> "${T}"/environment.filtered
- mv "${T}"/environment.filtered "${T}"/environment
+ if [ $? -ne 0 ] ; then
+ rm -f "${T}/environment.filtered"
+ return 1
+ fi
+ mv "${T}"/environment.filtered "${T}"/environment || return $?
+ rm -f "${T}/environment.success" || return $?
# WARNING: Code inside this subshell should avoid making assumptions
# about variables or functions after source "${T}"/environment has been
# called. Any variables that need to be relied upon should already be
# filtered out above.
(
- source "${T}"/environment
+ source "${T}/environment" && \
+ touch "${T}/environment.success"
# It's remotely possible that save_ebuild_env() has been overridden
# by the above source command. To protect ourselves, we override it
# Rely on save_ebuild_env() to filter out any remaining variables
# and functions that could interfere with the current environment.
save_ebuild_env
- ) | filter_readonly_variables > "${T}"/environment
+ ) | filter_readonly_variables > "${T}/environment.filtered"
+ if [ -e "${T}/environment.success" ] ; then
+ rm "${T}/environment.success"
+ mv "${T}/environment.filtered" "${T}/environment"
+ return $?
+ else
+ rm -f "${T}/environment.filtered"
+ fi
+ return 1
}
# === === === === === === === === === === === === === === === === === ===
[ ! -f "${T}/environment" ] ; then
bzip2 -dc "${EBUILD%/*}"/environment.bz2 > \
"${T}/environment" 2> /dev/null
- if [ -s "${T}/environment" ] ; then
- preprocess_ebuild_env
+ if [ $? -eq 0 ] && [ -s "${T}/environment" ] ; then
+ preprocess_ebuild_env || \
+ die "error processing '${EBUILD%/*}/environment.bz2'"
else
rm -f "${T}/environment"
fi
# environment may have been saved by a different version of ebuild.sh,
# so it can't trusted that it's been properly filtered. Therefore,
# always preprocess the environment when ${PN} == portage.
- preprocess_ebuild_env
+ preprocess_ebuild_env || \
+ die "error processing environment"
fi
# Colon separated SANDBOX_* variables need to be cumulative.
for x in SANDBOX_DENY SANDBOX_READ SANDBOX_PREDICT SANDBOX_WRITE ; do
eval PORTAGE_${x}=\${!x}
done
- source "${T}"/environment
+ source "${T}"/environment || \
+ die "error sourcing environment"
for x in SANDBOX_DENY SANDBOX_PREDICT SANDBOX_READ SANDBOX_WRITE ; do
eval y=\${PORTAGE_${x}}
if [ "${y}" != "${!x}" ] ; then