Subject: Re: 3.1 cross-build breaks with . in PATH
To: NetBSD Toolchain and Build Technical Discussion List <>
From: Greg A. Woods <>
List: tech-toolchain
Date: 03/20/2007 16:38:31
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Mon, 19 Mar 2007, der Mouse wrote:
> I just tried to cross-build hpcmips on i386.  For reasons not really
> relevant here, I happened to have . early in my PATH when I did this.
> The build broke
> mv: 1: Syntax error: "(" unexpected
> [cascade of failures up to the top level, snipped]
> Yes, having . in the path is arguably a bad idea in general, and I
> wouldn't be too surprised if a build refused to run under those
> circumstances.  But this is definitely not a correct way for it to
> fail, it seems to me.

Actually IMNSHO the problem is more that the system build allows the
process environment of the invoking user to influence its behaviour.

For a long time now I've been making changes to the tool and build
infrastructure of both system and pkgsrc builds to ensure that the
invoker's environment is always entirely discarded and that only the
desired and necessary environment variables are ever set.

If there's been one thing that's been a consistent problem since the
epoch and perhaps before it is the unexpected and unintended effect of
the builder's "environment" on software builds.  Good software
construction hygiene necessitates that all aspects of the build be
entirely controlled by the build tools and infrastructure.

For example my wrapper script for starts out with:

#! /bin/ksh

# make sure we start out with a very clean environment!
if [ -z "$MYBUILD_CLEAN" ]; then
	exec env -i USER=3D${USER} SHELL=3D/bin/ksh MYBUILD_CLEAN=3Dtrue "$0" ${1+=

# for NetBSD this should be sufficient....
export PATH=3D/bin:/usr/bin

For the final "make iso-image" step I add $PREFIX/bin and
$PREFIX/sbin to the path to access the pkg'ed mkisofs tools.

Index: Makefile
RCS file: /cvs/master/m-NetBSD/main/src/Makefile,v
retrieving revision
diff -u -r1.246.2.1 Makefile
--- Makefile	9 Mar 2007 06:59:37 -0000
+++ Makefile	11 Mar 2007 19:54:42 -0000
@@ -315,7 +315,8 @@
 iso-image: .PHONY
 	${MAKEDIRTARGET} distrib iso_image
-	${MAKEDIRTARGET} etc iso-image
+	# XXX can't use MAKEDIRTARGET as it has no way to set PATH for us!
+	(cd ${.CURDIR}/etc && env PATH=3D/sbin:/usr/sbin:/usr/pkg/sbin:$$PATH ${M=
AKE} $@)
 	@echo   "make ${.TARGET} started at:  ${START_TIME}"
 	@printf "make ${.TARGET} finished at: " && date

There may be other little tweaks I've had to make, but I think only in
the pkgsrc infrastructure, not the system build.

						Greg A. Woods

H:+1 416 218-0098 W:+1 416 489-5852 x122 VE3TCP RoboHack <>
Planix, Inc. <>       Secrets of the Weird <>

Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

Version: PGPfreeware 5.0i for non-commercial use
MessageID: PwEmoEmNkkSje7fSTBCAPjSDM7ACJUia