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