summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbo-getsrc/README.md12
-rwxr-xr-xsbo-getsrc/sbo-getsrc51
2 files changed, 63 insertions, 0 deletions
diff --git a/sbo-getsrc/README.md b/sbo-getsrc/README.md
new file mode 100644
index 0000000..bdaa299
--- /dev/null
+++ b/sbo-getsrc/README.md
@@ -0,0 +1,12 @@
+sbo-getsrc
+==========
+
+Get source archives and verify checksums from slackbuilds.org info file.
+
+Usage
+-----
+
+```
+$ cd path/to/slackbuild/directory
+$ sbo-getsrc
+```
diff --git a/sbo-getsrc/sbo-getsrc b/sbo-getsrc/sbo-getsrc
new file mode 100755
index 0000000..8e7d37c
--- /dev/null
+++ b/sbo-getsrc/sbo-getsrc
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+INFO=$(basename $(pwd)).info
+
+if [ ! -e "$INFO" ]; then
+ echo "$INFO not found."
+ exit 1
+fi
+
+( . $INFO || exit 1
+ if [ "$(arch)" == "x86_64" ]; then
+ if [ -n "$DOWNLOAD_x86_64" ]; then
+ DOWNLOAD="$DOWNLOAD_x86_64"
+ fi
+
+ if [ -n "$MD5SUM_x86_64" ]; then
+ MD5SUM="$MD5SUM_x86_64"
+ fi
+ fi
+
+ DOWNS=()
+ FILENUM=0
+ for d in $DOWNLOAD; do
+ DOWNS+=("$(basename $d)")
+ FILENUM=$(($FILENUM + 1))
+
+ if [ ! -e "$(basename $d)" ]; then
+ echo "Downloading $d"
+ wget -q $d
+ else
+ echo "$d is already downloaded."
+ fi
+ done
+
+ SUMS=()
+ SUMNUM=0
+ for m in $MD5SUM; do
+ SUMS+=("$m")
+ SUMNUM=$(($SUMNUM + 1))
+ done
+
+ if [ "$FILENUM" -ne "$SUMNUM" ]; then
+ echo "The number of items (file and checksum) do not match."
+ echo "Cannot verify checksum."
+ exit 2
+ fi
+
+ for i in $(seq 0 $(($FILENUM - 1))); do
+ echo ${SUMS[$i]} ${DOWNS[$i]}
+ done | md5sum -c
+)