Annotation of OpenXM/src/util/oxfetch.sh, Revision 1.2
1.1 ohara 1: #!/bin/sh
1.2 ! ohara 2: # $OpenXM: OpenXM/src/util/oxfetch.sh,v 1.1 2003/11/14 02:58:20 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".
42: fi
43: fi
44: }
45:
46: if [ $# -eq 0 ]; then
47: _usage
48: fi
49:
50: _mkdir $distdir
51: _fetch
52: _check
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>