makesums revision 1.10
1#!/bin/sh 2# 3# $NetBSD: makesums,v 1.10 2005/10/07 17:21:36 jmc 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 checksum are appended to possibly existing files. 12# NOTE: Don't use this when running parallel jobs 13# If -a is given, then the list of sets is ignored, and ``*'' is used. 14# 15# After shell glob expansion, the list of sets is filtered to remove known 16# output file names (of the form *SUM, SHA512 and MD5), non-existent files, and 17# subdirectories. If this filtering leaves no files, then no output files are 18# produced. Otherwise the resulting list of files are checksummed and five 19# output files (BSDSUM, CKSUM, MD5, SHA512, SYSVSUM) are produced. 20# 21 22prog=${0##*/} 23 24# set defaults 25: ${CKSUM=cksum} 26targetdir=$RELEASEDIR 27dash_all=no 28append=\> 29 30usage() 31{ 32 cat 1>&2 <<USAGE 33Usage: ${prog} [-A] [-a] [-t targetdir] [setname [...]] 34 -A Append to possible existing checksum files 35 -a checksum all plain files instead of [setname [...]] 36 -t targetdir \$RELEASEDIR [$targetdir] 37 setname [...] sets to checksum [*.tgz] 38USAGE 39 exit 1 40} 41 42# handle args 43while getopts aAt: ch; do 44 case ${ch} in 45 A) 46 append=\>\> 47 ;; 48 a) 49 dash_all=yes 50 ;; 51 t) 52 targetdir=${OPTARG} 53 ;; 54 *) 55 usage 56 ;; 57 esac 58done 59shift $((${OPTIND} - 1)) 60 61if [ -z "$targetdir" ]; then 62 echo 1>&2 '$RELEASEDIR must be set or provided with -t' 63 exit 1 64fi 65 66cd $targetdir 67pat="$*" 68if [ $dash_all = yes ]; then 69 pat='*' 70elif [ -z "$pat" ]; then 71 pat='*.tgz' 72fi 73lists=$(find $pat -prune \( -type f -o -type l \) \! -name '*SUM' \! -name MD5 \! -name SHA512 2>/dev/null) 74if [ -n "$lists" ]; then 75 eval ${CKSUM} -o1 $lists $append BSDSUM 76 eval ${CKSUM} $lists $append CKSUM 77 eval ${CKSUM} -a md5 $lists $append MD5 78 eval ${CKSUM} -o2 $lists $append SYSVSUM 79 eval ${CKSUM} -a sha512 $lists $append SHA512 80fi 81