Subject: Re: Nuking install_sh=... and friends
To: None <tech-pkg@NetBSD.org>
From: Johnny C. Lam <jlam@pkgsrc.org>
List: tech-pkg
Date: 06/20/2007 16:15:04
--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Wed, Jun 20, 2007 at 04:09:28PM +0000, Johnny C. Lam wrote:
> 
> The attached patch does the following:
> 
> (1) Removes install_sh from the CONFIGURE_ENV variable.
> 
> (2) Removes creation of an install-sh tool in ${TOOLS_DIR}.
> 
> (3) Replaces any install-sh script under ${WRKSRC} with the one from
>     sysutils/install-sh, which is correct for our pkgsrc platforms
>     and which also passes the BSD install regresion tests.

And the patch...

	Cheers,

	-- Johnny Lam <jlam@pkgsrc.org>

--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="install-sh.diff"

Index: configure/bsd.configure-vars.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/configure/bsd.configure-vars.mk,v
retrieving revision 1.3
diff -u -r1.3 bsd.configure-vars.mk
--- configure/bsd.configure-vars.mk	4 Jun 2007 12:10:20 -0000	1.3
+++ configure/bsd.configure-vars.mk	20 Jun 2007 15:42:06 -0000
@@ -25,8 +25,3 @@
 SCRIPTS_ENV+=	WRKDIR=${WRKDIR}
 SCRIPTS_ENV+=	WRKSRC=${WRKSRC}
 SCRIPTS_ENV+=	X11BASE=${X11BASE}
-
-.if defined(GNU_CONFIGURE)
-TOOLS_CREATE+=	install_sh
-TOOLS_SCRIPT.install_sh=	${INSTALL} "$$@"
-.endif
Index: configure/configure.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/configure/configure.mk,v
retrieving revision 1.17
diff -u -r1.17 configure.mk
--- configure/configure.mk	15 Mar 2007 22:54:24 -0000	1.17
+++ configure/configure.mk	20 Jun 2007 15:42:07 -0000
@@ -53,6 +53,9 @@
 .if defined(OVERRIDE_GNU_CONFIG_SCRIPTS)
 .  include "${PKGSRCDIR}/mk/configure/config-override.mk"
 .endif
+.if defined(INSTALL_SH_OVERRIDE)
+.  include "${PKGSRCDIR}/mk/configure/install-sh-override.mk"
+.endif
 .if defined(USE_LIBTOOL)
 .  include "${PKGSRCDIR}/mk/configure/libtool-override.mk"
 .endif
Index: configure/gnu-configure.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/configure/gnu-configure.mk,v
retrieving revision 1.4
diff -u -r1.4 gnu-configure.mk
--- configure/gnu-configure.mk	4 Jun 2007 12:10:20 -0000	1.4
+++ configure/gnu-configure.mk	20 Jun 2007 15:42:07 -0000
@@ -9,10 +9,10 @@
 
 HAS_CONFIGURE=			defined
 OVERRIDE_GNU_CONFIG_SCRIPTS=	defined
+INSTALL_SH_OVERRIDE?=		# empty
 
 CONFIGURE_ENV+=	CONFIG_SHELL=${CONFIG_SHELL:Q}
 CONFIGURE_ENV+=	LIBS=${LIBS:M*:Q}
-CONFIGURE_ENV+=	install_sh=${TOOLS_CMD.install_sh:Q}
 CONFIGURE_ENV+=	ac_given_INSTALL=${INSTALL:Q}\ -c\ -o\ ${BINOWN}\ -g\ ${BINGRP}
 
 .if (defined(USE_LIBTOOL) || !empty(PKGPATH:Mdevel/libtool-base)) && \
Index: configure/install-sh-override.mk
===================================================================
RCS file: configure/install-sh-override.mk
diff -N configure/install-sh-override.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ configure/install-sh-override.mk	20 Jun 2007 15:42:07 -0000
@@ -0,0 +1,44 @@
+# $NetBSD$
+
+######################################################################
+### install-sh-override (PRIVATE)
+######################################################################
+### install-sh-override replace any existing install-sh under
+### ${WRKSRC} with the version from sysutils/install-sh, which works
+### on all pkgsrc platforms, in particular Interix.
+###
+do-configure-pre-hook: install-sh-override
+
+OVERRIDE_DIRDEPTH.install-sh?=	${OVERRIDE_DIRDEPTH}
+
+_SCRIPT.install-sh-override=						\
+	${RM} -f $$file;						\
+	${SED} -e "s|@DEFAULT_INSTALL_MODE@|${PKGDIRMODE}|g"		\
+		${PKGSRCDIR}/sysutils/install-sh/files/install-sh.in	\
+		> $$file;						\
+	${CHMOD} +x $$file
+
+.PHONY: install-sh-override
+install-sh-override:
+	@${STEP_MSG} "Replacing install-sh with pkgsrc version"
+.if defined(INSTALL_SH_OVERRIDE) && !empty(INSTALL_SH_OVERRIDE)
+	${_PKG_SILENT}${_PKG_DEBUG}set -e;				\
+	cd ${WRKSRC};							\
+	set -- dummy ${INSTALL_SH_OVERRIDE}; shift;			\
+	while [ $$# -gt 0 ]; do						\
+		file="$$1"; shift;					\
+		[ -f "$$file" ] || [ -h "$$file" ] || continue;		\
+		${_SCRIPT.${.TARGET}};					\
+	done
+.else
+	${_PKG_SILENT}${_PKG_DEBUG}set -e;				\
+	cd ${WRKSRC};							\
+	depth=0; pattern=install-sh;					\
+	while [ $$depth -le ${OVERRIDE_DIRDEPTH.install-sh} ]; do	\
+		for file in $$pattern; do				\
+			[ -f "$$file" ] || [ -h "$$file" ] || continue;	\
+			${_SCRIPT.${.TARGET}};				\
+		done;							\
+		depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern";	\
+	done
+.endif

--2oS5YaxWCcQjTEyO--