From 7211270157b5c3b2327c45e0394ff451d3c05b4c Mon Sep 17 00:00:00 2001 From: jlam Date: Wed, 15 Aug 2007 13:56:24 +0000 Subject: Use a flag to the checksum script to tell it whether we're checking a distfile or a pkgsrc patch. It's simple, cleaner, less magic, etc. (duh!). While here, I notice that _CHECKSUM_CMD was already being defined in mk/checksum/checksum.mk (as it should be), so update the definition from mk/patch/patch.mk and remove it from patch.mk. --- mk/checksum/checksum | 31 +++++++++++++++---------------- mk/checksum/checksum.mk | 5 +++-- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'mk/checksum') diff --git a/mk/checksum/checksum b/mk/checksum/checksum index 4b8d770640a..ba0ad67faf2 100755 --- a/mk/checksum/checksum +++ b/mk/checksum/checksum @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: checksum,v 1.11 2007/08/14 21:25:09 jlam Exp $ +# $NetBSD: checksum,v 1.12 2007/08/15 13:56:24 jlam Exp $ # # Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. # All rights reserved. @@ -47,10 +47,7 @@ # # DESCRIPTION # checksum will verify the checksums in the distinfo file for each -# of the files specified. If the file is a patch (named patch-*), -# then strip out any lines containing NetBSD RCS ID tags before -# computing the checksum for comparison the one in the distinfo -# file. +# of the files specified. # # The checksum utility exits with one of the following values: # @@ -64,6 +61,11 @@ # # OPTIONS # -a algorithm Only verify checksums for the specified algorithm. +# +# -p The specified files are patches, so strip out any +# lines containing NetBSD RCS ID tags before +# computing the checksums for verification. +# # -s suffix Strip the specified suffix from the file names # when searching for the checksum. # @@ -80,15 +82,17 @@ set -e # exit on errors self="${0##*/}" usage() { - ${ECHO} 1>&2 "usage: $self [-a algorithm] [-s suffix] distinfo [file ...]" + ${ECHO} 1>&2 "usage: $self [-a algorithm] [-p] [-s suffix] distinfo [file ...]" } # Process optional arguments algorithm= +patch= suffix= while ${TEST} $# -gt 0; do case "$1" in -a) algorithm="$2"; shift 2 ;; + -p) patch=yes; shift ;; -s) suffix="$2"; shift 2 ;; --) shift; break ;; -*) ${ECHO} 1>&2 "$self: unknown option -- ${1#-}" @@ -149,9 +153,7 @@ fi for file in $files; do sfile="${file%$suffix}" - case $file in - patch-*|*/patch-*) sfile="${sfile##*/}" ;; - esac + ${TEST} -z "$patch" || sfile="${sfile##*/}" ${TEST} "$d_file" = "($sfile)" || continue case "$files_left" in @@ -174,14 +176,11 @@ fi ${ECHO} 1>&2 "$self: $file does not exist" exit 128 fi - case $file in - patch-*|*/patch-*) - checksum=`${SED} -e '/[$]NetBSD.*/d' $file | ${DIGEST} $d_alg` - ;; - *) + if ${TEST} -z "$patch"; then checksum=`${DIGEST} $d_alg < $file` - ;; - esac + else + checksum=`${SED} -e '/[$]NetBSD.*/d' $file | ${DIGEST} $d_alg` + fi if ${TEST} "$d_checksum" = "$checksum"; then ${ECHO} "=> Checksum $d_alg OK for $sfile" else diff --git a/mk/checksum/checksum.mk b/mk/checksum/checksum.mk index 490575ed562..692c52a8650 100644 --- a/mk/checksum/checksum.mk +++ b/mk/checksum/checksum.mk @@ -1,4 +1,4 @@ -# $NetBSD: checksum.mk,v 1.5 2007/08/14 19:08:18 jlam Exp $ +# $NetBSD: checksum.mk,v 1.6 2007/08/15 13:56:24 jlam Exp $ # # See bsd.checksum.mk for helpful comments. # @@ -16,7 +16,8 @@ DO_CHECKSUM_REPEATEDLY?= no _CHECKSUM_CMD= \ ${SETENV} DIGEST=${TOOLS_DIGEST:Q} CAT=${TOOLS_CAT:Q} \ - ECHO=${TOOLS_ECHO:Q} TEST=${TOOLS_TEST:Q} \ + ECHO=${TOOLS_ECHO:Q} SED=${TOOLS_SED:Q} \ + TEST=${TOOLS_TEST:Q} \ ${SH} ${PKGSRCDIR}/mk/checksum/checksum \ _COOKIE.checksum= ${WRKDIR}/.checksum_done -- cgit v1.2.3