Subject: pkgsrc error messages
To: None <tech-pkg@NetBSD.org>
From: Johnny C. Lam <jlam@NetBSD.org>
List: tech-pkg
Date: 01/10/2005 06:51:05
--LQksG6bCIzRHxTLp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
I'm frustrated with users reporting problems without providing enough
information upfront. It's frustrating because there are times that
I'd like to help, but can't spare the time to have a dialogue with the
bug reporter. Also, I feel that there are many smart users that have
the ability to begin debugging the problems themselves if they just
knew where to look.
I'd like to remedy this by making pkgsrc prompt the user for the proper
debugging information to submit. Please review the attached patch,
which adds the notion of error messages to make targets. I'm sure that
we could improve on the error message themselves in the future, so I'm
more concerned with whether this idea is worthwhile, and whether this
implementation is good enough for our needs.
Cheers,
-- Johnny Lam <jlam@NetBSD.org>
--LQksG6bCIzRHxTLp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="error.diff"
Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1552
diff -u -r1.1552 bsd.pkg.mk
--- bsd.pkg.mk 31 Dec 2004 13:13:56 -0000 1.1552
+++ bsd.pkg.mk 10 Jan 2005 06:42:02 -0000
@@ -3164,6 +3164,14 @@
${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:" \
+ " * config.log" \
+ " * ${WRKLOG}" \
+ ""
${CONFIGURE_COOKIE}:
.if ${INTERACTIVE_STAGE:Mconfigure} == "configure" && defined(BATCH)
@${ECHO} "*** The configuration stage of this package requires user interaction"
@@ -3171,9 +3179,17 @@
@${TOUCH} ${INTERACTIVE_COOKIE}
@${FALSE}
.else
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-configure PKG_PHASE=configure
+ ${_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"
@@ -3181,7 +3197,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}:
@@ -5147,3 +5163,16 @@
.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.
+#
+.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
--LQksG6bCIzRHxTLp--