1999-07-23 00:10:16 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2004-04-20 09:37:15 +04:00
|
|
|
# $NetBSD: makesums,v 1.7 2004/04/20 05:37:15 lukem Exp $
|
1999-07-23 00:10:16 +04:00
|
|
|
#
|
2000-08-20 12:29:59 +04:00
|
|
|
# Make checksum files for files in ``tardir''. Usage:
|
2004-04-20 09:37:15 +04:00
|
|
|
# makesums [-a] [-t tardir] [setname [...]]
|
2000-08-20 12:29:59 +04:00
|
|
|
#
|
|
|
|
# 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).
|
2004-04-20 09:37:15 +04:00
|
|
|
# If -a is given, then the list of sets is ignored, and ``*'' is used.
|
2000-08-20 12:29:59 +04:00
|
|
|
#
|
|
|
|
# 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.
|
1999-07-23 00:10:16 +04:00
|
|
|
#
|
|
|
|
|
2004-04-20 09:37:15 +04:00
|
|
|
prog=${0##*/}
|
|
|
|
|
1999-07-23 00:10:16 +04:00
|
|
|
# set defaults
|
2002-03-31 19:17:58 +04:00
|
|
|
: ${CKSUM=cksum}
|
2004-04-20 09:37:15 +04:00
|
|
|
targetdir=$RELEASEDIR
|
2000-08-20 12:29:59 +04:00
|
|
|
dash_all=no
|
1999-07-23 00:10:16 +04:00
|
|
|
|
2004-04-20 09:37:15 +04:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat 1>&2 <<USAGE
|
|
|
|
Usage: ${prog} [-a] [-t targetdir] [setname [...]]
|
|
|
|
-a checksum all plain files instead of [setname [...]]
|
|
|
|
-t targetdir \$RELEASEDIR [$targetdir]
|
|
|
|
setname [...] sets to checksum [*.tgz]
|
|
|
|
USAGE
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
1999-07-23 00:10:16 +04:00
|
|
|
# handle args
|
2004-04-20 09:37:15 +04:00
|
|
|
while getopts at: ch; do
|
|
|
|
case ${ch} in
|
|
|
|
a)
|
2000-08-20 12:29:59 +04:00
|
|
|
dash_all=yes
|
1999-07-23 00:10:16 +04:00
|
|
|
;;
|
2004-04-20 09:37:15 +04:00
|
|
|
t)
|
|
|
|
targetdir=${OPTARG}
|
1999-07-23 00:10:16 +04:00
|
|
|
;;
|
|
|
|
*)
|
2004-04-20 09:37:15 +04:00
|
|
|
usage
|
1999-07-23 00:10:16 +04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2004-04-20 09:37:15 +04:00
|
|
|
shift $((${OPTIND} - 1))
|
1999-07-23 00:10:16 +04:00
|
|
|
|
2004-04-20 09:37:15 +04:00
|
|
|
if [ -z "$targetdir" ]; then
|
|
|
|
echo 1>&2 '$RELEASEDIR must be set or provided with -t'
|
1999-07-23 00:10:16 +04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2004-04-20 09:37:15 +04:00
|
|
|
cd $targetdir
|
2000-08-20 12:29:59 +04:00
|
|
|
pat="$*"
|
|
|
|
if [ $dash_all = yes ]; then
|
|
|
|
pat='*'
|
|
|
|
elif [ -z "$pat" ]; then
|
|
|
|
pat='*.tgz'
|
|
|
|
fi
|
2004-04-20 09:37:15 +04:00
|
|
|
lists=$(find $pat -prune \( -type f -o -type l \) \! -name '*SUM' \! -name MD5 2>/dev/null)
|
2000-08-20 12:29:59 +04:00
|
|
|
if [ -n "$lists" ]; then
|
2002-03-31 19:17:58 +04:00
|
|
|
${CKSUM} -o1 $lists > BSDSUM
|
|
|
|
${CKSUM} $lists > CKSUM
|
|
|
|
${CKSUM} -m $lists > MD5
|
|
|
|
${CKSUM} -o2 $lists > SYSVSUM
|
1999-07-23 00:10:16 +04:00
|
|
|
fi
|