summaryrefslogtreecommitdiff
path: root/distrib/sets/makesums
blob: eb2d528905cdaff79b08a0a160a964ce21376075 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
#
# $NetBSD: makesums,v 1.6 2003/01/03 15:26:32 lukem 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
: ${CKSUM=cksum}
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 targetdir] [-all] [setname ...]
	-t targetdir	\$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 -o -type l \) \! -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