Handle errors while installing blfs tools and makes the error

message more accurate
This commit is contained in:
Pierre Labastie 2013-10-30 15:44:46 +00:00
parent b81c951193
commit bbcdeab57b
3 changed files with 24 additions and 4 deletions

View file

@ -433,7 +433,18 @@ pushd $SRC_DIR/blfs-bootscripts
URL=</xsl:text>
<xsl:value-of select="id('bootscripts')//itemizedlist//ulink/@url"/><xsl:text>
BOOTPACKG=$(basename $URL)
[[ ! -f "$BOOTPACKG" ]] &amp;&amp; { 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

View file

@ -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

13
jhalfs
View file

@ -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
#