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

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

1.1       ohara       1: #!/bin/sh
1.6     ! takayama    2: # $OpenXM: OpenXM/src/util/oxfetch.sh,v 1.5 2005/07/25 19:04:18 ohara Exp $
1.1       ohara       3:
1.4       ohara       4: MASTER_SITES="ftp://ftp.math.kobe-u.ac.jp/pub/OpenXM/misc/"
                      5: fetch="wget --no-directories --passive-ftp --timestamping"
1.1       ohara       6: url=$1
                      7: distdir=${2:-.}
1.5       ohara       8: distinfo=${3:-./distinfo}
1.1       ohara       9: distfile=`basename "$url"`
                     10:
                     11: _usage () {
1.2       ohara      12:     echo 'usage: oxfetch URL [savedir] [distinfo]'
1.1       ohara      13:     exit 1
                     14: }
                     15:
                     16: _mkdir () {
                     17:     if [ ! -d "$1" ]; then
                     18:         mkdir -p "$1"
                     19:     fi
                     20: }
                     21:
                     22: _fetch () {
                     23:     if [ "distfile" != "" -a ! -f "$distdir/$distfile" ]; then
                     24:         (cd $distdir; $fetch $url)
                     25:     fi
                     26: }
                     27:
1.5       ohara      28: # usage: _md5grep gc6.2.tar.gz distinfo
                     29: _md5grep () {
1.2       ohara      30:     if [ $# -gt 0 ]; then
1.5       ohara      31:         awk '/^MD5 \('"$1"'\) =/{print $NF}' $2
                     32:     fi
                     33: }
                     34:
                     35: _md5sum () {
                     36:     if [ "`which md5`" ]; then
                     37:         md5 "$1" | awk '{print $NF}'
                     38:     elif [ "`which md5sum`" ]; then
                     39:         md5sum "$1" | awk '{print $1}'
1.2       ohara      40:     fi
                     41: }
                     42:
1.6     ! takayama   43: _check() {
        !            44:    echo "Check is skipped."
        !            45: }
        !            46:
        !            47: _check_orig () {
1.4       ohara      48:     if [ ! -f "$distdir/$distfile" ]; then
1.5       ohara      49:         echo "Error: ${distfile} not found."
1.4       ohara      50:         exit 1
                     51:     fi
1.2       ohara      52:     if [ -f "$distinfo" ]; then
1.5       ohara      53:         key1=`_md5sum  "${distdir}/${distfile}"`
                     54:         key2=`_md5grep "${distfile}" ${distinfo}`
1.2       ohara      55:         if [ "$key1" = "$key2" ] ; then
1.1       ohara      56:             echo "Checksum OK for $distfile".
1.5       ohara      57:         elif [ -z "$key1" ]; then
                     58:             echo "Warnig: no md5 checker."
1.1       ohara      59:         else
1.5       ohara      60:             echo "Error: checksum mismatch for $distfile".
1.3       ohara      61:             exit 1
1.1       ohara      62:         fi
                     63:     fi
                     64: }
                     65:
                     66: if [ $# -eq 0 ]; then
                     67:     _usage
                     68: fi
                     69:
                     70: _mkdir $distdir
                     71: _fetch
                     72: _check
1.3       ohara      73: exit 0

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