2 # $NetBSD: printdepends,v 1.24 2007/01/08 21:36:07 rillig Exp $
5 # Copyright (c) 1999, 2000 Hubert Feyrer <hubertf@NetBSD.org>
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # 3. All advertising materials mentioning features or use of this software
17 # must display the following acknowledgement:
18 # This product includes software developed by Hubert Feyrer for
21 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 # usage: printdepends [brokenfile [bulkfilesdir]]
35 # Generates a list of package dependencies suitable for tsort(1) on
36 # stdout. Each line of the output has two fields: the package directory
37 # of the dependency and the package directory of the depending package
38 # (both in the form category/package).
40 # If <brokenfile> is given, package-specific errors are logged to
41 # <bulkfilesdir>/${pkgdir}/<brokenfile>. Otherwise no additional logging
44 # The default for <bulkfilesdir> is the pkgsrc directory itself. If
45 # <bulkfilesdir> differs from the pkgsrc directory, all directories
46 # that are needed for the log files are created automatically.
48 # Note: printdepends must be called from a pkgsrc root directory.
53 if [ -f "$BULK_BUILD_CONF" ]; then
56 .
`dirname $0`/build.conf
63 # The brokenfile_flag variable tells whether we want package-specific
64 # log files at all. If it is set to "yes", the mkdirs_flag
65 # variable tells whether the directories of the package-specific log
66 # files are created if necessary.
70 bulkfilesdir
="${pkgsrcdir}"
74 # Command line parsing
78 0) brokenfile_flag
="no"
84 if [ "${bulkfilesdir}" != "${pkgsrcdir}" ]; then
88 *) echo "usage: $0 [brokenfile [bulkfilesdir]]" 1>&2
98 "") echo "$0: error: BMAKE must be set and non-empty." 1>&2
101 case ${bulkfilesdir} in
103 *) echo "$0: error: The <bulkfilesdir> argument must be absolute." 1>&2
106 case ${brokenfile} in
107 */*) echo "$0: error: The <brokenfile> argument must not contain a slash." 1>&2
112 # Get additional system information
115 cd "${pkgsrcdir}/pkgtools/lintpkgsrc"
116 GREP
=`${BMAKE} show-var VARNAME=GREP USE_TOOLS=grep`
117 MKDIR
=`${BMAKE} show-var VARNAME=MKDIR USE_TOOLS=mkdir`
118 SED
=`${BMAKE} show-var VARNAME=SED USE_TOOLS=sed`
122 yes) mkbulkdir
="${MKDIR}";;
127 "") # List of all packages, from pkgsrc/*/Makefile
128 list
=`${GREP} '^SUBDIR+=' */Makefile | ${GREP} -v '^regress/' | ${SED} -e 's,/Makefile:SUBDIR+=[[:space:]]*,/,' -e 's,#.*,,'`
134 for pkgdir
in $list; do
135 if cd "${pkgsrcdir}/${pkgdir}"; then
136 if deps
=`${BMAKE} show-depends-dirs`; then
138 "") # Make the package depend on itself.
139 # Otherwise it would not show up in the
141 echo "${pkgdir} ${pkgdir}";;
142 *) for dep
in $deps; do
143 echo "${dep} ${pkgdir}"
147 echo "$0: error: could not extract dependencies for ${pkgdir} -- skipping." 1>&2
149 [ $brokenfile_flag = yes ] ||
continue
151 ${mkbulkdir} "${bulkfilesdir}/${pkgdir}"
152 { echo "[printdepends
] command failed
: ${BMAKE} show-depends-dirs
"
153 ( ${BMAKE} show-depends-dirs
155 } >> "${bulkfilesdir}/${pkgdir}/${brokenfile}" 2>&1
158 ${mkbulkdir} "${bulkfilesdir}"
159 { echo "[printdepends
] command failed
: cd ${pkgsrcdir}/${pkgdir}"
160 ( cd "${pkgsrcdir}/${pkgdir}"