diff options
Diffstat (limited to 'mk/bulk/printindex')
-rw-r--r-- | mk/bulk/printindex | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/mk/bulk/printindex b/mk/bulk/printindex index 0cda3e561bd..dce0d6d7097 100644 --- a/mk/bulk/printindex +++ b/mk/bulk/printindex @@ -1,5 +1,5 @@ #!/bin/sh -# $NetBSD: printindex,v 1.17 2005/11/05 14:01:07 rillig Exp $ +# $NetBSD: printindex,v 1.18 2005/11/05 18:34:45 rillig Exp $ # # # Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -37,25 +37,36 @@ # POSSIBILITY OF SUCH DAMAGE. # - -# Generate package index. If an argument is given, use it as a file name -# to contain any failure messages in each package directory. +# usage: printindex [brokenfile [brokenbasedir]] +# +# Generates a mapping from pkgsrc directories to the current package +# version and prints it on stdout. Each line of the output has two +# fields: the package directory (in the form category/package) and the +# package version (in the form package-1.456nb3). # -# generates a pkgsrc directory <-> package name database. eg. -# foo/bar bar-2.0 -# foo/baz baz-1.0.1 +# If the optional argument <brokenfile> is given, it specifies the +# basename of the file to which package-specific errors will be +# appended. # -# Start in $USR_PKGSRC. +# If the <brokenbasedir> is specified, the complete filename of the +# <brokenfile> is <brokenbasedir>/${pkgdir}/<brokenfile>. This +# directory is created automatically if needed. If the <brokenbasedir> +# is not specified, the <brokenfile> is created in the package directory +# itself. # +# Note: printindex must be called from a pkgsrc root directory. set -e +have_brokenbasedir="no" case $# in 0) brokenfile="/dev/null" ;; 1) brokenfile="$1" ;; -*) echo "usage: $0 [brokenfile]" 1>&2 +2) brokenfile="$1"; brokenbasedir="$2"; have_brokenbasedir="yes" + ;; +*) echo "usage: $0 [brokenfile [brokenbasedir]]" 1>&2 exit 1 ;; esac @@ -72,6 +83,7 @@ cwd="${PWD}" cd "${cwd}/pkgtools/pkglint" BULK_PREREQ=`${BMAKE} show-var VARNAME=BULK_PREREQ` GREP=`${BMAKE} show-var VARNAME=GREP USE_TOOLS=grep` +MKDIR=`${BMAKE} show-var VARNAME=MKDIR USE_TOOLS=mkdir` SED=`${BMAKE} show-var VARNAME=SED USE_TOOLS=sed` cd "${cwd}" @@ -102,9 +114,18 @@ for pkgdir in $list :detect_duplicates: $BULK_PREREQ; do done_pkgs="${done_pkgs} =${pkgdir}=" else echo "$0: error: could not extract PKGNAME for ${pkgdir} -- skipping." 1>&2 + + case $have_brokenbasedir in + yes) brokendir="${brokenbasedir}/${pkgdir}" + ${MKDIR} "${brokendir}" + ;; + *) brokendir="." + ;; + esac + { echo "===> ${BMAKE} show-var VARNAME=PKGNAME failed" - cd "${cwd}/${pkgdir}" && ${BMAKE} show-var VARNAME=PKGNAME || true - } >> "${brokenfile}" 2>&1 + ${BMAKE} show-var VARNAME=PKGNAME || true + } >> "${brokendir}/${brokenfile}" 2>&1 fi fi done |