diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-11-26 23:59:01 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-11-26 23:59:01 +0000 |
commit | 87e6983478c4f6f6b09192108ab58ad47a5531a7 (patch) | |
tree | 0f2c966639e93f01facece175bc13177db64036e | |
parent | 54d95fda4ac3e2b5137cfcca4b0b76029206e1f5 (diff) | |
download | portage-87e6983478c4f6f6b09192108ab58ad47a5531a7.tar.gz portage-87e6983478c4f6f6b09192108ab58ad47a5531a7.tar.bz2 portage-87e6983478c4f6f6b09192108ab58ad47a5531a7.zip |
Make the environment handling code detect errors and die if
necessary. (trunk r8700)
svn path=/main/branches/2.1.2/; revision=8701
-rwxr-xr-x | bin/ebuild.sh | 31 |
1 files 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 |