Home | History | Annotate | Line # | Download | only in sets
makesums revision 1.7.2.2
      1      1.1      is #!/bin/sh
      2      1.1      is #
      3  1.7.2.1    tron # $NetBSD: makesums,v 1.7.2.2 2005/12/15 20:12:54 tron Exp $
      4      1.1      is #
      5      1.2  toddpw # Make checksum files for files in ``tardir''.  Usage:
      6      1.7   lukem # makesums [-a] [-t tardir] [setname [...]]
      7      1.2  toddpw #
      8      1.2  toddpw # If -t is omitted, RELEASEDIR must be set and not empty.
      9      1.2  toddpw # The ``setname'' arguments comprise a list of files to checksum,
     10      1.2  toddpw # and may be omitted (in which case ``*.tgz'' is used).
     11      1.7   lukem # If -a is given, then the list of sets is ignored, and ``*'' is used.
     12      1.2  toddpw #
     13      1.2  toddpw # After shell glob expansion, the list of sets is filtered to remove known
     14  1.7.2.2    tron # output file names (of the form *SUM, SHA512 and MD5), non-existent files, and
     15      1.2  toddpw # subdirectories. If this filtering leaves no files, then no output files are
     16  1.7.2.2    tron # produced. Otherwise the resulting list of files are checksummed and five
     17  1.7.2.2    tron # output files (BSDSUM, CKSUM, MD5, SHA512, SYSVSUM) are produced.
     18      1.1      is #
     19      1.1      is 
     20      1.7   lukem prog=${0##*/}
     21      1.7   lukem 
     22      1.1      is # set defaults
     23      1.3   bjh21 : ${CKSUM=cksum}
     24      1.7   lukem targetdir=$RELEASEDIR
     25      1.2  toddpw dash_all=no
     26      1.1      is 
     27      1.7   lukem usage()
     28      1.7   lukem {
     29      1.7   lukem 	cat 1>&2 <<USAGE
     30      1.7   lukem Usage: ${prog} [-a] [-t targetdir] [setname [...]]
     31      1.7   lukem 	-a		checksum all plain files instead of [setname [...]]
     32      1.7   lukem 	-t targetdir	\$RELEASEDIR		[$targetdir]
     33      1.7   lukem 	setname [...]	sets to checksum 	[*.tgz]
     34      1.7   lukem USAGE
     35      1.7   lukem 	exit 1
     36      1.7   lukem }
     37      1.7   lukem 
     38      1.1      is # handle args
     39      1.7   lukem while getopts at: ch; do
     40      1.7   lukem 	case ${ch} in
     41      1.7   lukem 	a)
     42      1.2  toddpw 		dash_all=yes
     43      1.1      is 		;;
     44      1.7   lukem 	t)	
     45      1.7   lukem 		targetdir=${OPTARG}
     46      1.1      is 		;;
     47      1.1      is 	*)
     48      1.7   lukem 		usage
     49      1.1      is 		;;
     50      1.1      is 	esac
     51      1.1      is done
     52      1.7   lukem shift $((${OPTIND} - 1))
     53      1.1      is 
     54      1.7   lukem if [ -z "$targetdir" ]; then
     55      1.7   lukem 	echo 1>&2 '$RELEASEDIR must be set or provided with -t'
     56      1.1      is 	exit 1
     57      1.1      is fi
     58      1.1      is 
     59      1.7   lukem cd $targetdir
     60      1.2  toddpw pat="$*"
     61      1.2  toddpw if [ $dash_all = yes ]; then
     62      1.2  toddpw 	pat='*'
     63      1.2  toddpw elif [ -z "$pat" ]; then
     64      1.2  toddpw 	pat='*.tgz'
     65      1.2  toddpw fi
     66  1.7.2.1    tron lists=$(find $pat -prune \( -type f -o -type l \) \! -name '*SUM' \! -name MD5 \! -name SHA512 2>/dev/null)
     67      1.2  toddpw if [ -n "$lists" ]; then
     68      1.3   bjh21 	${CKSUM} -o1 $lists > BSDSUM
     69      1.3   bjh21 	${CKSUM}     $lists > CKSUM
     70  1.7.2.1    tron 	${CKSUM} -a md5  $lists > MD5
     71      1.3   bjh21 	${CKSUM} -o2 $lists > SYSVSUM
     72  1.7.2.1    tron 	${CKSUM} -a sha512  $lists > SHA512
     73      1.1      is fi
     74