pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk Allow the creation of error handlers for shell comm...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f276cfd54aad
branches:  trunk
changeset: 487174:f276cfd54aad
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Mon Jan 10 18:34:48 2005 +0000

description:
Allow the creation of error handlers for shell commands in make targets.
PKG_ERROR_CLASSES is a list of error handlers, PKG_ERROR_HANDLER.<class>,
to create.  The default error handler will rethrow the exit code after
emitting an error message that may be specified per-class with
PKG_ERROR_MSG.<class>.

Create error messages for the configure and build phases that inform
the user of places to go looking for why the build didn't complete.

diffstat:

 mk/bsd.pkg.mk |  48 +++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 43 insertions(+), 5 deletions(-)

diffs (80 lines):

diff -r a0766c7a4bcc -r f276cfd54aad mk/bsd.pkg.mk
--- a/mk/bsd.pkg.mk     Mon Jan 10 18:27:37 2005 +0000
+++ b/mk/bsd.pkg.mk     Mon Jan 10 18:34:48 2005 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.pkg.mk,v 1.1553 2005/01/10 08:30:43 jlam Exp $
+#      $NetBSD: bsd.pkg.mk,v 1.1554 2005/01/10 18:34:48 jlam Exp $
 #
 # This file is in the public domain.
 #
@@ -3162,6 +3162,22 @@
 ${WRAPPER_COOKIE}:
        ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-wrapper PKG_PHASE=wrapper
 
+PKG_ERROR_CLASSES+=    configure
+PKG_ERROR_MSG.configure=                                               \
+       ""                                                              \
+       "There was an error during the \`\`configure'' phase."          \
+       "Please investigate the following for more information:"
+.if defined(GNU_CONFIGURE)
+PKG_ERROR_MSG.configure+=                                              \
+       "     * config.log"                                             \
+       "     * ${WRKLOG}"                                              \
+       ""
+.else
+PKG_ERROR_MSG.configure+=                                              \
+       "     * log of the build"                                       \
+       "     * ${WRKLOG}"                                              \
+       ""
+.endif
 ${CONFIGURE_COOKIE}:
 .if ${INTERACTIVE_STAGE:Mconfigure} == "configure" && defined(BATCH)
        @${ECHO} "*** The configuration stage of this package requires user interaction"
@@ -3169,9 +3185,17 @@
        @${TOUCH} ${INTERACTIVE_COOKIE}
        @${FALSE}
 .else
-       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-configure PKG_PHASE=configure
-.endif
-
+       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-configure PKG_PHASE=configure || ${PKG_ERROR_HANDLER.configure}
+.endif
+
+PKG_ERROR_CLASSES+=    build
+PKG_ERROR_MSG.build=   \
+       ""                                                              \
+       "There was an error during the \`\`build'' phase."              \
+       "Please investigate the following for more information:"        \
+       "     * log of the build"                                       \
+       "     * ${WRKLOG}"                                              \
+       ""
 ${BUILD_COOKIE}:
 .if ${INTERACTIVE_STAGE:Mbuild} == "build" && defined(BATCH)
        @${ECHO} "*** The build stage of this package requires user interaction"
@@ -3179,7 +3203,7 @@
        @${TOUCH} ${INTERACTIVE_COOKIE}
        @${FALSE}
 .else
-       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-build PKG_PHASE=build
+       ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-build PKG_PHASE=build || ${PKG_ERROR_HANDLER.build}
 .endif
 
 ${TEST_COOKIE}:
@@ -5145,3 +5169,17 @@
 .if defined(BATCH)
 .  include "../../mk/bulk/bsd.bulk-pkg.mk"
 .endif
+
+# Create a PKG_ERROR_HANDLER shell command for each class listed in
+# PKG_ERROR_CLASSES.  The error handler is meant to be invoked within
+# a make target.
+#
+.for _class_ in ${PKG_ERROR_CLASSES}
+PKG_ERROR_HANDLER.${_class_}?= {                                       \
+               ec=$$?;                                                 \
+               for str in ${PKG_ERROR_MSG.${_class_}}; do              \
+                       ${ECHO} "${_PKGSRC_IN}> $$str";                 \
+               done;                                                   \
+               exit $$ec;                                              \
+       }
+.endfor



Home | Main Index | Thread Index | Old Index