Subject: pkg/13236: patch for making mk/bsd.buildlink.mk work on Solaris
To: None <gnats-bugs@gnats.netbsd.org>
From: Stoned Elipot <Stoned.Elipot@script.jussieu.fr>
List: netbsd-bugs
Date: 06/18/2001 13:41:00
>Number:         13236
>Category:       pkg
>Synopsis:       mk/bsd.buildlink.mk does not work on Solaris
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 18 04:39:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Stoned Elipot
>Release:        pkgsrc-current
>Organization:
SCRIPT, Paris VII University, France
>Environment:
SunOS tzolkin 5.8 Generic_108528-06 sun4u sparc SUNW,Ultra-5_10
SunOS pok-a-tok 5.7 Generic_106541-12 sun4u sparc
>Description:
Solaris /bin/sh lacks parameter expansion ${parameter%word}, ${parameter%%word},
${parameter#word} and ${parameter##word}. mk/bsd.buildlink.mk uses
${parameter##word}and ${parameter%word}.
>How-To-Repeat:
On Solaris with zoularis installed, try to build any package with a Makefile 
including ../../what/ever/buildlink.mk
>Fix:
Patch proposition : sed and dirname used to replace occurence of 
${parameter##word} and ${parameter%word} in mk/bsd.buildlink.mk, DIRNAME 
introduced in mk/defs.{Linux,NetBSD,SunOS}.mk

Index: bsd.buildlink.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.buildlink.mk,v
retrieving revision 1.8
diff -u -r1.8 bsd.buildlink.mk
--- bsd.buildlink.mk	2001/06/18 05:07:40	1.8
+++ bsd.buildlink.mk	2001/06/18 11:36:36
@@ -101,13 +101,14 @@
 	if [ ! -f $${cookie} ]; then					\
 		${ECHO_MSG} "Linking ${.TARGET:S/-buildlink//} files into ${BUILDLINK_DIR}."; \
 		for file in ${BUILDLINK_FILES.${.TARGET:S/-buildlink//}:S/^/${BUILDLINK_PREFIX.${.TARGET:S/-buildlink//}}\//g}; do \
+			prefixless_file=`${ECHO} $${file} | ${SED} -e 's|${BUILDLINK_PREFIX.${.TARGET:S/-buildlink//}}/||` ; \
 			if [ -z "${BUILDLINK_TRANSFORM.${.TARGET:S/-buildlink//}:Q}" ]; then \
-				dest=${BUILDLINK_DIR}/$${file##${BUILDLINK_PREFIX.${.TARGET:S/-buildlink//}}/}; \
+				dest=${BUILDLINK_DIR}/$${prefixless_file}; \
 			else						\
-				dest=`${ECHO} ${BUILDLINK_DIR}/$${file##${BUILDLINK_PREFIX.${.TARGET:S/-buildlink//}}/} | ${SED} ${BUILDLINK_TRANSFORM.${.TARGET:S/-buildlink//}}`; \
+				dest=`${ECHO} ${BUILDLINK_DIR}/$${prefixless_file} | ${SED} ${BUILDLINK_TRANSFORM.${.TARGET:S/-buildlink//}}`; \
 			fi;						\
 			if [ -f $${file} ]; then			\
-				${MKDIR} $${dest%/*};			\
+				${MKDIR} `${DIRNAME} $${dest}`;		\
 				${RM} -f $${dest};			\
 				${LN} -sf $${file} $${dest};		\
 			fi;						\
Index: defs.Linux.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.Linux.mk,v
retrieving revision 1.3
diff -u -r1.3 defs.Linux.mk
--- defs.Linux.mk	2001/06/13 18:19:52	1.3
+++ defs.Linux.mk	2001/06/18 11:36:37
@@ -11,6 +11,7 @@
 CP?=		/bin/cp
 CUT?=		/bin/cut
 DC?=		/usr/bin/dc
+DIRNAME?=	/bin/dirname
 ECHO?=		/bin/echo
 EGREP?=		/bin/egrep
 FALSE?=		/bin/false
Index: defs.NetBSD.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.NetBSD.mk,v
retrieving revision 1.2
diff -u -r1.2 defs.NetBSD.mk
--- defs.NetBSD.mk	2001/06/12 13:16:09	1.2
+++ defs.NetBSD.mk	2001/06/18 11:36:37
@@ -11,6 +11,7 @@
 CP?=		/bin/cp
 CUT?=		/usr/bin/cut
 DC?=		/usr/bin/dc
+DIRNAME?=	/usr/bin/dirname
 ECHO?=		echo				# Shell builtin
 EGREP?=		/usr/bin/egrep
 FALSE?=		false				# Shell builtin
Index: defs.SunOS.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.SunOS.mk,v
retrieving revision 1.2
diff -u -r1.2 defs.SunOS.mk
--- defs.SunOS.mk	2001/06/12 13:16:09	1.2
+++ defs.SunOS.mk	2001/06/18 11:36:37
@@ -11,6 +11,7 @@
 CP?=		/usr/bin/cp
 CUT?=		/usr/bin/cut
 DC?=		/usr/bin/dc
+DIRNAME?=	/usr/bin/dirname
 ECHO?=		/usr/ucb/echo
 EGREP?=		/usr/xpg4/bin/egrep
 FALSE?=		/usr/bin/false
>Release-Note:
>Audit-Trail:
>Unformatted: