makesums revision 1.8
11.1Sis#!/bin/sh 21.1Sis# 31.8Selad# $NetBSD: makesums,v 1.8 2005/09/13 16:38:01 elad Exp $ 41.1Sis# 51.2Stoddpw# Make checksum files for files in ``tardir''. Usage: 61.7Slukem# makesums [-a] [-t tardir] [setname [...]] 71.2Stoddpw# 81.2Stoddpw# If -t is omitted, RELEASEDIR must be set and not empty. 91.2Stoddpw# The ``setname'' arguments comprise a list of files to checksum, 101.2Stoddpw# and may be omitted (in which case ``*.tgz'' is used). 111.7Slukem# If -a is given, then the list of sets is ignored, and ``*'' is used. 121.2Stoddpw# 131.2Stoddpw# After shell glob expansion, the list of sets is filtered to remove known 141.2Stoddpw# output file names (of the form *SUM and MD5), non-existent files, and 151.2Stoddpw# subdirectories. If this filtering leaves no files, then no output files are 161.2Stoddpw# produced. Otherwise the resulting list of files are checksummed and four 171.2Stoddpw# output files (BSDSUM, CKSUM, MD5, SYSVSUM) are produced. 181.1Sis# 191.1Sis 201.7Slukemprog=${0##*/} 211.7Slukem 221.1Sis# set defaults 231.3Sbjh21: ${CKSUM=cksum} 241.7Slukemtargetdir=$RELEASEDIR 251.2Stoddpwdash_all=no 261.1Sis 271.7Slukemusage() 281.7Slukem{ 291.7Slukem cat 1>&2 <<USAGE 301.7SlukemUsage: ${prog} [-a] [-t targetdir] [setname [...]] 311.7Slukem -a checksum all plain files instead of [setname [...]] 321.7Slukem -t targetdir \$RELEASEDIR [$targetdir] 331.7Slukem setname [...] sets to checksum [*.tgz] 341.7SlukemUSAGE 351.7Slukem exit 1 361.7Slukem} 371.7Slukem 381.1Sis# handle args 391.7Slukemwhile getopts at: ch; do 401.7Slukem case ${ch} in 411.7Slukem a) 421.2Stoddpw dash_all=yes 431.1Sis ;; 441.7Slukem t) 451.7Slukem targetdir=${OPTARG} 461.1Sis ;; 471.1Sis *) 481.7Slukem usage 491.1Sis ;; 501.1Sis esac 511.1Sisdone 521.7Slukemshift $((${OPTIND} - 1)) 531.1Sis 541.7Slukemif [ -z "$targetdir" ]; then 551.7Slukem echo 1>&2 '$RELEASEDIR must be set or provided with -t' 561.1Sis exit 1 571.1Sisfi 581.1Sis 591.7Slukemcd $targetdir 601.2Stoddpwpat="$*" 611.2Stoddpwif [ $dash_all = yes ]; then 621.2Stoddpw pat='*' 631.2Stoddpwelif [ -z "$pat" ]; then 641.2Stoddpw pat='*.tgz' 651.2Stoddpwfi 661.8Seladlists=$(find $pat -prune \( -type f -o -type l \) \! -name '*SUM' \! -name MD5 \! -name SHA512 2>/dev/null) 671.2Stoddpwif [ -n "$lists" ]; then 681.3Sbjh21 ${CKSUM} -o1 $lists > BSDSUM 691.3Sbjh21 ${CKSUM} $lists > CKSUM 701.8Selad ${CKSUM} -a md5 $lists > MD5 711.3Sbjh21 ${CKSUM} -o2 $lists > SYSVSUM 721.8Selad ${CKSUM} -a sha512 $lists > SHA512 731.1Sisfi 74