diff options
author | rillig <rillig> | 2005-11-16 22:18:03 +0000 |
---|---|---|
committer | rillig <rillig> | 2005-11-16 22:18:03 +0000 |
commit | 7e0c037a935bf4f83e96c37ac50f917d3fe6b0b5 (patch) | |
tree | 20522672a873d81ce3edd3538fc5a79247f2da6d /mk/bulk | |
parent | eee00923b32a8ed1d518025c9a6149d03fb1b66b (diff) | |
download | pkgsrc-7e0c037a935bf4f83e96c37ac50f917d3fe6b0b5.tar.gz |
Made printdepends very similar to printindex, as both iterate over all
pkgsrc packages, collecting different information.
- BMAKE is taken from the environment instead of querying `uname -s`.
- package-specific log files can be saved in a directory tree different
from PKGSRCDIR.
- Added sanity checks for BMAKE, bulkfilesdir and brokenfile.
- The .pkglist cache is saved in ${BULKFILESDIR} instead of ${PKGSRCDIR}.
- Reformatted the diagnostics.
Diffstat (limited to 'mk/bulk')
-rw-r--r-- | mk/bulk/printdepends | 167 |
1 files changed, 114 insertions, 53 deletions
diff --git a/mk/bulk/printdepends b/mk/bulk/printdepends index 6aeeb9b9402..af1e883521f 100644 --- a/mk/bulk/printdepends +++ b/mk/bulk/printdepends @@ -1,7 +1,7 @@ #!/bin/sh -# $NetBSD: printdepends,v 1.19 2005/11/14 20:58:12 rillig Exp $ - +# $NetBSD: printdepends,v 1.20 2005/11/16 22:18:03 rillig Exp $ # + # Copyright (c) 1999, 2000 Hubert Feyrer <hubertf@NetBSD.org> # All rights reserved. # @@ -30,13 +30,24 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +# usage: printdepends [brokenfile [bulkfilesdir]] # -# Print list of pkg dependencies suitable for tsort(1). -# Start in $USR_PKGSRC. +# Generates a list of package dependencies suitable for tsort(1) on +# stdout. Each line of the output has two fields: the package directory +# of the dependency and the package directory of the depending package +# (both in the form category/package). # -# If an argument is given, use it as a file name -# to contain any failure messages in each package directory. +# If <brokenfile> is given, package-specific errors are logged to +# <bulkfilesdir>/${pkgdir}/<brokenfile>. Otherwise no additional logging +# takes place. # +# The default for <bulkfilesdir> is the pkgsrc directory itself. If +# <bulkfilesdir> differs from the pkgsrc directory, all directories +# that are needed for the log files are created automatically. +# +# Note: printdepends must be called from a pkgsrc root directory. + +set -e # Pull in PKGLIST if [ -f "$BULK_BUILD_CONF" ]; then @@ -45,65 +56,115 @@ else . `dirname $0`/build.conf fi -if [ ! -z "$1" ]; then - brokenfile=$1 -else - brokenfile=/dev/null -fi +# +# Global variables +# -opsys=`uname -s` -case "$opsys" in -NetBSD) BMAKE=make ;; -*) BMAKE=bmake ;; +# 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_flag="no" + ;; +1) brokenfile="$1" + ;; +2) brokenfile="$1" + bulkfilesdir="$2" + if [ "${bulkfilesdir}" != "${pkgsrcdir}" ]; then + mkdirs_flag="yes" + fi + ;; +*) echo "usage: $0 [brokenfile [bulkfilesdir]]" 1>&2 + exit 1 + ;; esac -export BMAKE +# +# Sanity checks +# -# $USR_PKGSRC -cwd=$PWD +case ${BMAKE-""} in +"") 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 + +# +# Get additional system information +# -# get some initial variables -cd $cwd/pkgtools/pkglint +cd "${pkgsrcdir}/pkgtools/pkglint" 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 +cd "${pkgsrcdir}" -if [ -n "${PKGLIST}" ]; then - list="${PKGLIST}" -else - # List of all pkgs, from pkgsrc/*/Makefile +case $mkdirs_flag in +yes) mkbulkdir="${MKDIR}";; +*) mkbulkdir=":";; +esac + +case ${PKGLIST} in +"") # List of all packages, from pkgsrc/*/Makefile list=`${GREP} '^[[:space:]]*'SUBDIR */Makefile | ${GREP} -v regress/ | ${SED} 's,/Makefile.*=[[:space:]]*,/,'` -fi + ;; +*) list="${PKGLIST}" + ;; +esac # cache the package list for printindex -echo list='"'${list}'"' > .pkglist - -for pkgdir in $list -do - if [ ! -d $pkgdir ]; then - echo "WARNING: the package directory $pkgdir is listed in" > /dev/stderr - echo $pkgdir | ${SED} 's;/.*;/Makefile;g' > /dev/stderr - echo "but the directory does not exist. Please fix this!" > /dev/stderr - else - l=`cd $pkgdir && ${BMAKE} show-depends-dirs` - if [ $? != 0 ]; then - echo "WARNING (printdepends): the package in $pkgdir had problem with" > /dev/stderr - echo " ${BMAKE} show-depends-dirs" > /dev/stderr - echo " dependency information in the cache will" > /dev/stderr - echo " be dropped for $pkgdir" > /dev/stderr - echo "${BMAKE} show-depends-dirs failed:" > $brokenfile - ${BMAKE} show-depends-dirs >> $brokenfile 2>&1 - echo "$pkgdir $pkgdir" +${mkbulkdir} "${bulkfilesdir}" +echo list='"'${list}'"' > "${bulkfilesdir}/.pkglist" + +for pkgdir in $list; do + if cd "${pkgsrcdir}/${pkgdir}"; then + if deps=`${BMAKE} show-depends-dirs`; then + case ${deps} in + "") # Make the package depend on itself. + # Otherwise it would not show up in the + # dependency graph. + echo "${pkgdir} ${pkgdir}";; + *) for dep in $deps; do + echo "${dep} ${pkgdir}" + done;; + esac else - if [ "$l" = "" ]; then - # No dependencies - echo "$pkgdir $pkgdir" - else - for depdir in $l - do - echo "$depdir $pkgdir" - done - fi + echo "$0: error: could not extract dependencies for ${pkgdir} -- skipping." 1>&2 + + case $brokenfile_flag in + no) continue;; + esac + + ${mkbulkdir} "${bulkfilesdir}/${pkgdir}" + { echo "[printdepends] command failed: ${BMAKE} show-depends-dir" + ( ${BMAKE} show-depends-dirs + ) || true + } >> "${bulkfilesdir}/${pkgdir}/${brokenfile}" 2>&1 fi + else + ${mkbulkdir} "${bulkfilesdir}" + { echo "[printdepends] command failed: cd ${pkgsrcdir}/${pkgdir}" + ( cd "${pkgsrcdir}/${pkgdir}" + ) || true + } 1>&2 fi done |