From bbcdeab57b3e51542fe947fbfc19af53e42606d5 Mon Sep 17 00:00:00 2001 From: Pierre Labastie Date: Wed, 30 Oct 2013 15:44:46 +0000 Subject: [PATCH] Handle errors while installing blfs tools and makes the error message more accurate --- BLFS/xsl/scripts.xsl | 13 ++++++++++++- common/libs/func_install_blfs | 2 +- jhalfs | 13 +++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/BLFS/xsl/scripts.xsl b/BLFS/xsl/scripts.xsl index 263948b..cf25a4b 100644 --- a/BLFS/xsl/scripts.xsl +++ b/BLFS/xsl/scripts.xsl @@ -433,7 +433,18 @@ pushd $SRC_DIR/blfs-bootscripts URL= BOOTPACKG=$(basename $URL) -[[ ! -f "$BOOTPACKG" ]] && { wget -T 30 -t 5 $URL; rm -f unpacked; } +if [[ ! -f $BOOTPACKG ]] ; then + if [[ -f $SRC_ARCHIVE/$PKG_DIR/$BOOTPACKG ]] ; then + cp $SRC_ARCHIVE/$PKG_DIR/$BOOTPACKG $BOOTPACKG + elif [[ -f $SRC_ARCHIVE/$BOOTPACKG ]] ; then + cp $SRC_ARCHIVE/$BOOTPACKG $BOOTPACKG + else + wget -T 30 -t 5 $URL + cp $BOOTPACKG $SRC_ARCHIVE + fi + rm -f unpacked +fi + if [[ -e unpacked ]] ; then UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'` if ! [[ -d $UNPACKDIR ]]; then diff --git a/common/libs/func_install_blfs b/common/libs/func_install_blfs index 15a73d4..3f34915 100644 --- a/common/libs/func_install_blfs +++ b/common/libs/func_install_blfs @@ -122,7 +122,7 @@ echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script sed -n -e '/PACKAGE=/,/md5sum/p' \ -e '/PACKAGE1=/,/^fi/p' \ -e '/PATCH=/,/^fi/p' \ - -e '/URL=/,/unpacked/p' \ + -e '/URL=/,/^fi/p' \ $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script chmod u+x $BUILDDIR$BLFS_ROOT/download_script diff --git a/jhalfs b/jhalfs index 8ebade0..bee1145 100755 --- a/jhalfs +++ b/jhalfs @@ -1,6 +1,8 @@ #!/bin/bash # $Id$ set -e +# Pass trap handlers to functions +set -E # VT100 colors declare -r BLACK=$'\e[1;30m' @@ -37,8 +39,14 @@ simple_error() { # Basic error trap.... JUST DIE #-----------------------# # If +e then disable text output if [[ "$-" =~ e ]]; then - echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2 + LASTLINE="$1" + LASTERR="$2" + LASTFUNC="$3" + LASTSOURCE="$4" +# echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2 + echo -e "\n${RED}ERROR:${GREEN} Error $LASTERR at $LASTSOURCE line ${LASTLINE}!${OFF}\n" >&2 fi + exit $LASTERR } see_ya() { @@ -57,7 +65,7 @@ see_ya() { ##### set -e trap see_ya 0 -trap simple_error ERR +trap 'simple_error "${LINENO}" "$?" "${FUNCNAME}" "${BASH_SOURCE}"' ERR trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23 #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> @@ -374,6 +382,7 @@ if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then echo Downloading and validating the BLFS book echo '(may take some time...)' install_blfs_tools 2>&1 | tee -a $LOGDIR/$LOG + [[ ${PIPESTATUS[0]} != 0 ]] && exit 1 fi #