Subject: [patch] Unified progress and error messages
To: None <tech-pkg@netbsd.org>
From: Roland Illig <rillig@NetBSD.org>
List: tech-pkg
Date: 02/18/2006 22:01:14
This is a multi-part message in MIME format.
--------------020906030209060508030601
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

currently the use of progress messages in pkgsrc is not as consistent as 
it could be. For example:

===> Checking for vulnerabilities in pkglint-4.57
===> Extracting for pkglint-4.57
===> Required installed package digest>=20010101: digest-20050731 found
===> Required installed package perl>=5.0: perl-5.8.7nb8 found
===> Patching for pkglint-4.57
===> Overriding tools for pkglint-4.57
===> Configuring for pkglint-4.57
=> Setting compile-time constants for pkglint.
===> Installing for pkglint-4.57
===> Creating installation directories
===> [Automatic manual page handling]
===> Registering installation for pkglint-4.57
===> Checking for work-directory references in pkglint-4.57
===> Checking for non-existent script interpreters in pkglint-4.57
===> Packaging pkglint-4.57
===> Building binary package for pkglint-4.57

As you can see, there are two different leaders for messages. One for 
the "big" steps (called "phases" in the pkgsrc guide), and one for the 
"small" steps (called "steps" in the pkgsrc guide).

The inconsistency lies in the usage of the "big" and the "small" 
leaders. Checking if the package perl>=5.0 is installed is not a phase, 
but has the same leader. So I suggest to change the above to look like:

===> Checking for vulnerabilities in pkglint-4.57
===> Extracting for pkglint-4.57
=> Required installed package digest>=20010101: digest-20050731 found
=> Required installed package perl>=5.0: perl-5.8.7nb8 found
===> Patching for pkglint-4.57
===> Overriding tools for pkglint-4.57
===> Configuring for pkglint-4.57
=> Setting compile-time constants for pkglint.
===> Installing for pkglint-4.57
=> Creating installation directories
=> [Automatic manual page handling]
=> Registering installation for pkglint-4.57
=> Checking for work-directory references in pkglint-4.57
=> Checking for non-existent script interpreters in pkglint-4.57
===> Packaging pkglint-4.57
=> Building binary package for pkglint-4.57

But that's not all. Currently pkgsrc is lacking many plausibility checks 
that cannot be done by static analyzers like pkglint. There are many 
places where warnings should be given instead of just ignoring the 
erroneous state. To make the appearance of these warnings consistent, 
I'd like to add two more variables: WARNING_MSG and ERROR_MSG. These 
variables make printing warnings and error messages much more 
convenient, as the warnings are automatically redirected to stderr 
instead of stdout. Additionally, if they are used consistently, all the 
warnings and errors from bulk builds can be extracted easily and be 
included in the final report. Currently we get no feed-back whether a 
package has built cleanly or if it sailed near the wind. (For example, 
the SUBST framework already prints warnings, but no-one gets to see them 
by now.)

Roland

--------------020906030209060508030601
Content-Type: text/plain;
 name="messages.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="messages.patch"

Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1799
diff -u -p -r1.1799 bsd.pkg.mk
--- bsd.pkg.mk	18 Feb 2006 15:37:22 -0000	1.1799
+++ bsd.pkg.mk	18 Feb 2006 20:43:18 -0000
@@ -533,6 +533,10 @@ _PKGSRC_IN?=		===${SMART_MESSAGES:D> ${.
 
 # Used to print all the '===>' style prompts - override this to turn them off.
 ECHO_MSG?=		${ECHO}
+PHASE_MSG?=		${ECHO_MSG} ${_PKGSRC_IN:Q}\>
+STEP_MSG?=		${ECHO_MSG} "=>"
+WARNING_MSG?=		${ECHO_MSG} 1>&2 "WARNING:"
+ERROR_MSG?=		${ECHO_MSG} 1>&2 "ERROR:"
 
 # How to do nothing.  Override if you, for some strange reason, would rather
 # do something.

--------------020906030209060508030601--