move die into isolated-functions.sh
authorAlec Warner <antarus@gentoo.org>
Wed, 7 Feb 2007 20:33:45 +0000 (20:33 -0000)
committerAlec Warner <antarus@gentoo.org>
Wed, 7 Feb 2007 20:33:45 +0000 (20:33 -0000)
svn path=/main/trunk/; revision=5910

bin/ebuild.sh
bin/isolated-functions.sh

index d943a64a11848a2ebd93e762ca4326cbf6d81c6e..db8193ae29dd9c5a939adb8e2b6f10acd23f6453 100755 (executable)
@@ -64,22 +64,14 @@ unalias -a
 # Unset some variables that break things.
 unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE
 
-# We need this next line for "die" and "assert". It expands
-# It _must_ preceed all the calls to die and assert.
-shopt -s expand_aliases
-alias die='diefunc "$FUNCNAME" "$LINENO" "$?"'
-alias assert='_pipestatus="${PIPESTATUS[*]}"; [[ "${_pipestatus// /}" -eq 0 ]] || diefunc "$FUNCNAME" "$LINENO" "$_pipestatus"'
-alias save_IFS='[ "${IFS:-unset}" != "unset" ] && old_IFS="${IFS}"'
-alias restore_IFS='if [ "${old_IFS:-unset}" != "unset" ]; then IFS="${old_IFS}"; unset old_IFS; else unset IFS; fi'
-
-OCC="$CC"
-OCXX="$CXX"
-
 export PATH="/usr/local/sbin:/sbin:/usr/sbin:${PORTAGE_BIN_PATH}:/usr/local/bin:/bin:/usr/bin:${ROOTPATH}"
 [ ! -z "$PREROOTPATH" ] && export PATH="${PREROOTPATH%%:}:$PATH"
 
 source "${PORTAGE_BIN_PATH}/isolated-functions.sh"  &>/dev/null
 
+OCC="$CC"
+OCXX="$CXX"
+
 [[ $PORTAGE_QUIET != "" ]] && export PORTAGE_QUIET
 
 # the sandbox is disabled by default except when overridden in the relevant stages
index 5aa838ba95f3338d9969b5386478c2417a8618c4..c5c2f4824d57ed8cc2b7d35260c2ecbb56144c47 100755 (executable)
@@ -1,6 +1,47 @@
 # Copyright 1999-2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header$
+# $Id$
+
+# We need this next line for "die" and "assert". It expands
+# It _must_ preceed all the calls to die and assert.
+shopt -s expand_aliases
+alias die='diefunc "$FUNCNAME" "$LINENO" "$?"'
+alias assert='_pipestatus="${PIPESTATUS[*]}"; [[ "${_pipestatus// /}" -eq 0 ]] || diefunc "$FUNCNAME" "$LINENO" "$_pipestatus"'
+alias save_IFS='[ "${IFS:-unset}" != "unset" ] && old_IFS="${IFS}"'
+alias restore_IFS='if [ "${old_IFS:-unset}" != "unset" ]; then IFS="${old_IFS}"; unset old_IFS; else unset IFS; fi'
+
+diefunc() {
+        local funcname="$1" lineno="$2" exitcode="$3"
+        shift 3
+        echo >&2
+        echo "!!! ERROR: $CATEGORY/$PF failed." >&2
+        dump_trace 2 1>&2
+        echo "  $(basename "${BASH_SOURCE[1]}"), line ${BASH_LINENO[0]}:   Called die" 1>&2
+        echo >&2
+        echo "!!! ${*:-(no error message)}" >&2
+        echo "!!! If you need support, post the topmost build error, and the call stack if relevant." >&2
+        echo "!!! A complete build log is located at '${PORTAGE_LOG_FILE}'." >&2
+        echo >&2
+        if [ -n "${EBUILD_OVERLAY_ECLASSES}" ] ; then
+                echo "This ebuild used the following eclasses from overlays:" >&2
+                echo >&2
+                for x in ${EBUILD_OVERLAY_ECLASSES} ; do
+                        echo "  ${x}" >&2
+                done
+                echo >&2
+        fi
+
+        if [ "${EBUILD_PHASE/depend}" == "${EBUILD_PHASE}" ]; then
+                local x
+                for x in $EBUILD_DEATH_HOOKS; do
+                        ${x} "$@" >&2 1>&2
+                done
+        fi
+
+        # subshell die support
+        kill -s SIGTERM ${EBUILD_MASTER_PID}
+        exit 1
+}
 
 quiet_mode() {
        [[ ${PORTAGE_QUIET} -eq 1 ]]