aboutsummaryrefslogtreecommitdiff
path: root/sbodl
diff options
context:
space:
mode:
Diffstat (limited to 'sbodl')
-rwxr-xr-xsbodl36
1 files 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 <<EOF
$SELF - download the sources for a slackbuilds.org build.
-version 20140421, public release
+version 20170306, public release, with cachedir
(c) 2014 B. Watson (yalhcru at gmail dawt cawm)
Licensed under the WTFPL: Do WTF you want with this.
-Usage: $SELF <wget-options>
+Usage: $SELF <wget-options> [-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 )"