aboutsummaryrefslogtreecommitdiff
path: root/sbodl
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2018-07-04 05:13:51 -0400
committerB. Watson <yalhcru@gmail.com>2018-07-04 05:13:51 -0400
commit2d4458f5ff0855fe07603faf45c74d0b389ac47d (patch)
tree07e34ae185040460ee76da1f9baefff853bda903 /sbodl
parentc88a88a42d91d2744208c69ac9261dad159cbe54 (diff)
downloadsbostuff-2d4458f5ff0855fe07603faf45c74d0b389ac47d.tar.gz
sbodl: forgot to commit this 4 years ago
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 )"