=================================================================== RCS file: /home/cvs/OpenXM/src/util/oxfetch.sh,v retrieving revision 1.1 retrieving revision 1.7 diff -u -p -r1.1 -r1.7 --- OpenXM/src/util/oxfetch.sh 2003/11/14 02:58:20 1.1 +++ OpenXM/src/util/oxfetch.sh 2006/10/13 11:51:25 1.7 @@ -1,14 +1,15 @@ #!/bin/sh -# $OpenXM$ +# $OpenXM: OpenXM/src/util/oxfetch.sh,v 1.6 2006/10/12 10:45:37 takayama Exp $ -fetch="wget --no-directories --passive-ftp --quiet --timestamping" +MASTER_SITES="ftp://ftp.math.kobe-u.ac.jp/pub/OpenXM/misc/" +fetch="wget --no-directories --passive-ftp --timestamping" url=$1 distdir=${2:-.} -md5file=$3 +distinfo=${3:-./distinfo} distfile=`basename "$url"` _usage () { - echo 'usage: oxfetch URL [savedir] [md5file]' + echo 'usage: oxfetch URL [savedir] [distinfo]' exit 1 } @@ -24,15 +25,33 @@ _fetch () { fi } -_check () { - if [ -f "$md5file" ]; then - (cd $distdir; md5 "$distfile" > "md5.$distfile" ) - if cmp "$distdir/md5.$distfile" "$md5file" ; then +# usage: _md5grep gc6.2.tar.gz distinfo +_md5grep () { + if [ $# -gt 0 ]; then + awk '/^MD5 \('"$1"'\) =/{print $NF}' $2 + fi +} + +_md5sum () { + md5.sh "$1" | awk '{print $NF}' +} + +_check() { + if [ ! -f "$distdir/$distfile" ]; then + echo "Error: ${distfile} not found." + exit 1 + fi + if [ -f "$distinfo" ]; then + key1=`_md5sum "${distdir}/${distfile}"` + key2=`_md5grep "${distfile}" ${distinfo}` + if [ "$key1" = "$key2" ] ; then echo "Checksum OK for $distfile". + elif [ -z "$key1" ]; then + echo "Warnig: no md5 checker." else - echo "Checksum mismatch for $distfile". + echo "Error: checksum mismatch for $distfile". + exit 1 fi - rm -f "$distdir/md5.$distfile" fi } @@ -43,3 +62,4 @@ fi _mkdir $distdir _fetch _check +exit 0