From 2d4458f5ff0855fe07603faf45c74d0b389ac47d Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 4 Jul 2018 05:13:51 -0400 Subject: sbodl: forgot to commit this 4 years ago --- sbodl | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/sbodl b/sbodl index 724733d..822593e 100755 --- a/sbodl +++ b/sbodl @@ -2,23 +2,32 @@ # sbodl, initial public release. +# 20170306 bkw: add caching + SELF=$( basename $0 ) +CACHEDIR=/home/urchlay/slackbuilds + usage() { cat < +Usage: $SELF [-f] Execute $SELF in the directory that contains the .info and .SlackBuild files. It will use wget to download the source file(s), then check their md5sums. -$SELF doesn't take any options itself (except --help), but any options -you pass to it will be passed to wget. +$SELF options: + +-h, --help: Show this help message. + +-f: Ignore locally cached files, always download. + +Any other options you pass to it will be passed to wget. EOF exit 0 } @@ -29,8 +38,9 @@ die() { } # check for our one argument -case "$*" in +case "$1" in -h|-help|-\?|--help) usage ;; + -f) FORCEDL="yes" ; shift ;; esac source ./$( basename $( pwd ) ).info \ @@ -39,7 +49,7 @@ 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=i486 ;; + i?86) ARCH=i586 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac @@ -70,8 +80,20 @@ for dl in $DL; do esac FILE=$( echo "$dl" | sed 's,.*/,,' ) + [ "$FORCEDL" = "yes" ] && rm -f "$FILE" - wget $WGETARGS $EXTRAWGETARGS "$dl" || die "Download failed" + if [ -e "$FILE" ]; then + # don't do anything + : + elif [ "$FORCEDL" != "yes" ] && [ -e "$CACHEDIR/$FILE" ]; then + ln -s "$CACHEDIR/$FILE" "$FILE" + else + wget $WGETARGS $EXTRAWGETARGS "$dl" || die "Download failed" + if [ -e "$FILE" ]; then + mv "$FILE" "$CACHEDIR" + ln -s "$CACHEDIR/$FILE" "$FILE" + fi + fi if [ -e "$FILE" ]; then GOTSUM="$( md5sum "$FILE" | cut -d' ' -f1 )" -- cgit v1.2.3