aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2015-09-16 04:32:08 -0400
committerB. Watson <yalhcru@gmail.com>2015-09-16 04:32:08 -0400
commit0921145df66a513eedf306eec979b89bd8d003b1 (patch)
tree846d9cb4cee8f8714205ee6106fee14771ef3102
parentc1f243467dbfb839f58541287dfd8e94f9e09d9a (diff)
downloadsbostuff-0921145df66a513eedf306eec979b89bd8d003b1.tar.gz
sbofindsrc: add a couple more repos, rewrite usage a bit
-rwxr-xr-xsbofindsrc39
1 files changed, 31 insertions, 8 deletions
diff --git a/sbofindsrc b/sbofindsrc
index 9478314..e5682db 100755
--- a/sbofindsrc
+++ b/sbofindsrc
@@ -7,7 +7,10 @@ SELF=$( basename $0 )
# to add a repo, list its name here, and write a <name>_download()
# function, which should return success if a file was downloaded
# and failure otherwise.
-repos="wayback naptime tld ponce sfdirect gentoo netbsd freebsd debian"
+
+# these are used in the order listed. the order is basically random
+# right now, possibly could rank them according to something or another.
+repos="macports fedora wayback naptime tld ponce sfdirect gentoo netbsd freebsd debian"
usage() {
cat <<EOF
@@ -24,8 +27,11 @@ $repos
If a source file is found, it's downloaded to the current directory.
The md5sum is checked, and the file is discarded if it doesn't match.
+When a matching file with correct md5sum is downloaded, it's saved
+to the current directory and $SELF exits with success status.
-Exit status is success (0) if a file was found, otherwise nonzero.
+If no matching file was found in any of the repos, $SELF exits with
+failure (non-zero) status.
-t is test mode, does an HTTP HEAD request instead of downloading,
and doesn't stop after finding a match.
@@ -64,9 +70,13 @@ read_info_file() {
esac
fi
- # TODO: handle DOWNLOAD_x86_64 and MD5SUM_x86_64
- # if [ "$ARCH" = "x86_64" ]; then
- # fi
+ if [ "$ARCH" = "x86_64" ]; then
+ case "$DOWNLOAD_x86_64" in
+ ""|UNSUPPORTED|UNTESTED) ;;
+ *) DOWNLOAD="$DOWNLOAD_x86_64"
+ MD5SUM="$MD5SUM_x86_64" ;;
+ esac
+ fi
}
do_wget() {
@@ -158,6 +168,20 @@ wayback_download() {
do_wget "$url"
}
+# lot of stuff here. URLs of the form:
+# http://pkgs.fedoraproject.org/repo/pkgs/zziplib/zziplib-0.13.62.tar.bz2/5fe874946390f939ee8f4abe9624b96c/zziplib-0.13.62.tar.bz2
+fedora_download() {
+ pkgname="$( echo $dlfile | rev | cut -d- -f2- | rev )"
+ do_wget "http://pkgs.fedoraproject.org/repo/pkgs/$pkgname/$dlfile/$dlmd5/$dlfile"
+}
+
+# URL form:
+# http://distfiles.macports.org/arj/arj-3.10.22.tar.gz
+macports_download() {
+ pkgname="$( echo $dlfile | rev | cut -d- -f2- | rev )"
+ do_wget "http://distfiles.macports.org/$pkgname/$dlfile"
+}
+
check_file() {
if [ ! -f "$dlfile" ]; then
echo "Nothing downloaded"
@@ -184,8 +208,6 @@ if [ "$1" = "-t" ]; then
wgetopts="--spider --tries 1" # might want -S here too
testmode=1
shift
-else
- wgetopts="--content-disposition"
fi
if [ "$#" -gt 1 ]; then
@@ -195,9 +217,10 @@ fi
echo "-=- $1"
read_info_file "$1"
+set $MD5SUM
+
for srcurl in $DOWNLOAD; do
dlfile="$( basename "$srcurl" )"
- set $MD5SUM
dlmd5=$1
shift