aboutsummaryrefslogtreecommitdiff
path: root/sbodl
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2015-04-07 18:11:06 -0400
committerB. Watson <yalhcru@gmail.com>2015-04-07 18:11:06 -0400
commit97a7e8464438e173a357ea9a272f91e26a789ac5 (patch)
treee85072e516e5d70f70dd43f98471db7b89290726 /sbodl
downloadsbostuff-97a7e8464438e173a357ea9a272f91e26a789ac5.tar.gz
initial commit
Diffstat (limited to 'sbodl')
-rwxr-xr-xsbodl88
1 files changed, 88 insertions, 0 deletions
diff --git a/sbodl b/sbodl
new file mode 100755
index 0000000..724733d
--- /dev/null
+++ b/sbodl
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+# sbodl, initial public release.
+
+SELF=$( basename $0 )
+
+usage() {
+ cat <<EOF
+$SELF - download the sources for a slackbuilds.org build.
+version 20140421, public release
+(c) 2014 B. Watson (yalhcru at gmail dawt cawm)
+Licensed under the WTFPL: Do WTF you want with this.
+
+Usage: $SELF <wget-options>
+
+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.
+EOF
+ exit 0
+}
+
+die() {
+ echo "$SELF: $*" 2>&1
+ exit 1
+}
+
+# check for our one argument
+case "$*" in
+ -h|-help|-\?|--help) usage ;;
+esac
+
+source ./$( basename $( pwd ) ).info \
+ || die "No .info file, are you sure this is a SBo directory? Try '$SELF --help'"
+
+# This stanza copied from the SBo template for 14.1:
+if [ -z "$ARCH" ]; then
+ case "$( uname -m )" in
+ i?86) ARCH=i486 ;;
+ arm*) ARCH=arm ;;
+ *) ARCH=$( uname -m ) ;;
+ esac
+fi
+
+if [ "$ARCH" = "x86_64" ]; then
+ DL=${DOWNLOAD_x86_64:-$DOWNLOAD}
+ SUM=${MD5SUM_x86_64:-$MD5SUM}
+else
+ DL=$DOWNLOAD
+ SUM=${MD5SUM}
+fi
+
+if [ -z "$DL" ]; then
+ die "Bad .info file (no DOWNLOAD= or DOWNLOAD_x86_64=)."
+fi
+
+# save passed-in command line args for use with wget
+WGETARGS="$@"
+
+set $SUM
+
+for dl in $DL; do
+ EXTRAWGETARGS="--content-disposition "
+ case "$dl" in
+ *sourceforge.net/*|*.sf.net/*) EXTRAWGETARGS="--user-agent wget" ;;
+ *) ;;
+ esac
+
+ FILE=$( echo "$dl" | sed 's,.*/,,' )
+
+ wget $WGETARGS $EXTRAWGETARGS "$dl" || die "Download failed"
+
+ if [ -e "$FILE" ]; then
+ GOTSUM="$( md5sum "$FILE" | cut -d' ' -f1 )"
+ if [ "$1" != "$GOTSUM" ]; then
+ echo "WARN: md5sum doesn't match, expected $1, got $GOTSUM"
+ else
+ echo "md5sum matches OK: $1"
+ fi
+ else
+ echo "WARN: can't find downloaded file $FILE"
+ fi
+ echo
+ shift
+done