From 48cf73ee9e248fa4073ff43b752fc5d81ad3426c Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 26 Jun 2023 23:00:56 -0400 Subject: sbodl: exit status now useful, color only on tty, add ?.cabal hint. --- sbodl | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'sbodl') diff --git a/sbodl b/sbodl index ddcfb91..33097a4 100755 --- a/sbodl +++ b/sbodl @@ -109,13 +109,21 @@ doesn't have a DOWNLOAD_aarch64 field (yet). =back +=head1 EXIT STATUS + +0 (success) if all files were downloaded or found in the cache, and their +md5sums all match the .info file. + +1 (failure) if any download failed, or if at least one md5sum failed to match. + =head1 BUGS One very rare but nasty one: all the cached files are stored in the same directory. If two SlackBuilds happen to have the same filename -for their downloads (but they're actually different files), you'll -get md5sum failues. At some point this will be fixed. For now, if this -happens, use the B<-f> option. +for their downloads (but they're actually different files), you'll get +md5sum failures. This is most noticeable with I builds, with +filenames like B<1.cabal>, B<2.cabal>, etc. At some point this will be +fixed. For now, if this happens, use the B<-f> option. Also, since --content-disposition is used, occasionally the downloaded filename won't match the filename in the URL, and B will warn @@ -143,10 +151,12 @@ CACHEDIR=${SBODL_CACHEDIR:-$DEFCACHEDIR} DEFARCHIVE=https://slackware.uk/sbosrcarch ARCHIVE=${SBODL_ARCHIVE:-$DEFARCHIVE} -RED="\033[1;31m" -GREEN="\033[1;32m" -COLOR_OFF="\033[0m" - +if [ -t 1 ]; then + RED="\033[1;31m" + GREEN="\033[1;32m" + YELLOW="\033[1;33m" + COLOR_OFF="\033[0m" +fi die() { echo "$SELF: $*" 2>&1 @@ -170,11 +180,11 @@ source ./$( basename $( pwd ) ).info \ # This stanza copied from the SBo template for 14.1: if [ -z "$ARCH" ]; then - case "$( uname -m )" in - i?86) ARCH=i586 ;; - arm*) ARCH=arm ;; - *) ARCH=$( uname -m ) ;; - esac + case "$( uname -m )" in + i?86) ARCH=i586 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac fi if [ "$ARCH" = "x86_64" ]; then @@ -189,9 +199,15 @@ if [ -z "$DL" ]; then die "Bad .info file (no DOWNLOAD= or DOWNLOAD_x86_64=)." fi +if [ "$DL" = "UNSUPPORTED" ]; then + die "$PRGNAM is unsupported on $ARCH" +fi + # save passed-in command line args for use with wget WGETARGS="$@" +EXIT=0 + set $SUM for dl in $DL; do @@ -236,11 +252,18 @@ for dl in $DL; do GOTSUM="$( md5sum "$FILE" | cut -d' ' -f1 )" if [ "$1" != "$GOTSUM" ]; then echo -e "${RED}WARN: md5sum doesn't match${COLOR_OFF}\\n expected: $1\\n got: $GOTSUM" + case "$FILE" in + ?.cabal) echo -e "${YELLOW}HINT:${COLOR_OFF} for ?.cabal files: if the md5sum fails, retry with '$SELF -f'." ;; + esac + EXIT=1 else echo -e "${GREEN}md5sum matches OK${COLOR_OFF}: $1" fi else echo -e "${RED}WARN${COLOR_OFF}: can't find downloaded file $FILE, try '$SELF -a'?" + EXIT=1 fi shift done + +exit $EXIT -- cgit v1.2.3