summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-09-27 01:38:27 +0000
committerZac Medico <zmedico@gentoo.org>2007-09-27 01:38:27 +0000
commitd15521239665a8d78c37664175b9eacd7d5bcf42 (patch)
tree65327eb7917c865917683cb801b92602dbb8be3c /bin
parent7dfbdc135804015692d5b417d294031271d2e470 (diff)
downloadportage-d15521239665a8d78c37664175b9eacd7d5bcf42.tar.gz
portage-d15521239665a8d78c37664175b9eacd7d5bcf42.tar.bz2
portage-d15521239665a8d78c37664175b9eacd7d5bcf42.zip
align the filename and line numbers in the output of the stack
dump so that it is much easier to read (trunk r7842) svn path=/main/branches/2.1.2/; revision=7843
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ebuild.sh44
1 files changed, 26 insertions, 18 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index c2b06b691..c85a49da7 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -284,23 +284,34 @@ register_die_hook() {
diefunc() {
local funcname="$1" lineno="$2" exitcode="$3"
shift 3
+
+ local n filespacing=0 linespacing=0
+ # setup spacing to make output easier to read
+ for ((n = ${#FUNCNAME[@]} - 1; n >= 0; --n)); do
+ sourcefile=${BASH_SOURCE[${n}]} sourcefile=${sourcefile##*/}
+ lineno=${BASH_LINENO[${n}]}
+ ((filespacing < ${#sourcefile})) && filespacing=${#sourcefile}
+ ((linespacing < ${#lineno})) && linespacing=${#lineno}
+ done
+
eerror
eerror "ERROR: $CATEGORY/$PF failed."
- dump_trace 2
- eerror " ${BASH_SOURCE[1]##*/}, line ${BASH_LINENO[0]}: Called die"
+ dump_trace 2 ${filespacing} ${linespacing}
+ eerror " $(printf "%${filespacing}s" "${BASH_SOURCE[1]##*/}"), line $(printf "%${linespacing}s" "${BASH_LINENO[0]}"): Called die"
+ eerror
+ eerror " ${*:-(no error message)}"
eerror
- eerror "${*:-(no error message)}"
eerror "If you need support, post the topmost build error, and the call stack if relevant."
- [ -n "${PORTAGE_LOG_FILE}" ] && \
- eerror "A complete build log is located at '${PORTAGE_LOG_FILE}'."
- if [ -n "${EBUILD_OVERLAY_ECLASSES}" ] ; then
+ [[ -n ${PORTAGE_LOG_FILE} ]] \
+ && eerror "A complete build log is located at '${PORTAGE_LOG_FILE}'."
+ if [[ -n ${EBUILD_OVERLAY_ECLASSES} ]] ; then
eerror "This ebuild used the following eclasses from overlays:"
local x
for x in ${EBUILD_OVERLAY_ECLASSES} ; do
eerror " ${x}"
done
fi
- if [ "${EBUILD#${PORTDIR}/}" == "${EBUILD}" ] ; then
+ if [[ "${EBUILD#${PORTDIR}/}" == "${EBUILD}" ]] ; then
local overlay=${EBUILD%/*}
overlay=${overlay%/*}
overlay=${overlay%/*}
@@ -308,7 +319,7 @@ diefunc() {
fi
eerror
- if [ "${EBUILD_PHASE/depend}" == "${EBUILD_PHASE}" ]; then
+ if [[ "${EBUILD_PHASE/depend}" == "${EBUILD_PHASE}" ]] ; then
local x
for x in $EBUILD_DEATH_HOOKS; do
${x} "$@" >&2 1>&2
@@ -322,19 +333,16 @@ diefunc() {
shopt -s extdebug &> /dev/null
-# usage- first arg is the number of funcs on the stack to ignore.
-# defaults to 1 (ignoring dump_trace)
+# dump_trace([number of funcs on stack to skip],
+# [whitespacing for filenames],
+# [whitespacing for line numbers])
dump_trace() {
local funcname="" sourcefile="" lineno="" n e s="yes"
+ declare -i strip=${1:-1}
+ local filespacing=$2 linespacing=$3
- declare -i strip=1
-
- if [[ -n $1 ]]; then
- strip=$(( $1 ))
- fi
-
eerror "Call stack:"
- for (( n = ${#FUNCNAME[@]} - 1, p = ${#BASH_ARGV[@]} ; n > $strip ; n-- )) ; do
+ for (( n = ${#FUNCNAME[@]} - 1, p = ${#BASH_ARGV[@]} ; n > ${strip} ; n-- )) ; do
funcname=${FUNCNAME[${n} - 1]}
sourcefile=$(basename ${BASH_SOURCE[${n}]})
lineno=${BASH_LINENO[${n} - 1]}
@@ -347,7 +355,7 @@ dump_trace() {
done
(( p -= ${BASH_ARGC[${n} - 1]} ))
fi
- eerror " ${sourcefile}, line ${lineno}: Called ${funcname}${args:+ ${args}}"
+ eerror " $(printf "%${filespacing}s" "${sourcefile}"), line $(printf "%${linespacing}s" "${lineno}"): Called ${funcname}${args:+ ${args}}"
done
}