Home | History | Annotate | Line # | Download | only in sets
makesums revision 1.3
      1 #!/bin/sh
      2 #
      3 # $NetBSD: makesums,v 1.3 2002/03/31 15:17:58 bjh21 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 : ${CKSUM=cksum}
     22 : ${MAKE=make}	# XXX: what purpose does this serve??
     23 tars=$RELEASEDIR
     24 dash_all=no
     25 
     26 # handle args
     27 while : ; do
     28 	case $1 in
     29 	-all)
     30 		dash_all=yes
     31 		break
     32 		;;
     33 	-t*)	
     34 		tars=$2; shift
     35 		;;
     36 	-*)
     37 		cat 1>&2 <<USAGE
     38 Usage: $0 [-t tars] [-all] [setname ...]
     39 	-t tars		\$RELEASEDIR		[$tars]
     40 	[setname ...]	sets to checksum 	[*.tgz]
     41 	-all		do all plain files instead of [setname ...]
     42 USAGE
     43 		exit 1
     44 		;;
     45 	*)
     46 		break
     47 		;;
     48 	esac
     49 	shift
     50 done
     51 
     52 if [ -z "$tars" ]; then
     53 	echo \$RELEASEDIR must be set
     54 	exit 1
     55 fi
     56 
     57 cd $tars
     58 pat="$*"
     59 if [ $dash_all = yes ]; then
     60 	pat='*'
     61 elif [ -z "$pat" ]; then
     62 	pat='*.tgz'
     63 fi
     64 lists=`find $pat -prune -type f \! -name '*SUM' \! -name MD5 2>/dev/null`
     65 if [ -n "$lists" ]; then
     66 	${CKSUM} -o1 $lists > BSDSUM
     67 	${CKSUM}     $lists > CKSUM
     68 	${CKSUM} -m  $lists > MD5
     69 	${CKSUM} -o2 $lists > SYSVSUM
     70 fi
     71