makesums revision 1.2 1 #!/bin/sh
2 #
3 # $NetBSD: makesums,v 1.2 2000/08/20 08:29:59 toddpw Exp $
4 #
5 # Make checksum files for files in ``tardir''. Usage:
6 # makesums [-t tardir] [ -all ] [setname ...]
7 #
8 # If -t is omitted, RELEASEDIR must be set and not empty.
9 # The ``setname'' arguments comprise a list of files to checksum,
10 # and may be omitted (in which case ``*.tgz'' is used).
11 # If -all is given, then the list of sets is ignored, and ``*'' is used.
12 #
13 # After shell glob expansion, the list of sets is filtered to remove known
14 # output file names (of the form *SUM and MD5), non-existent files, and
15 # subdirectories. If this filtering leaves no files, then no output files are
16 # produced. Otherwise the resulting list of files are checksummed and four
17 # output files (BSDSUM, CKSUM, MD5, SYSVSUM) are produced.
18 #
19
20 # set defaults
21 : ${MAKE=make} # XXX: what purpose does this serve??
22 tars=$RELEASEDIR
23 dash_all=no
24
25 # handle args
26 while : ; do
27 case $1 in
28 -all)
29 dash_all=yes
30 break
31 ;;
32 -t*)
33 tars=$2; shift
34 ;;
35 -*)
36 cat 1>&2 <<USAGE
37 Usage: $0 [-t tars] [-all] [setname ...]
38 -t tars \$RELEASEDIR [$tars]
39 [setname ...] sets to checksum [*.tgz]
40 -all do all plain files instead of [setname ...]
41 USAGE
42 exit 1
43 ;;
44 *)
45 break
46 ;;
47 esac
48 shift
49 done
50
51 if [ -z "$tars" ]; then
52 echo \$RELEASEDIR must be set
53 exit 1
54 fi
55
56 cd $tars
57 pat="$*"
58 if [ $dash_all = yes ]; then
59 pat='*'
60 elif [ -z "$pat" ]; then
61 pat='*.tgz'
62 fi
63 lists=`find $pat -prune -type f \! -name '*SUM' \! -name MD5 2>/dev/null`
64 if [ -n "$lists" ]; then
65 cksum -o1 $lists > BSDSUM
66 cksum $lists > CKSUM
67 cksum -m $lists > MD5
68 cksum -o2 $lists > SYSVSUM
69 fi
70