2001-01-28 21:56:34 +01:00
|
|
|
#!/bin/sh
|
2005-11-14 22:37:16 +01:00
|
|
|
# $NetBSD: printindex,v 1.22 2005/11/14 21:37:16 rillig Exp $
|
2001-01-28 21:56:34 +01:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# Copyright (c) 2001 The NetBSD Foundation, Inc.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This code is derived from software contributed to The NetBSD Foundation
|
2003-05-06 19:40:18 +02:00
|
|
|
# by
|
2001-01-28 21:56:34 +01:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2005-11-05 19:34:45 +01:00
|
|
|
# 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).
|
2001-01-28 21:56:34 +01:00
|
|
|
#
|
2005-11-05 19:34:45 +01:00
|
|
|
# If the optional argument <brokenfile> is given, it specifies the
|
|
|
|
# basename of the file to which package-specific errors will be
|
|
|
|
# appended.
|
2001-01-28 21:56:34 +01:00
|
|
|
#
|
2005-11-05 19:34:45 +01:00
|
|
|
# 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.
|
2001-01-28 21:56:34 +01:00
|
|
|
#
|
2005-11-05 19:34:45 +01:00
|
|
|
# Note: printindex must be called from a pkgsrc root directory.
|
2001-01-28 21:56:34 +01:00
|
|
|
|
2005-11-05 15:01:07 +01:00
|
|
|
set -e
|
|
|
|
|
2005-11-05 19:34:45 +01:00
|
|
|
have_brokenbasedir="no"
|
2005-11-05 15:01:07 +01:00
|
|
|
case $# in
|
|
|
|
0) brokenfile="/dev/null"
|
|
|
|
;;
|
|
|
|
1) brokenfile="$1"
|
|
|
|
;;
|
2005-11-05 19:34:45 +01:00
|
|
|
2) brokenfile="$1"; brokenbasedir="$2"; have_brokenbasedir="yes"
|
|
|
|
;;
|
|
|
|
*) echo "usage: $0 [brokenfile [brokenbasedir]]" 1>&2
|
2005-11-05 15:01:07 +01:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2005-11-11 11:50:14 +01:00
|
|
|
case ${BMAKE-""} in
|
|
|
|
"") echo "$0: error: BMAKE must be set." 1>&2
|
2005-11-05 15:01:07 +01:00
|
|
|
exit 1;;
|
|
|
|
esac
|
2001-10-14 22:34:53 +02:00
|
|
|
|
2003-12-10 14:59:06 +01:00
|
|
|
# $USR_PKGSRC
|
2005-11-05 15:01:07 +01:00
|
|
|
cwd="${PWD}"
|
2001-01-28 21:56:34 +01:00
|
|
|
|
2003-10-11 04:39:24 +02:00
|
|
|
# get some initial variables
|
2005-11-05 15:01:07 +01:00
|
|
|
cd "${cwd}/pkgtools/pkglint"
|
|
|
|
BULK_PREREQ=`${BMAKE} show-var VARNAME=BULK_PREREQ`
|
2005-05-03 18:34:02 +02:00
|
|
|
GREP=`${BMAKE} show-var VARNAME=GREP USE_TOOLS=grep`
|
2005-11-05 19:34:45 +01:00
|
|
|
MKDIR=`${BMAKE} show-var VARNAME=MKDIR USE_TOOLS=mkdir`
|
2005-05-03 18:34:02 +02:00
|
|
|
SED=`${BMAKE} show-var VARNAME=SED USE_TOOLS=sed`
|
2005-11-05 15:01:07 +01:00
|
|
|
cd "${cwd}"
|
2003-10-11 04:39:24 +02:00
|
|
|
|
2005-11-05 15:01:07 +01:00
|
|
|
if [ -r "${cwd}/.pkglist" ]; then
|
|
|
|
. "${cwd}/.pkglist"
|
2004-01-30 11:54:36 +01:00
|
|
|
else
|
|
|
|
# fall back to all packages.
|
|
|
|
list=`${GREP} '^[[:space:]]*'SUBDIR */Makefile | ${SED} 's,/Makefile.*=[[:space:]]*,/,'`
|
|
|
|
fi
|
2001-01-28 21:56:34 +01:00
|
|
|
|
2005-11-11 10:18:57 +01:00
|
|
|
#
|
|
|
|
# Print the table of PKGPATH and PKGNAME.
|
|
|
|
#
|
|
|
|
# The check for duplicates is necessary to prevents double entries in
|
|
|
|
# the table. The use of the :detect_duplicates: delimiter prevents the
|
|
|
|
# inner "case" from occuring too often, as the $done_pkgs string grows
|
|
|
|
# to about 100k during one run of the program. This saves about
|
|
|
|
# 40 seconds on a 1 GHz Athlon.
|
|
|
|
#
|
2005-11-05 15:01:07 +01:00
|
|
|
done_pkgs=""
|
|
|
|
detect_duplicates=no
|
|
|
|
for pkgdir in $list :detect_duplicates: $BULK_PREREQ; do
|
2001-01-28 21:56:34 +01:00
|
|
|
|
2005-11-05 15:01:07 +01:00
|
|
|
case $pkgdir in :detect_duplicates:)
|
|
|
|
detect_duplicates=yes
|
|
|
|
continue;;
|
|
|
|
esac
|
|
|
|
case $detect_duplicates in yes)
|
2005-11-11 10:18:57 +01:00
|
|
|
case $done_pkgs in *="${pkgdir}"=*)
|
2005-11-05 15:01:07 +01:00
|
|
|
continue;;
|
|
|
|
esac;;
|
2001-03-27 04:50:05 +02:00
|
|
|
esac
|
2005-11-05 15:01:07 +01:00
|
|
|
|
|
|
|
if cd "${cwd}/${pkgdir}"; then
|
|
|
|
if pkgname=`${BMAKE} show-var VARNAME=PKGNAME`; then
|
|
|
|
echo "${pkgdir} ${pkgname}"
|
|
|
|
done_pkgs="${done_pkgs} =${pkgdir}="
|
|
|
|
else
|
|
|
|
echo "$0: error: could not extract PKGNAME for ${pkgdir} -- skipping." 1>&2
|
2005-11-05 19:34:45 +01:00
|
|
|
|
|
|
|
case $have_brokenbasedir in
|
2005-11-08 14:55:29 +01:00
|
|
|
yes) broken_path="${brokenbasedir}/${pkgdir}/${brokenfile}"
|
2005-11-14 22:37:16 +01:00
|
|
|
${MKDIR} "${brokenbasedir}/${pkgdir}"
|
2005-11-05 19:34:45 +01:00
|
|
|
;;
|
2005-11-08 14:55:29 +01:00
|
|
|
*) broken_path="${brokenfile}"
|
2005-11-05 19:34:45 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2005-11-05 15:01:07 +01:00
|
|
|
{ echo "===> ${BMAKE} show-var VARNAME=PKGNAME failed"
|
2005-11-05 19:34:45 +01:00
|
|
|
${BMAKE} show-var VARNAME=PKGNAME || true
|
2005-11-08 14:55:29 +01:00
|
|
|
} >> "${broken_path}" 2>&1
|
2005-11-05 15:01:07 +01:00
|
|
|
fi
|
|
|
|
fi
|
2001-03-27 04:50:05 +02:00
|
|
|
done
|