Subject: pkg/19690: non-portable shell constructs in buildink2 libtool scripts
To: None <gnats-bugs@gnats.netbsd.org>
From: None <fcusack@fcusack.com>
List: netbsd-bugs
Date: 01/05/2003 00:57:11
>Number:         19690
>Category:       pkg
>Synopsis:       non-portable shell constructs in buildink2 libtool scripts
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 05 00:58:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Frank Cusack
>Release:        NetBSD 1.6
>Organization:
>Environment:
System: NetBSD moltar.savecore.net 1.6 NetBSD 1.6 (moltar) #16: Sun Nov 17 22:42:13 PST 2002 root@moltar.savecore.net:/usr/src/sys/arch/sparc64/compile/moltar sparc64
Architecture: sparc64
Machine: sparc64
>Description:
	`if ! command' is not portable (bourne shell does not treat `!'
	as logical NOT).  I ranked it non-critical, but really
	I don't know how serious the effects are.  For NetBSD, this patch
	is meaningless.  For systems with a conforming bourne shell,
	libtool-fix-la fails.  Libraries seem to be built just fine, though.

	The buildlink/libtool script uses /bin/ksh on my system (#! line),
	which would take care of it except that libtool is generally called
	as "/bin/sh /path/to/libtool" so the #! shell is ignored.
>How-To-Repeat:
	Build a library with libtool, eg libiconv.
>Fix:
--- pkgsrc/mk/buildlink2/fake-la.orig	Sun Dec 22 11:02:44 2002
+++ pkgsrc/mk/buildlink2/fake-la	Sun Jan  5 00:29:56 2003
@@ -21,7 +21,7 @@
 libname=`${BASENAME} $reallib`
 tmpdir=${BUILDLINK_DIR}/.tmp
 
-if ! ${TEST} -f $tmpdir/inst/$libbase.la; then
+if ${TEST} ! -f $tmpdir/inst/$libbase.la; then
 	case $libname in
 	*.so.[0-9]*)
 		libbase=`${ECHO} $libname | ${SED} -e "s/\.so\.[0-9.]*$//"`
--- pkgsrc/mk/buildlink2/libtool-fix-la.orig	Sun Dec 22 11:02:44 2002
+++ pkgsrc/mk/buildlink2/libtool-fix-la	Sun Jan  5 00:29:56 2003
@@ -103,8 +103,10 @@
 			;;
 		esac
 	done
+	@EGREP@ "^#.*modified by buildlink2" $lafile >/dev/null 2>&1
+	ret=$?
 	if @TEST@ -n "$deps" || @TEST@ -n "$relink" && \
-	   ! @EGREP@ "^#.*modified by buildlink2" $lafile >/dev/null 2>&1; then
+	    @TEST@ $ret -ne 0; then
 		@MV@ -f $lafile ${lafile}.blsav
 		if @TEST@ -n "$deps"; then
 			(
@@ -129,8 +131,10 @@
 		@RM@ ${lafile}.tmp
 		@ECHO@ "==> Fixed $lafile" >> $wrapperlog
 	fi
+	@EGREP@ "^#.*modified by buildlink2" $laifile >/dev/null 2>&1
+	ret=$?
 	if @TEST@ -n "$laifile" && @TEST@ -f "$laifile" && \
-	   ! @EGREP@ "^#.*modified by buildlink2" $laifile >/dev/null 2>&1; then
+	    @TEST@ $ret -ne 0; then
 		@SED@	@_BLNK_WRAP_LT_UNTRANSFORM_SED@ \
 			@_BLNK_UNTRANSFORM_SED@ \
 			$laifile > ${laifile}.tmp
>Release-Note:
>Audit-Trail:
>Unformatted: