From cafccdb0da311f40d08541e3d3ad5945cf36ec3d Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 26 Nov 2007 23:57:11 +0000 Subject: [PATCH] Make the environment handling code detect errors and die if necessary. svn path=/main/trunk/; revision=8700 --- bin/ebuild.sh | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 9c4436697..8772219c6 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1399,13 +1399,19 @@ filter_readonly_variables() { 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 @@ -1416,7 +1422,15 @@ preprocess_ebuild_env() { # 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 } # === === === === === === === === === === === === === === === === === === @@ -1529,8 +1543,9 @@ if ! hasq ${EBUILD_SH_ARGS} clean depend && \ [ ! -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 @@ -1544,13 +1559,15 @@ elif ! hasq ${EBUILD_PHASE} depend && [ -f "${T}"/environment ] ; then # 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 -- 2.26.2