Annotation of OpenXM/src/util/oxfetch.sh, Revision 1.4
1.1 ohara 1: #!/bin/sh
1.4 ! ohara 2: # $OpenXM: OpenXM/src/util/oxfetch.sh,v 1.3 2003/11/16 17:20:54 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.2 ohara 8: distinfo=$3
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.2 ohara 28: # usage: cat distinfo | _md5 gc6.2.tar.gz
29: _md5 () {
30: if [ $# -gt 0 ]; then
31: grep "^MD5 ($1) =" | sed -e "s/^MD5 ($1) = //"
32: fi
33: }
34:
1.1 ohara 35: _check () {
1.4 ! ohara 36: if [ ! -f "$distdir/$distfile" ]; then
! 37: echo "Not found."
! 38: exit 1
! 39: fi
1.2 ohara 40: if [ -f "$distinfo" ]; then
41: key1=`(cd $distdir; md5 "$distfile" ) | _md5 $distfile`
42: key2=`cat $distinfo | _md5 "$distfile"`
43: if [ "$key1" = "$key2" ] ; then
1.1 ohara 44: echo "Checksum OK for $distfile".
45: else
46: echo "Checksum mismatch for $distfile".
1.3 ohara 47: exit 1
1.1 ohara 48: fi
49: fi
50: }
51:
52: if [ $# -eq 0 ]; then
53: _usage
54: fi
55:
56: _mkdir $distdir
57: _fetch
58: _check
1.3 ohara 59: exit 0
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>