pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk/bulk Made printdepends very similar to printindex, ...
details: https://anonhg.NetBSD.org/pkgsrc/rev/8a63f106cf78
branches: trunk
changeset: 503240:8a63f106cf78
user: rillig <rillig%pkgsrc.org@localhost>
date: Wed Nov 16 22:18:03 2005 +0000
description:
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:
mk/bulk/printdepends | 167 ++++++++++++++++++++++++++++++++++----------------
1 files changed, 114 insertions(+), 53 deletions(-)
diffs (205 lines):
diff -r 1f038c78cb3d -r 8a63f106cf78 mk/bulk/printdepends
--- a/mk/bulk/printdepends Wed Nov 16 22:13:42 2005 +0000
+++ b/mk/bulk/printdepends Wed Nov 16 22:18:03 2005 +0000
@@ -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@localhost>
# 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 @@
. `dirname $0`/build.conf
fi
-if [ ! -z "$1" ]; then
- brokenfile=$1
-else
- brokenfile=/dev/null
-fi
+#
+# Global variables
+#
+
+# 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=""
-opsys=`uname -s`
-case "$opsys" in
-NetBSD) BMAKE=make ;;
-*) BMAKE=bmake ;;
+#
+# 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 some initial variables
-cd $cwd/pkgtools/pkglint
+#
+# Get additional system information
+#
+
+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}"
+
+case $mkdirs_flag in
+yes) mkbulkdir="${MKDIR}";;
+*) mkbulkdir=":";;
+esac
-if [ -n "${PKGLIST}" ]; then
- list="${PKGLIST}"
-else
- # List of all pkgs, from pkgsrc/*/Makefile
+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
+${mkbulkdir} "${bulkfilesdir}"
+echo list='"'${list}'"' > "${bulkfilesdir}/.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
+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
+ 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
- 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"
- else
- if [ "$l" = "" ]; then
- # No dependencies
- echo "$pkgdir $pkgdir"
- else
- for depdir in $l
- do
- echo "$depdir $pkgdir"
- done
- fi
- fi
+ ${mkbulkdir} "${bulkfilesdir}"
+ { echo "[printdepends] command failed: cd ${pkgsrcdir}/${pkgdir}"
+ ( cd "${pkgsrcdir}/${pkgdir}"
+ ) || true
+ } 1>&2
fi
done
Home |
Main Index |
Thread Index |
Old Index