1999-07-23 00:10:16 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-10-21 06:41:14 +04:00
|
|
|
# $NetBSD: makesums,v 1.11 2005/10/21 02:41:14 jmc 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).
|
2005-10-07 21:21:36 +04:00
|
|
|
# If -A is given, then the checksum are appended to possibly existing files.
|
|
|
|
# NOTE: Don't use this when running parallel jobs
|
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
|
2005-10-06 06:12:49 +04:00
|
|
|
# output file names (of the form *SUM, SHA512 and MD5), non-existent files, and
|
2000-08-20 12:29:59 +04:00
|
|
|
# subdirectories. If this filtering leaves no files, then no output files are
|
2005-10-06 06:12:49 +04:00
|
|
|
# produced. Otherwise the resulting list of files are checksummed and five
|
|
|
|
# output files (BSDSUM, CKSUM, MD5, SHA512, 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
|
2005-10-21 06:41:14 +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
|
2005-10-07 21:21:36 +04:00
|
|
|
append=\>
|
1999-07-23 00:10:16 +04:00
|
|
|
|
2004-04-20 09:37:15 +04:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat 1>&2 <<USAGE
|
2005-10-07 21:21:36 +04:00
|
|
|
Usage: ${prog} [-A] [-a] [-t targetdir] [setname [...]]
|
|
|
|
-A Append to possible existing checksum files
|
2004-04-20 09:37:15 +04:00
|
|
|
-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
|
2005-10-07 21:21:36 +04:00
|
|
|
while getopts aAt: ch; do
|
2004-04-20 09:37:15 +04:00
|
|
|
case ${ch} in
|
2005-10-07 21:21:36 +04:00
|
|
|
A)
|
|
|
|
append=\>\>
|
|
|
|
;;
|
2004-04-20 09:37:15 +04:00
|
|
|
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
|
2005-09-13 20:38:01 +04:00
|
|
|
lists=$(find $pat -prune \( -type f -o -type l \) \! -name '*SUM' \! -name MD5 \! -name SHA512 2>/dev/null)
|
2000-08-20 12:29:59 +04:00
|
|
|
if [ -n "$lists" ]; then
|
2005-10-07 21:21:36 +04:00
|
|
|
eval ${CKSUM} -o1 $lists $append BSDSUM
|
|
|
|
eval ${CKSUM} $lists $append CKSUM
|
|
|
|
eval ${CKSUM} -a md5 $lists $append MD5
|
|
|
|
eval ${CKSUM} -o2 $lists $append SYSVSUM
|
|
|
|
eval ${CKSUM} -a sha512 $lists $append SHA512
|
1999-07-23 00:10:16 +04:00
|
|
|
fi
|