diff options
author | jlam <jlam@pkgsrc.org> | 2007-08-15 13:56:24 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2007-08-15 13:56:24 +0000 |
commit | 4ca817df4f585e04eb598f8d14a2857152c9cbbd (patch) | |
tree | b39c3812c8c0a6ac7aeb0c9ba941493ef70c4828 /mk | |
parent | 24ed48fffc89b79dbcafd0b2cc095b5c3642a871 (diff) | |
download | pkgsrc-4ca817df4f585e04eb598f8d14a2857152c9cbbd.tar.gz |
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.
Diffstat (limited to 'mk')
-rwxr-xr-x | mk/checksum/checksum | 31 | ||||
-rw-r--r-- | mk/checksum/checksum.mk | 5 | ||||
-rw-r--r-- | mk/patch/patch.mk | 9 |
3 files changed, 20 insertions, 25 deletions
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 diff --git a/mk/patch/patch.mk b/mk/patch/patch.mk index 772eed5caef..4bb0a685f63 100644 --- a/mk/patch/patch.mk +++ b/mk/patch/patch.mk @@ -1,4 +1,4 @@ -# $NetBSD: patch.mk,v 1.13 2007/08/14 21:25:10 jlam Exp $ +# $NetBSD: patch.mk,v 1.14 2007/08/15 13:56:25 jlam Exp $ # # The following variables may be set in a package Makefile and control # how pkgsrc patches are applied. @@ -261,11 +261,6 @@ _PKGSRC_PATCHES+= ${PATCHDIR}/patch-* _PKGSRC_PATCHES+= ${LOCALPATCHES}/${PKGPATH}/* .endif -_CHECKSUM_CMD= ${SETENV} DIGEST=${TOOLS_DIGEST:Q} CAT=${TOOLS_CAT:Q} \ - ECHO=${TOOLS_ECHO:Q} SED=${TOOLS_SED:Q} \ - TEST=${TOOLS_TEST:Q} \ - ${SH} ${PKGSRCDIR}/mk/checksum/checksum - pkgsrc-patch-message: @${STEP_MSG} "Applying pkgsrc patches for ${PKGNAME}" @@ -293,7 +288,7 @@ do-pkgsrc-patch: continue; \ fi; \ ${ECHO_PATCH_MSG} "Verifying $$i"; \ - if ${_CHECKSUM_CMD} ${DISTINFO_FILE} $$i >/dev/null 2>&1; then \ + if ${_CHECKSUM_CMD} -p ${DISTINFO_FILE} $$i >/dev/null 2>&1; then \ cksum_result=0; \ else \ cksum_result=$$?; \ |