Subject: Re: Message for registering info files necessary?
To: Julio M. Merino Vidal <jmmv84@gmail.com>
From: Johnny C. Lam <jlam@pkgsrc.org>
List: tech-pkg
Date: 06/25/2007 22:29:49
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sat, Jun 23, 2007 at 09:44:02AM +0200, Julio M. Merino Vidal wrote:
> On 23/06/2007, at 0:49, Thomas Klausner wrote:
> 
> >Hi!
> >
> >Do we really need these messages?
> >
> >====================================================================== 
> >=====
> >Registering info files for gnucash-2.0.5nb5:
> >
> >        /usr/pkg/info/gnucash-design.info
> >
> >====================================================================== 
> >=====
> >
> >The user won't care, the admin usually won't care either, perhaps the
> >packager cares to make sure he didn't forget adding the appropriate
> >line.
> >I think we can silence it by default, and perhaps enable it for
> >PKG_DEVELOPER if someone insists.
> 
> Also, if this finally stays in some way... do we really have to have  
> so long messages?  I mean, those ==== and blank lines take a lot of  
> screen space, whereas the same thing could be achieved by printing  
> 'Regitering info file foo for bar-x.y.z.' on a line on its own.
> 
> (Ever tried pkg_add on a package with lots of dependents (e.g.  
> gnome)?  The output is hard to parse visually and is extremely long.)

I have modified the scriptlets to be less verbose in the "add" and
"delete" actions, which are executed at install and deinstall time.
The scriptlets maintain their current verbosity for "check" actions.

The current output looks like the following examples extracted from
installing packages:

./+FILES: copying /usr/pkg/etc/ddclient.conf from /usr/pkg/share/examples/ddclient/sample-etc_ddclient.conf for ddclient-3.6.6

./+INFO_FILES: registering info file /usr/pkg/share/info/make.info for gmake-3.81

I've included the name of the scriptlet as the first part of the output
so that it's obvious what script is being executed that is performing
the actions.  This output should mix in more harmoniously with pkg_add
and pkg_delete output.

I've attached a patch that keeps the PKGINSTALL_VERBOSE change from
before and includes these new changes to the scriptlets.

If there are no objections, I'd like to commit this after the branch
is cut.

Thoughts?  Perhaps better suggestions for the one-line output in place
of the ones I've put into the scriptlets?

	Cheers,

	-- Johnny Lam <jlam@pkgsrc.org>

--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pkginstall.diff"

Index: mk/pkginstall/bsd.pkginstall.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/bsd.pkginstall.mk,v
retrieving revision 1.25
diff -u -r1.25 bsd.pkginstall.mk
--- mk/pkginstall/bsd.pkginstall.mk	15 Jun 2007 22:04:33 -0000	1.25
+++ mk/pkginstall/bsd.pkginstall.mk	25 Jun 2007 22:20:09 -0000
@@ -5,6 +5,18 @@
 # framework, simply set the relevant variables to customize the install
 # scripts to the package.
 #
+# User-settable variables:
+#
+# PKGINSTALL_VERBOSE:
+#	A list of scriptlets that will be verbose and output a message
+#	noting the actions taken.
+#
+#	* "all" is a special value that implies all of the other items
+#	* "fonts" for +FONTS
+#	* "info-files" for +INFO_FILES
+#
+#	Default value: "all" for PKG_DEVELOPERs, empty otherwise.
+#
 
 # The Solaris /bin/sh does not know the ${foo#bar} shell substitution.
 # This shell function serves a similar purpose, but is specialized on
@@ -809,6 +821,22 @@
 FILES_SUBST+=		PKG_REGISTER_SHELLS=${PKG_REGISTER_SHELLS:Q}
 FILES_SUBST+=		PKG_UPDATE_FONTS_DB=${PKG_UPDATE_FONTS_DB:Q}
 
+.if defined(PKG_DEVELOPER)
+PKGINSTALL_VERBOSE?=	all
+.else
+PKGINSTALL_VERBOSE?=	# empty
+.endif
+.if !empty(PKGINSTALL_VERBOSE:Mall) || !empty(PKGINSTALL_VERBOSE:Mfonts)
+FILES_SUBST+=		FONTS_VERBOSE=yes
+.else
+FILES_SUBST+=		FONTS_VERBOSE=no
+.endif
+.if !empty(PKGINSTALL_VERBOSE:Mall) || !empty(PKGINSTALL_VERBOSE:Minfo-files)
+FILES_SUBST+=		INFO_FILES_VERBOSE=yes
+.else
+FILES_SUBST+=		INFO_FILES_VERBOSE=no
+.endif
+
 # Substitute for various programs used in the DEINSTALL/INSTALL scripts and
 # in the rc.d scripts.
 #
Index: mk/pkginstall/files
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/files,v
retrieving revision 1.3
diff -u -r1.3 files
--- mk/pkginstall/files	15 Dec 2006 13:15:06 -0000	1.3
+++ mk/pkginstall/files	25 Jun 2007 22:20:09 -0000
@@ -118,7 +118,7 @@
 case $ACTION in
 ADD)
 	${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -u |
-	{ while read file f_flags f_eg f_mode f_user f_group; do
+	while read file f_flags f_eg f_mode f_user f_group; do
 		case $file in
 		"")	continue ;;
 		[!/]*)	file="${PKG_PREFIX}/$file" ;;
@@ -157,20 +157,10 @@
 		else
 			case "$f_flags:$_PKG_CONFIG:$_PKG_RCD_SCRIPTS" in
 			*f*:*:*|[!r]:yes:*|[!r][!r]:yes:*|[!r][!r][!r]:yes:*|*r*:yes:yes)
-				case "$printed_header" in
-				yes)	;;
-				*)	printed_header=yes
-					${ECHO} "==========================================================================="
-					${ECHO} "Installing files needed by ${PKGNAME}:"
-					;;
-				esac
 				if ${TEST} -f "$file"; then
-					${ECHO} ""
-					${ECHO} "	$file already exists."
+					${ECHO} "$SELF: $file already exists for ${PKGNAME}"
 				elif ${TEST} -f "$f_eg"; then
-					${ECHO} ""
-					${ECHO} "	$file"
-					${ECHO} "	    [$f_eg]"
+					${ECHO} "$SELF: copying $file from $f_eg for ${PKGNAME}"
 					${CP} $f_eg $file
 					case $f_user in
 					"")	;;
@@ -189,11 +179,6 @@
 			esac
 		fi
 	done
-	case "$printed_header" in
-	yes)	${ECHO} ""
-		${ECHO} "==========================================================================="
-		;;
-	esac; }
 	;;
 
 REMOVE)
Index: mk/pkginstall/fonts
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/fonts,v
retrieving revision 1.4
diff -u -r1.4 fonts
--- mk/pkginstall/fonts	2 Jan 2007 11:47:26 -0000	1.4
+++ mk/pkginstall/fonts	25 Jun 2007 22:20:09 -0000
@@ -56,8 +56,17 @@
 	;;
 esac
 
+case "${FONTS_VERBOSE:-@FONTS_VERBOSE@}" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+	echo="${ECHO}"
+	;;
+[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
+	echo=":"
+	;;
+esac
+
 ${SED} -n "/^\# FONTS: /{s/^\# FONTS: //;p;}" ${SELF} | ${SORT} -u |
-{ while read dir font_type; do
+while read dir font_type; do
 	case ${_PKG_UPDATE_FONTS_DB} in
 	no)	continue ;;
 	esac
@@ -66,15 +75,7 @@
 	[!/]*)	dir="${PKG_PREFIX}/$dir" ;;
 	esac
 	${TEST} -d "$dir" || continue
-	case "$printed_header" in
-	yes)	;;
-	*)	printed_header=yes
-		${ECHO} "==========================================================================="
-		${ECHO} "Updating font databases in the following directories:"
-		${ECHO} ""
-		;;
-	esac
-	( ${ECHO} "	$dir ($font_type)"
+	( $echo "$SELF: updating font database in $dir ($font_type)"
 	  cd $dir
 	  update_args=
 	  post_update_cmd=
@@ -96,11 +97,6 @@
 	  ${FIND} . -type f | ${GREP} -v "/encodings.dir" | ${GREP} -v "/fonts\.scale" | ${GREP} -v "/fonts\.dir" | ${GREP} -v "/Fontmap" >/dev/null || ${RM} -f fonts.dir fonts.scale Fontmap* encodings.dir > /dev/null
 	)
 done
-case "$printed_header" in
-yes)	${ECHO} ""
-	${ECHO} "==========================================================================="
-	;;
-esac; }
 
 EOF
 	${SED} -n "/^\# FONTS: /p" ${SELF} >> ./+FONTS
Index: mk/pkginstall/info-files
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/info-files,v
retrieving revision 1.3
diff -u -r1.3 info-files
--- mk/pkginstall/info-files	29 Dec 2006 07:06:31 -0000	1.3
+++ mk/pkginstall/info-files	25 Jun 2007 22:20:09 -0000
@@ -48,11 +48,20 @@
 : ${PKGNAME=${PKG_METADATA_DIR##*/}}
 : ${PKG_PREFIX=@PREFIX@}
 
+case "${INFO_FILES_VERBOSE:-@INFO_FILES_VERBOSE@}" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+	echo="${ECHO}"
+	;;
+[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
+	echo=":"
+	;;
+esac
+
 exitcode=0
 case $ACTION in
 ADD)
 	${SED} -n "/^\# INFO: /{s/^\# INFO: //;p;}" ${SELF} | ${SORT} -u |
-	{ while read file infodir; do
+	while read file infodir; do
 		case $file in
 		"")	continue ;;
 		[!/]*)	file="${PKG_PREFIX}/$file" ;;
@@ -61,15 +70,6 @@
 		if ${TEST} ! -f "$file"; then
 			:
 		else
-			case "$printed_header" in
-			yes)	;;
-			*)	printed_header=yes
-				${ECHO} "==========================================================================="
-				${ECHO} "Registering info files for ${PKGNAME}:"
-				${ECHO} ""
-				;;
-			esac
-
 			case $infodir in
 			"")	infodir="${file%/*}" ;;
 			[!/]*)	infodir="${PKG_PREFIX}/$infodir" ;;
@@ -79,22 +79,17 @@
 			case "$nentries" in
 			[0-9]*)	${TEST} $nentries -gt 0 || ${RM} $infoindex ;;
 			esac
-			${ECHO} "	$file"
+			$echo "$SELF: registering info file $file for ${PKGNAME}"
 			${MKDIR} -p "$infodir"
 			${INSTALL_INFO} --info-dir="$infodir" --delete $file >/dev/null 2>&1
 			${INSTALL_INFO} --info-dir="$infodir" $file >/dev/null 2>&1
 		fi
 	done
-	case "$printed_header" in
-	yes)	${ECHO} ""
-		${ECHO} "==========================================================================="
-		;;
-	esac; }
 	;;
 
 REMOVE)
 	${SED} -n "/^\# INFO: /{s/^\# INFO: //;p;}" ${SELF} | ${SORT} -u |
-	{ while read file infodir; do
+	while read file infodir; do
 		case $file in
 		"")	continue ;;
 		[!/]*)	file="${PKG_PREFIX}/$file" ;;
@@ -103,21 +98,12 @@
 		if ${TEST} ! -f "$file"; then
 			:
 		else
-			case "$printed_header" in
-			yes)	;;
-			*)	printed_header=yes
-				${ECHO} "==========================================================================="
-				${ECHO} "Unregistering info files for ${PKGNAME}:"
-				${ECHO} ""
-				;;
-			esac
-
 			case $infodir in
 			"")	infodir="${file%/*}" ;;
 			[!/]*)	infodir="${PKG_PREFIX}/$infodir" ;;
 			esac
 			infoindex="$infodir/dir"
-			${ECHO} "	$file"
+			$echo "$SELF: unregistering info file $file for ${PKGNAME}"
 			${INSTALL_INFO} --info-dir="$infodir" --delete $file >/dev/null 2>&1
 			nentries="`${GREP} -c '^\*' $infoindex 2>/dev/null`"
 			case "$nentries" in
@@ -126,11 +112,6 @@
 			${RMDIR} -p "$infodir" 2>/dev/null || ${TRUE}
 		fi
 	done
-	case "$printed_header" in
-	yes)	${ECHO} ""
-		${ECHO} "==========================================================================="
-		;;
-	esac; }
 	;;
 esac
 exit $exitcode
Index: mk/pkginstall/perms
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/perms,v
retrieving revision 1.2
diff -u -r1.2 perms
--- mk/pkginstall/perms	19 Jul 2006 22:26:26 -0000	1.2
+++ mk/pkginstall/perms	25 Jun 2007 22:20:09 -0000
@@ -42,35 +42,28 @@
 : ${PKG_PREFIX=@PREFIX@}
 
 ${SED} -n "/^\# PERMS: /{s/^\# PERMS: //;p;}" ${SELF} | ${SORT} -u |
-{ while read file f_mode f_user f_group; do
+while read file f_mode f_user f_group; do
 	case $file in
 	"")	continue ;;
 	[!/]*)	file="${PKG_PREFIX}/$file" ;;
 	esac
 	${TEST} -f "$file" || continue
-	case "$printed_header" in
-	yes)	;;
-	*)	printed_header=yes
-		${ECHO} "==========================================================================="
-		${ECHO} "The following files and directories needed by ${PKGNAME}"
-		${ECHO} "have special permissions:"
-		${ECHO} ""
-		;;
-	esac
+	filemsg=
 	case $f_mode/$f_user/$f_group in
 	//)
-		${ECHO} "	$file"
+		filemsg="$file"
 		;;
 	[!/]*//)
-		${ECHO} "	$file (m=$f_mode)"
+		filemsg="$file (m=$f_mode)"
 		;;
 	[!/]*/[!/]*/)
-		${ECHO} "	$file (o=$f_user, m=$f_mode)"
+		filemsg="$file (o=$f_user, m=$f_mode)"
 		;;
 	[!/]*/[!/]*/[!/]*)
-		${ECHO} "	$file (o=$f_user, g=$f_group, m=$f_mode)"
+		filemsg="$file (o=$f_user, g=$f_group, m=$f_mode)"
 		;;
 	esac
+	${ECHO} "$SELF: special permissions for ${PKGNAME}: $filemsg"
 	case $f_user in
 	"")	;;
 	*)	${CHOWN} $f_user $file ;;
@@ -84,11 +77,6 @@
 	*)	${CHMOD} $f_mode $file ;;
 	esac
 done
-case "$printed_header" in
-yes)	${ECHO} ""
-	${ECHO} "==========================================================================="
-	;;
-esac; }
 
 EOF
 	${SED} -n "/^\# PERMS: /p" ${SELF} >> ./+PERMS
Index: mk/pkginstall/shell
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/shell,v
retrieving revision 1.3
diff -u -r1.3 shell
--- mk/pkginstall/shell	19 Jul 2006 22:26:26 -0000	1.3
+++ mk/pkginstall/shell	25 Jun 2007 22:20:09 -0000
@@ -62,7 +62,7 @@
 case $ACTION in
 ADD)
 	${SED} -n "/^\# SHELL: /{s/^\# SHELL: //;p;}" ${SELF} | ${SORT} -u |
-	{ while read shell; do
+	while read shell; do
 		case ${_PKG_REGISTER_SHELLS} in
 		no)	continue ;;
 		esac
@@ -82,31 +82,18 @@
 		   ${GREP} "^$shell" $shelldb >/dev/null; then
 			:
 		else
-			case "$printed_header" in
-			yes)	;;
-			*)	printed_header=yes
-				${ECHO} "==========================================================================="
-				${ECHO} "Adding ${PKGNAME} shells to $shelldb:"
-				${ECHO} ""
-				;;
-			esac
-			${ECHO} "	$shell"
+			${ECHO} "$SELF: adding $shell from ${PKGNAME} to $shelldb"
                 	${TOUCH} $shelldb
                 	${CP} $shelldb $shelldb.pkgsrc."$$"
 			{ ${CAT} $shelldb.pkgsrc."$$"; ${ECHO} "$shell"; } > $shelldb
                 	${RM} $shelldb.pkgsrc."$$"
 		fi
 	done
-	case "$printed_header" in
-	yes)	${ECHO} ""
-		${ECHO} "==========================================================================="
-		;;
-	esac; }
 	;;
 
 REMOVE)
 	${SED} -n "/^\# SHELL: /{s/^\# SHELL: //;p;}" ${SELF} | ${SORT} -u |
-	{ while read shell; do
+	while read shell; do
 		case ${_PKG_REGISTER_SHELLS} in
 		no)	continue ;;
 		esac
@@ -123,26 +110,13 @@
 		shelldb="/etc/shells"
 		if ${TEST} -f "$shelldb" && \
 		   ${GREP} "^$shell" $shelldb >/dev/null; then
-			case "$printed_header" in
-			yes)	;;
-			*)	printed_header=yes
-				${ECHO} "==========================================================================="
-				${ECHO} "Removing ${PKGNAME} shells from $shelldb:"
-				${ECHO} ""
-				;;
-			esac
-			${ECHO} "	$shell"
+			${ECHO} "$SELF: removing $shell from ${PKGNAME} to $shelldb"
                 	${TOUCH} $shelldb
                 	${CP} $shelldb $shelldb.pkgsrc."$$"
 			{ ${GREP} -v "^$shell" $shelldb.pkgsrc."$$" || ${TRUE}; } > $shelldb
                 	${RM} $shelldb.pkgsrc."$$"
 		fi
 	done
-	case "$printed_header" in
-	yes)	${ECHO} ""
-		${ECHO} "==========================================================================="
-		;;
-	esac; }
 	;;
 
 CHECK-ADD)
Index: mk/pkginstall/usergroupfuncs
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/usergroupfuncs,v
retrieving revision 1.2
diff -u -r1.2 usergroupfuncs
--- mk/pkginstall/usergroupfuncs	15 Dec 2006 13:15:06 -0000	1.2
+++ mk/pkginstall/usergroupfuncs	25 Jun 2007 22:20:09 -0000
@@ -111,7 +111,7 @@
 	: ${shell:="@PKG_USER_SHELL@"}
 
 	if ${TEST} -n "${USERADD}" -a -x "${USERADD}"; then
-		${ECHO} "Creating user: $user"
+		${ECHO} "$SELF: Creating user \`\`$user'' for ${PKGNAME}"
 		case $userid in
 		"")
 			${USERADD}					\
@@ -138,7 +138,7 @@
 	GROUPADD="@GROUPADD@"
 
 	if ${TEST} -n "${GROUPADD}" -a -x "${GROUPADD}"; then
-		${ECHO} "Creating group: $group";
+		${ECHO} "$SELF: Creating group \`\`$group'' for ${PKGNAME}"
 		case $groupid in
 		"")	${GROUPADD} $group ;;
 		*)	${GROUPADD} -g $groupid $group ;;
Index: mk/pkginstall/usergroupfuncs.DragonFly
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/usergroupfuncs.DragonFly,v
retrieving revision 1.2
diff -u -r1.2 usergroupfuncs.DragonFly
--- mk/pkginstall/usergroupfuncs.DragonFly	15 Dec 2006 13:15:06 -0000	1.2
+++ mk/pkginstall/usergroupfuncs.DragonFly	25 Jun 2007 22:20:09 -0000
@@ -103,7 +103,7 @@
 	: ${shell:="@PKG_USER_SHELL@"}
 
 	if ${TEST} -n "${PW}" -a -x "${PW}"; then
-		${ECHO} "Creating user: $user"
+		${ECHO} "$SELF: Creating user \`\`$user'' for ${PKGNAME}"
 		case $userid in
 		"")
 			${PW} useradd					\
@@ -132,7 +132,7 @@
 	PW="@PW@"
 
 	if ${TEST} -n "${PW}" -a -x "${PW}"; then
-		${ECHO} "Creating group: $group";
+		${ECHO} "$SELF: Creating group \`\`$group'' for ${PKGNAME}"
 		case $groupid in
 		"")	${PW} groupadd $group ;;
 		*)	${PW} groupadd $group -g $groupid ;;
Index: mk/pkginstall/usergroupfuncs.FreeBSD
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/usergroupfuncs.FreeBSD,v
retrieving revision 1.2
diff -u -r1.2 usergroupfuncs.FreeBSD
--- mk/pkginstall/usergroupfuncs.FreeBSD	15 Dec 2006 13:15:06 -0000	1.2
+++ mk/pkginstall/usergroupfuncs.FreeBSD	25 Jun 2007 22:20:09 -0000
@@ -103,7 +103,7 @@
 	: ${shell:="@PKG_USER_SHELL@"}
 
 	if ${TEST} -n "${PW}" -a -x "${PW}"; then
-		${ECHO} "Creating user: $user"
+		${ECHO} "$SELF: Creating user \`\`$user'' for ${PKGNAME}"
 		case $userid in
 		"")
 			${PW} useradd					\
@@ -132,7 +132,7 @@
 	PW="@PW@"
 
 	if ${TEST} -n "${PW}" -a -x "${PW}"; then
-		${ECHO} "Creating group: $group";
+		${ECHO} "$SELF: Creating group \`\`$group'' for ${PKGNAME}"
 		case $groupid in
 		"")	${PW} groupadd $group ;;
 		*)	${PW} groupadd $group -g $groupid ;;
Index: mk/pkginstall/usergroupfuncs.Linux
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/usergroupfuncs.Linux,v
retrieving revision 1.2
diff -u -r1.2 usergroupfuncs.Linux
--- mk/pkginstall/usergroupfuncs.Linux	15 Dec 2006 13:15:06 -0000	1.2
+++ mk/pkginstall/usergroupfuncs.Linux	25 Jun 2007 22:20:09 -0000
@@ -103,7 +103,7 @@
 	: ${shell:="@PKG_USER_SHELL@"}
 
 	if ${TEST} -n "${USERADD}" -a -x "${USERADD}"; then
-		${ECHO} "Creating user: $user"
+		${ECHO} "$SELF: Creating user \`\`$user'' for ${PKGNAME}"
 		# if home directory is missing, make and remove it
 		# ensures that the base directory exists, for shadow-utils
 		if ! ${TEST} -d "$home"; then
@@ -136,7 +136,7 @@
 	GROUPADD="@GROUPADD@"
 
 	if ${TEST} -n "${GROUPADD}" -a -x "${GROUPADD}"; then
-		${ECHO} "Creating group: $group";
+		${ECHO} "$SELF: Creating group \`\`$group'' for ${PKGNAME}"
 		case $groupid in
 		"")	${GROUPADD} $group ;;
 		*)	${GROUPADD} -g $groupid $group ;;

--jRHKVT23PllUwdXP--