[BACK]Return to oxfetch.sh CVS log [TXT][DIR] Up to [local] / OpenXM / src / util

Annotation of OpenXM/src/util/oxfetch.sh, Revision 1.3

1.1       ohara       1: #!/bin/sh
1.3     ! ohara       2: # $OpenXM: OpenXM/src/util/oxfetch.sh,v 1.2 2003/11/16 17:17:02 ohara Exp $
1.1       ohara       3:
                      4: fetch="wget --no-directories --passive-ftp --quiet --timestamping"
                      5: url=$1
                      6: distdir=${2:-.}
1.2       ohara       7: distinfo=$3
1.1       ohara       8: distfile=`basename "$url"`
                      9:
                     10: _usage () {
1.2       ohara      11:     echo 'usage: oxfetch URL [savedir] [distinfo]'
1.1       ohara      12:     exit 1
                     13: }
                     14:
                     15: _mkdir () {
                     16:     if [ ! -d "$1" ]; then
                     17:         mkdir -p "$1"
                     18:     fi
                     19: }
                     20:
                     21: _fetch () {
                     22:     if [ "distfile" != "" -a ! -f "$distdir/$distfile" ]; then
                     23:         (cd $distdir; $fetch $url)
                     24:     fi
                     25: }
                     26:
1.2       ohara      27: # usage: cat distinfo | _md5 gc6.2.tar.gz
                     28: _md5 () {
                     29:     if [ $# -gt 0 ]; then
                     30:         grep "^MD5 ($1) =" | sed -e "s/^MD5 ($1) = //"
                     31:     fi
                     32: }
                     33:
1.1       ohara      34: _check () {
1.2       ohara      35:     if [ -f "$distinfo" ]; then
                     36:         key1=`(cd $distdir; md5 "$distfile" ) | _md5 $distfile`
                     37:         key2=`cat $distinfo | _md5 "$distfile"`
                     38:         if [ "$key1" = "$key2" ] ; then
1.1       ohara      39:             echo "Checksum OK for $distfile".
                     40:         else
                     41:             echo "Checksum mismatch for $distfile".
1.3     ! ohara      42:             exit 1
1.1       ohara      43:         fi
                     44:     fi
                     45: }
                     46:
                     47: if [ $# -eq 0 ]; then
                     48:     _usage
                     49: fi
                     50:
                     51: _mkdir $distdir
                     52: _fetch
                     53: _check
1.3     ! ohara      54: exit 0

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>