From 72aba76bde1fe1e79c35d0c80c79ac16a1db0639 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 6 Dec 2009 11:03:54 +0000 Subject: Bug #295715 - Implement a register_success_hook function to complement register_die_hook, and also add code to ensure the die hooks are called even when the failure is on the python side (like for file collisions). (trunk r14936) svn path=/main/branches/2.1.7/; revision=14950 --- bin/ebuild.sh | 11 ++++++++++- bin/isolated-functions.sh | 1 + bin/misc-functions.sh | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 6a32aa0ce..c4b9c7b0b 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -273,6 +273,14 @@ register_die_hook() { done } +register_success_hook() { + local x + for x in $* ; do + hasq $x $EBUILD_SUCCESS_HOOKS || \ + export EBUILD_SUCCESS_HOOKS="$EBUILD_SUCCESS_HOOKS $x" + done +} + # Ensure that $PWD is sane whenever possible, to protect against # exploitation of insecure search path for python -c in ebuilds. # See bug #239560. @@ -747,7 +755,8 @@ dyn_clean() { if [[ $EMERGE_FROM = binary ]] || ! hasq keepwork $FEATURES; then rm -f "$PORTAGE_BUILDDIR"/.{ebuild_changed,exit_status,logid,unpacked,prepared} \ - "$PORTAGE_BUILDDIR"/.{configured,compiled,tested,packaged} + "$PORTAGE_BUILDDIR"/.{configured,compiled,tested,packaged} \ + "$PORTAGE_BUILDDIR"/.die_hooks rm -rf "${PORTAGE_BUILDDIR}/build-info" rm -rf "${WORKDIR}" diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 4d3c6960e..9741419b6 100755 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -156,6 +156,7 @@ die() { for x in $EBUILD_DEATH_HOOKS; do ${x} "$@" >&2 1>&2 done + > "$PORTAGE_BUILDDIR/.die_hooks" fi [[ -n ${PORTAGE_LOG_FILE} ]] \ diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index ef8b0a54a..87aaeff5a 100755 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -781,6 +781,22 @@ dyn_rpm() { die "Failed to move rpm" } +die_hooks() { + [[ -f $PORTAGE_BUILDDIR/.die_hooks ]] && return + local x + for x in $EBUILD_DEATH_HOOKS ; do + $x >&2 + done + > "$PORTAGE_BUILDDIR/.die_hooks" +} + +success_hooks() { + local x + for x in $EBUILD_SUCCESS_HOOKS ; do + $x + done +} + if [ -n "${MISC_FUNCTIONS_ARGS}" ]; then source_all_bashrcs [ "$PORTAGE_DEBUG" == "1" ] && set -x -- cgit v1.2.3-1-g7c22