pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/checksum Move the code that generates distinfo to a...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2e206bf6538c
branches:  trunk
changeset: 532236:2e206bf6538c
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Tue Aug 14 19:08:18 2007 +0000

description:
Move the code that generates distinfo to a standalone AWK script.

diffstat:

 mk/checksum/bsd.checksum.mk |    6 +-
 mk/checksum/checksum.mk     |  104 ++++++------
 mk/checksum/distinfo.awk    |  358 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 410 insertions(+), 58 deletions(-)

diffs (truncated from 511 to 300 lines):

diff -r a544396fcd0d -r 2e206bf6538c mk/checksum/bsd.checksum.mk
--- a/mk/checksum/bsd.checksum.mk       Tue Aug 14 19:04:56 2007 +0000
+++ b/mk/checksum/bsd.checksum.mk       Tue Aug 14 19:08:18 2007 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.checksum.mk,v 1.5 2007/03/07 01:06:11 rillig Exp $
+# $NetBSD: bsd.checksum.mk,v 1.6 2007/08/14 19:08:18 jlam Exp $
 #
 # This Makefile fragment is included by bsd.pkg.mk and defines the
 # relevant variables and targets for the "checksum" phase.
@@ -33,8 +33,8 @@
 
 .PHONY: checksum makesum makepatchsum mps mdi makedistinfo distinfo
 
-checksum makesum: fetch
-makedistinfo distinfo mdi: makepatchsum makesum
+checksum distinfo makesum: fetch
+makedistinfo mdi: distinfo
 mps: makepatchsum
 
 .if defined(NO_CHECKSUM)
diff -r a544396fcd0d -r 2e206bf6538c mk/checksum/checksum.mk
--- a/mk/checksum/checksum.mk   Tue Aug 14 19:04:56 2007 +0000
+++ b/mk/checksum/checksum.mk   Tue Aug 14 19:08:18 2007 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: checksum.mk,v 1.4 2007/03/07 01:06:11 rillig Exp $
+# $NetBSD: checksum.mk,v 1.5 2007/08/14 19:08:18 jlam Exp $
 #
 # See bsd.checksum.mk for helpful comments.
 #
@@ -40,39 +40,51 @@
        fi
 .endfor
 
-makesum:
-       ${_PKG_SILENT}${_PKG_DEBUG}set -e;                              \
+_DISTINFO_CMD= ${SETENV} DIGEST=${TOOLS_DIGEST:Q} SED=${TOOLS_SED:Q}   \
+                       TEST=${TOOLS_TEST:Q} WC=${TOOLS_WC:Q}           \
+               ${AWK} -f ${PKGSRCDIR}/mk/checksum/distinfo.awk --
+
+.if exists(${DISTDIR})
+_DISTINFO_ARGS_COMMON+=        -d ${DISTDIR}
+.endif
+.if exists(${DISTINFO_FILE})
+_DISTINFO_ARGS_COMMON+=        -f ${DISTINFO_FILE}
+.endif
+.if defined(_DIGEST_ALGORITHMS) && !empty(_DIGEST_ALGORITHMS)
+_DISTINFO_ARGS_COMMON+=        ${_DIGEST_ALGORITHMS:S/^/-a /}
+.endif
+.if defined(_PATCH_DIGEST_ALGORITHMS) && !empty(_PATCH_DIGEST_ALGORITHMS)
+_DISTINFO_ARGS_COMMON+=        ${_PATCH_DIGEST_ALGORITHMS:S/^/-p /}
+.endif
+
+.if defined(_CKSUMFILES) && !empty(_CKSUMFILES)
+_DISTINFO_ARGS_DISTSUM+=       ${_CKSUMFILES:S/^/-c /}
+.endif
+.if defined(_IGNOREFILES) && !empty(_IGNOREFILES)
+_DISTINFO_ARGS_DISTSUM+=       ${_IGNOREFILES:S/^/-i /}
+.endif
+
+_DISTINFO_ARGS_PATCHSUM+=      ${PATCHDIR}/patch-*
+
+distinfo:
+       ${RUN}set -e;                                                   \
        newfile=${DISTINFO_FILE}.$$$$;                                  \
-       if ${TEST} -f ${DISTINFO_FILE}; then                            \
-               { ${GREP} '^.NetBSD' ${DISTINFO_FILE} ||                \
-                 ${ECHO} "$$""NetBSD""$$"; } > $$newfile;              \
+       if ${_DISTINFO_CMD} ${_DISTINFO_ARGS_COMMON}                    \
+               ${_DISTINFO_ARGS_DISTSUM}                               \
+               ${_DISTINFO_ARGS_PATCHSUM} > $$newfile;                 \
+       then                                                            \
+               ${RM} -f $$newfile;                                     \
+               ${ECHO_MSG} "=> distinfo: unchanged.";                  \
        else                                                            \
-               ${ECHO} "$$""NetBSD""$$" > $$newfile;                   \
-       fi;                                                             \
-       ${ECHO} "" >> $$newfile;                                        \
-       cd ${DISTDIR};                                                  \
-       for sumfile in "" ${_CKSUMFILES}; do                            \
-               ${TEST} -n "$$sumfile" || continue;                     \
-               for a in "" ${_DIGEST_ALGORITHMS}; do                   \
-                       ${TEST} -n "$$a" || continue;                   \
-                       ${TOOLS_DIGEST} $$a $$sumfile >> $$newfile;     \
-               done;                                                   \
-               ${WC} -c $$sumfile |                                    \
-               ${AWK} '{ print "Size (" $$2 ") = " $$1 " bytes" }'     \
-                       >> $$newfile;                                   \
-       done;                                                           \
-       for ignore in "" ${_IGNOREFILES}; do                            \
-               ${TEST} -n "$$ignore" || continue;                      \
-               for a in "" ${_DIGEST_ALGORITHMS}; do                   \
-                       ${TEST} -n "$$a" || continue;                   \
-                       ${ECHO} "$$a ($$ignore) = IGNORE" >> $$newfile; \
-               done;                                                   \
-       done;                                                           \
-       if ${TEST} -f ${DISTINFO_FILE}; then                            \
-               ${AWK} '$$2 ~ /\(patch-[a-z0-9]+\)/ { print $$0 }'      \
-                       < ${DISTINFO_FILE} >> $$newfile;                \
-       fi;                                                             \
-       if ${CMP} -s $$newfile ${DISTINFO_FILE}; then                   \
+               ${MV} -f $$newfile ${DISTINFO_FILE};                    \
+       fi
+
+makesum:
+       ${RUN}set -e;                                                   \
+       newfile=${DISTINFO_FILE}.$$$$;                                  \
+       if ${_DISTINFO_CMD} ${_DISTINFO_ARGS_COMMON}                    \
+               ${_DISTINFO_ARGS_DISTSUM} > $$newfile;                  \
+       then                                                            \
                ${RM} -f $$newfile;                                     \
                ${ECHO_MSG} "=> distinfo: distfiles part unchanged.";   \
        else                                                            \
@@ -80,31 +92,13 @@
        fi
 
 makepatchsum:
-       ${_PKG_SILENT}${_PKG_DEBUG}set -e;                              \
+       ${RUN}set -e;                                                   \
        newfile=${DISTINFO_FILE}.$$$$;                                  \
-       if ${TEST} -f ${DISTINFO_FILE}; then                            \
-               ${AWK} '$$2 !~ /\(patch-[a-z0-9]+\)/ { print $$0 }'     \
-                       < ${DISTINFO_FILE} >> $$newfile;                \
-       else                                                            \
-               ${ECHO} "$$""NetBSD""$$" > $$newfile;                   \
-               ${ECHO} "" >> $$newfile;                                \
-       fi;                                                             \
-       if ${TEST} -d ${PATCHDIR}; then                                 \
-               ( cd ${PATCHDIR};                                       \
-                 for sumfile in "" patch-*; do                         \
-                       case "$$sumfile" in                             \
-                       ""|"patch-*") continue ;;                       \
-                       patch-local-*|*.orig|*.rej|*~) continue ;;      \
-                       esac;                                           \
-                       for a in "" ${_PATCH_DIGEST_ALGORITHMS}; do     \
-                               ${TEST} -n "$$a" || continue;           \
-                               ${ECHO} "$$a ($$sumfile) = `${SED} -e '/\$$NetBSD.*/d' $$sumfile | ${TOOLS_DIGEST} $$a`" >> $$newfile; \
-                       done;                                           \
-                 done );                                               \
-       fi;                                                             \
-       if ${CMP} -s $$newfile ${DISTINFO_FILE}; then                   \
+       if ${_DISTINFO_CMD} ${_DISTINFO_ARGS_COMMON}                    \
+               ${_DISTINFO_ARGS_PATCHSUM} > $$newfile;                 \
+       then                                                            \
                ${RM} -f $$newfile;                                     \
                ${ECHO_MSG} "=> distinfo: patches part unchanged.";     \
        else                                                            \
-               ${MV} $$newfile ${DISTINFO_FILE};                       \
+               ${MV} -f $$newfile ${DISTINFO_FILE};                    \
        fi
diff -r a544396fcd0d -r 2e206bf6538c mk/checksum/distinfo.awk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/checksum/distinfo.awk  Tue Aug 14 19:08:18 2007 +0000
@@ -0,0 +1,358 @@
+#!/usr/bin/awk -f
+#
+# $NetBSD: distinfo.awk,v 1.1 2007/08/14 19:08:18 jlam Exp $
+#
+# Copyright (c) 2007 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#        This product includes software developed by the NetBSD
+#        Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+#    contributors may be used to endorse or promote products derived
+#    from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+###########################################################################
+#
+# NAME
+#      distinfo.awk -- print distinfo information to standard output
+#
+# SYNOPSIS
+#      distinfo.awk -- [options] [patch ...]
+#
+# DESCRIPTION
+#      distinfo.awk generates distinfo information for the named
+#      cksumfiles, ignorefiles and patches.  The format of a distinfo
+#      file is:
+#
+#         1. NetBSD RCS ID header
+#         2. a blank line
+#         3. digests and size information for each cksumfile and ignorefile
+#         4. digests for patches
+#
+#      For example:
+#
+#      $NetBSD: distinfo.awk,v 1.1 2007/08/14 19:08:18 jlam Exp $
+#
+#      SHA1 (make-3.81.tar.gz) = cd4fa5a3184176492bf0799593a8f250a728210c
+#      RMD160 (make-3.81.tar.gz) = a713a72875cb9a29568677c98022465c6f55cbbf
+#      Size (make-3.81.tar.gz) = 1564560 bytes
+#      SHA1 (patch-aa) = ba88ee2175c7c2258fc647b3654b2f725cf75a50
+#      SHA1 (patch-ac) = de18956fde66fa3fc61a991bb3e6724d9c5b1eac
+#      SHA1 (patch-af) = 067cac366694ce33e5bc52ef937603ae17d3bc2e
+#
+# OPTIONS
+#      The following command line arguments are supported.
+#
+#      --              This is a mandatory option and must always be the
+#                      first option specified.
+#
+#      -a algorithm    Generate a digest for the specified distfiles
+#                      using the named digest algorithm.  If this option
+#                      is given more than once, then digests are
+#                      generated using each algorithm in the order
+#                      given.
+#
+#      -c cksumfile    Generate distinfo information for the named
+#                      cksumfile.  If this option is given more than
+#                      once, then generate information for each
+#                      cksumfile in alphabetical order.
+#
+#      -d distdir      Directory under which cksumfiles and ignorefiles
+#                      are found.
+#
+#      -f distinfo     Path to an existing distinfo file.  If this
+#                      option is given, then it is used to provide the
+#                      distinfo information for either cksumfiles and
+#                      ignorefiles or patches, depending on which
+#                      are not given on the command line.  Also, using
+#                      this option causes the return code to be 0 if
+#                      the generated distinfo information matches the
+#                      contents of the existing distinfo file, or
+#                      non-zero otherwise.
+#
+#      -i ignorefile   Generate distinfo information to ignore checksum
+#                      verification for ignorefile.  If this option is
+#                      given more than once, then generate information
+#                      for each ignore file in alphabetical order.
+#
+#      -p algorithm    Generate a digest for the patches using the named
+#                      digest algorithm.  If this option is given more
+#                      than once, then digests are generated using each
+#                      algorithm in the order given.
+#
+#      patch ...       Generate distinfo information for the named
+#                      patches in alphabetical order.
+#
+###########################################################################
+
+BEGIN {
+       DIGEST = ENVIRON["DIGEST"] ? ENVIRON["DIGEST"] : "digest"
+       SED = ENVIRON["SED"] ? ENVIRON["SED"] : "sed"
+       TEST = ENVIRON["TEST"] ? ENVIRON["TEST"] : "test"
+       WC = ENVIRON["WC"] ? ENVIRON["WC"] : "wc"
+
+       self = "distinfo.awk"
+       ARGSTART = 1
+       A = 0           # size of algorithms array
+       D = 0           # size of distfiles array
+       L = 0           # size of lines array
+       P = 0           # size of patch_algorithms array
+       N = 0           # size of patchfiles array
+       F = 0           # size of distinfo_lines array
+
+       distdir = "."
+       distinfo = ""
+       exitcode = 0
+
+       parse_options()
+
+       if (length(distdir) > 0) {
+               cmd = TEST " -d " distdir
+               if (system(cmd) != 0) {
+                       print self ": " distdir " not found"
+                       exitcode = 128
+               }
+       }
+       if (length(distinfo) > 0) {
+               cmd = TEST " -f " distinfo
+               if (system(cmd) != 0) {
+                       print self ": " distinfo " not found"
+                       exitcode = 128
+               }



Home | Main Index | Thread Index | Old Index