summaryrefslogtreecommitdiff
path: root/mk/bulk/printindex
diff options
context:
space:
mode:
authorrillig <rillig>2005-11-16 22:07:19 +0000
committerrillig <rillig>2005-11-16 22:07:19 +0000
commitf6e8ced1563e43018070de2c17b5d9d5faaa9609 (patch)
tree084e5d83a532758d29962f63f9b2370efd68dfd4 /mk/bulk/printindex
parentabc27fe7abd4d04d2fe4b3ae1af1c8eb006bab91 (diff)
downloadpkgsrc-f6e8ced1563e43018070de2c17b5d9d5faaa9609.tar.gz
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 (limited to 'mk/bulk/printindex')
-rw-r--r--mk/bulk/printindex86
1 files changed, 65 insertions, 21 deletions
diff --git a/mk/bulk/printindex b/mk/bulk/printindex
index 5effc524d70..30a2e8d4485 100644
--- a/mk/bulk/printindex
+++ b/mk/bulk/printindex
@@ -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 @@ MKDIR=`${BMAKE} show-var VARNAME=MKDIR USE_TOOLS=mkdir`
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 @@ for pkgdir in $list :detect_duplicates: $BULK_PREREQ; do
continue;;
esac;;
esac
-
+
if cd "${pkgsrcdir}/${pkgdir}"; then
if pkgname=`${BMAKE} show-var VARNAME=PKGNAME`; then
echo "${pkgdir} ${pkgname}"
@@ -121,17 +161,21 @@ for pkgdir in $list :detect_duplicates: $BULK_PREREQ; do
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