NetBSD/distrib/sets/makesums
toddpw eb6225f8f4 Enhance script. Add -all option and improve intelligence about which files to
sum (and whether to do sums at all!). Describe script in comments at the top.
2000-08-20 08:29:59 +00:00

70 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
#
# $NetBSD: makesums,v 1.2 2000/08/20 08:29:59 toddpw Exp $
#
# Make checksum files for files in ``tardir''. Usage:
# makesums [-t tardir] [ -all ] [setname ...]
#
# If -t is omitted, RELEASEDIR must be set and not empty.
# The ``setname'' arguments comprise a list of files to checksum,
# and may be omitted (in which case ``*.tgz'' is used).
# If -all is given, then the list of sets is ignored, and ``*'' is used.
#
# After shell glob expansion, the list of sets is filtered to remove known
# output file names (of the form *SUM and MD5), non-existent files, and
# subdirectories. If this filtering leaves no files, then no output files are
# produced. Otherwise the resulting list of files are checksummed and four
# output files (BSDSUM, CKSUM, MD5, SYSVSUM) are produced.
#
# set defaults
: ${MAKE=make} # XXX: what purpose does this serve??
tars=$RELEASEDIR
dash_all=no
# handle args
while : ; do
case $1 in
-all)
dash_all=yes
break
;;
-t*)
tars=$2; shift
;;
-*)
cat 1>&2 <<USAGE
Usage: $0 [-t tars] [-all] [setname ...]
-t tars \$RELEASEDIR [$tars]
[setname ...] sets to checksum [*.tgz]
-all do all plain files instead of [setname ...]
USAGE
exit 1
;;
*)
break
;;
esac
shift
done
if [ -z "$tars" ]; then
echo \$RELEASEDIR must be set
exit 1
fi
cd $tars
pat="$*"
if [ $dash_all = yes ]; then
pat='*'
elif [ -z "$pat" ]; then
pat='*.tgz'
fi
lists=`find $pat -prune -type f \! -name '*SUM' \! -name MD5 2>/dev/null`
if [ -n "$lists" ]; then
cksum -o1 $lists > BSDSUM
cksum $lists > CKSUM
cksum -m $lists > MD5
cksum -o2 $lists > SYSVSUM
fi