pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/bulk Another rewrite:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ecb69eed0cea
branches:  trunk
changeset: 503237:ecb69eed0cea
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Nov 16 22:07:19 2005 +0000

description:
Another rewrite:

- Changed the implementation how package-specific log files are generated.
  No user-visible changes.
- Stricter preconditions:
  - bulkfilesdir must be an absolute path.
  - brokenfile must not contain slashes.
- The .pkglist file is taken from BULKFILESDIR, not from PKGSRCDIR.
- Error messages use the prefix "[printindex]" instead of "===>", as the
  latter is already reserved for pkgsrc. Everything else would be confusing.
- If a "cd" into a package directory fails, an error message is written to
  ${BULKFILESDIR}/${BROKENFILE}.

diffstat:

 mk/bulk/printindex |  86 ++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 65 insertions(+), 21 deletions(-)

diffs (139 lines):

diff -r 478087483fc8 -r ecb69eed0cea mk/bulk/printindex
--- a/mk/bulk/printindex        Wed Nov 16 22:07:04 2005 +0000
+++ b/mk/bulk/printindex        Wed Nov 16 22:07:19 2005 +0000
@@ -1,7 +1,7 @@
 #!/bin/sh
-# $NetBSD: printindex,v 1.23 2005/11/16 20:39:02 rillig Exp $
+# $NetBSD: printindex,v 1.24 2005/11/16 22:07:19 rillig Exp $
 #
-#
+
 # Copyright (c) 2001 The NetBSD Foundation, Inc.
 # All rights reserved.
 #
@@ -56,27 +56,62 @@
 
 set -e
 
-have_brokenbasedir="no"
+#
+# Global variables
+#
+
+# The brokenfile_flag variable tells whether we want package-specific
+# log files at all. If it is set to "yes", the mkdirs_flag
+# variable tells whether the directories of the package-specific log
+# files are created if necessary.
+brokenfile_flag="yes"
+mkdirs_flag="no"
+pkgsrcdir="${PWD}"
+bulkfilesdir="${pkgsrcdir}"
+brokenfile=""
+
+#
+# Command line parsing
+#
+
 case $# in
-0)     brokenfile="/dev/null"
+0)     brokenfile_flag="no"
        ;;
 1)     brokenfile="$1"
        ;;
-2)     brokenfile="$1"; brokenbasedir="$2"; have_brokenbasedir="yes"
+2)     brokenfile="$1"
+       bulkfilesdir="$2"
+       if [ "${bulkfilesdir}" != "${pkgsrcdir}" ]; then
+               mkdirs_flag="yes"
+       fi
        ;;
-*)     echo "usage: $0 [brokenfile [brokenbasedir]]" 1>&2
+*)     echo "usage: $0 [brokenfile [bulkfilesdir]]" 1>&2
        exit 1
        ;;
 esac
 
+#
+# Sanity checks
+#
+
 case ${BMAKE-""} in
-"")    echo "$0: error: BMAKE must be set." 1>&2
+"")    echo "$0: error: BMAKE must be set and non-empty." 1>&2
+       exit 1;;
+esac
+case ${bulkfilesdir} in
+/*)    ;;
+*)     echo "$0: error: The <bulkfilesdir> argument must be absolute." 1>&2
+       exit 1;;
+esac
+case ${brokenfile} in
+*/*)   echo "$0: error: The <brokenfile> argument must not contain a slash." 1>&2
        exit 1;;
 esac
 
-pkgsrcdir="${PWD}"
+#
+# Get additional system information
+#
 
-# get some initial variables
 cd "${pkgsrcdir}/pkgtools/pkglint"
 BULK_PREREQ=`${BMAKE} show-var VARNAME=BULK_PREREQ`
 GREP=`${BMAKE} show-var VARNAME=GREP USE_TOOLS=grep`
@@ -84,8 +119,13 @@
 SED=`${BMAKE} show-var VARNAME=SED USE_TOOLS=sed`
 cd "${pkgsrcdir}"
 
-if [ -r "${pkgsrcdir}/.pkglist" ]; then
-       . "${pkgsrcdir}/.pkglist"
+case $mkdirs_flag in
+yes)   mkbulkdir="${MKDIR}";;
+*)     mkbulkdir=":";;
+esac
+
+if [ -r "${bulkfilesdir}/.pkglist" ]; then
+       . "${bulkfilesdir}/.pkglist"
 else
        # fall back to all packages.
        list=`${GREP} '^[[:space:]]*'SUBDIR */Makefile | ${SED} 's,/Makefile.*=[[:space:]]*,/,'`
@@ -113,7 +153,7 @@
                        continue;;
                esac;;
        esac
-       
+
        if cd "${pkgsrcdir}/${pkgdir}"; then
                if pkgname=`${BMAKE} show-var VARNAME=PKGNAME`; then
                        echo "${pkgdir} ${pkgname}"
@@ -121,17 +161,21 @@
                else
                        echo "$0: error: could not extract PKGNAME for ${pkgdir} -- skipping." 1>&2
 
-                       case $have_brokenbasedir in
-                       yes)    broken_path="${brokenbasedir}/${pkgdir}/${brokenfile}"
-                               ${MKDIR} "${brokenbasedir}/${pkgdir}"
-                               ;;
-                       *)      broken_path="${brokenfile}"
-                               ;;
+                       case $brokenfile_flag in
+                       no)     continue;;
                        esac
 
-                       { echo "===> ${BMAKE} show-var VARNAME=PKGNAME failed"
-                         ${BMAKE} show-var VARNAME=PKGNAME || true
-                       } >> "${broken_path}" 2>&1
+                       ${mkbulkdir} "${bulkfilesdir}/${pkgdir}"
+                       { echo "[printindex] command failed: ${BMAKE} show-var VARNAME=PKGNAME"
+                         ( ${BMAKE} show-var VARNAME=PKGNAME
+                         ) || true
+                       } >> "${bulkfilesdir}/${pkgdir}/${brokenfile}" 2>&1
                fi
+       else
+               ${mkbulkdir} "${bulkfilesdir}"
+               { echo "[printindex] command failed: cd ${pkgsrcdir}/${pkgdir}"
+                 ( cd "${pkgsrcdir}/${pkgdir}"
+                 ) || true
+               } >> "${bulkfilesdir}/${brokenfile}" 2>&1
        fi
 done



Home | Main Index | Thread Index | Old Index