2 # $NetBSD: printindex,v 1.31 2008/01/04 15:49:08 rillig Exp $
5 # Copyright (c) 2001 The NetBSD Foundation, Inc.
8 # This code is derived from software contributed to The NetBSD Foundation
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions
14 # 1. Redistributions of source code must retain the above copyright
15 # notice, this list of conditions and the following disclaimer.
16 # 2. Redistributions in binary form must reproduce the above copyright
17 # notice, this list of conditions and the following disclaimer in the
18 # documentation and/or other materials provided with the distribution.
20 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 # POSSIBILITY OF SUCH DAMAGE.
39 # The brokenfile_flag variable tells whether we want package-specific
40 # log files at all. If it is set to "yes", the mkdirs_flag
41 # variable tells whether the directories of the package-specific log
42 # files are created if necessary.
46 bulkfilesdir
="${pkgsrcdir}"
50 # Command line parsing
54 0) brokenfile_flag
="no"
60 if [ "${bulkfilesdir}" != "${pkgsrcdir}" ]; then
64 *) echo "usage: $0 [brokenfile [bulkfilesdir]]" 1>&2
74 "") echo "$0: error: BMAKE must be set and non-empty." 1>&2
77 case ${bulkfilesdir} in
79 *) echo "$0: error: The <bulkfilesdir> argument must be absolute." 1>&2
83 */*) echo "$0: error: The <brokenfile> argument must not contain a slash." 1>&2
88 # Get additional system information
91 cd "${pkgsrcdir}/pkgtools/lintpkgsrc"
92 BULK_PREREQ
=`${BMAKE} show-var VARNAME=BULK_PREREQ`
93 GREP
=`${BMAKE} show-var VARNAME=GREP USE_TOOLS=grep`
94 MKDIR
=`${BMAKE} show-var VARNAME=MKDIR USE_TOOLS=mkdir`
95 SED
=`${BMAKE} show-var VARNAME=SED USE_TOOLS=sed`
99 yes) mkbulkdir
="${MKDIR}";;
103 case ${PKGLIST-""} in
104 "") # List of all packages, from pkgsrc/*/Makefile
105 list
=`${GREP} '^[[:space:]]*'SUBDIR */Makefile | ${GREP} -v regress/ | ${SED} 's,/Makefile.*=[[:space:]]*,/,'`
112 # Sanity checks, part 2
116 +./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"
119 inval
=`echo "${BULK_PREREQ}" | tr -d " +\\\\-${allowed}"`
120 echo "$0: error: BULK_PREREQ contains invalid characters (${inval})." 1>&2
125 inval
=`echo "${list}" | tr -d " +\\\\-${allowed}"`
126 echo "$0: error: The package list contains invalid characters (${inval})." 1>&2
134 # Print the table of PKGPATH and PKGNAME.
136 # The check for duplicates is necessary to prevents double entries in
137 # the table. The use of the :detect_duplicates: delimiter prevents the
138 # inner "case" from occuring too often, as the $done_pkgs string grows
139 # to about 100k during one run of the program. This saves about
140 # 40 seconds on a 1 GHz Athlon.
144 for pkgdir
in $list :detect_duplicates
: $BULK_PREREQ; do
146 case $pkgdir in :detect_duplicates
:)
147 detect_duplicates
=yes
150 case $detect_duplicates in yes)
151 case $done_pkgs in *="${pkgdir}"=*)
156 if cd "${pkgsrcdir}/${pkgdir}"; then
158 # The NetBSD /bin/sh creates lots of zombies for the backticks
159 # line below, and it doesn't clean them up until a real
160 # command is executed. (See PR 35227)
164 if output
=`${BMAKE} show-var VARNAME=PKGNAME can-be-built-here`; then
168 read can_be_built_here
169 while read reason
; do
170 reasons
="$reasons$reason$newline"
175 echo "${pkgdir} ${pkgname}"
176 done_pkgs
="${done_pkgs} =${pkgdir}="
178 if [ "$can_be_built_here" != "yes" ]; then
179 ${mkbulkdir} "${bulkfilesdir}/${pkgdir}"
180 echo "$reasons" > "${bulkfilesdir}/${pkgdir}/${brokenfile}"
183 echo "$0: error
: could not extract PKGNAME
for ${pkgdir} -- skipping.
" 1>&2
185 case $brokenfile_flag in
189 ${mkbulkdir} "${bulkfilesdir}/${pkgdir}"
190 { echo "[printindex] command failed: ${BMAKE} show-var VARNAME=PKGNAME"
191 ( ${BMAKE} show-var VARNAME
=PKGNAME
193 } >> "${bulkfilesdir}/${pkgdir}/${brokenfile}" 2>&1
196 ${mkbulkdir} "${bulkfilesdir}"
197 { echo "[printindex] command failed: cd ${pkgsrcdir}/${pkgdir}"
198 ( cd "${pkgsrcdir}/${pkgdir}"