makesums revision 1.7.2.2
1#!/bin/sh 2# 3# $NetBSD: makesums,v 1.7.2.2 2005/12/15 20:12:54 tron Exp $ 4# 5# Make checksum files for files in ``tardir''. Usage: 6# makesums [-a] [-t tardir] [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 -a 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, SHA512 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 five 17# output files (BSDSUM, CKSUM, MD5, SHA512, SYSVSUM) are produced. 18# 19 20prog=${0##*/} 21 22# set defaults 23: ${CKSUM=cksum} 24targetdir=$RELEASEDIR 25dash_all=no 26 27usage() 28{ 29 cat 1>&2 <<USAGE 30Usage: ${prog} [-a] [-t targetdir] [setname [...]] 31 -a checksum all plain files instead of [setname [...]] 32 -t targetdir \$RELEASEDIR [$targetdir] 33 setname [...] sets to checksum [*.tgz] 34USAGE 35 exit 1 36} 37 38# handle args 39while getopts at: ch; do 40 case ${ch} in 41 a) 42 dash_all=yes 43 ;; 44 t) 45 targetdir=${OPTARG} 46 ;; 47 *) 48 usage 49 ;; 50 esac 51done 52shift $((${OPTIND} - 1)) 53 54if [ -z "$targetdir" ]; then 55 echo 1>&2 '$RELEASEDIR must be set or provided with -t' 56 exit 1 57fi 58 59cd $targetdir 60pat="$*" 61if [ $dash_all = yes ]; then 62 pat='*' 63elif [ -z "$pat" ]; then 64 pat='*.tgz' 65fi 66lists=$(find $pat -prune \( -type f -o -type l \) \! -name '*SUM' \! -name MD5 \! -name SHA512 2>/dev/null) 67if [ -n "$lists" ]; then 68 ${CKSUM} -o1 $lists > BSDSUM 69 ${CKSUM} $lists > CKSUM 70 ${CKSUM} -a md5 $lists > MD5 71 ${CKSUM} -o2 $lists > SYSVSUM 72 ${CKSUM} -a sha512 $lists > SHA512 73fi 74