Subject: Re: 3.1 cross-build breaks with . in PATH
To: NetBSD Toolchain and Build Technical Discussion List <tech-toolchain@NetBSD.org>
From: Greg A. Woods <woods@planix.com>
List: tech-toolchain
Date: 03/20/2007 16:38:31
--pgp-sign-Multipart_Tue_Mar_20_16:38:29_2007-1
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
>=20
> mv: 1: Syntax error: "(" unexpected
> [cascade of failures up to the top level, snipped]
>=20
> 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 build.sh 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+=
"$@"}
fi

# 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/master/m-NetBSD/main/src/Makefile,v
retrieving revision 1.246.2.1
diff -u -r1.246.2.1 Makefile
--- Makefile	9 Mar 2007 06:59:37 -0000	1.246.2.1
+++ Makefile	11 Mar 2007 19:54:42 -0000
@@ -315,7 +315,8 @@
=20
 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
=20



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


--=20
						Greg A. Woods

H:+1 416 218-0098 W:+1 416 489-5852 x122 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>       Secrets of the Weird <woods@weird.com>

--pgp-sign-Multipart_Tue_Mar_20_16:38:29_2007-1
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

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

iQA/AwUBRgBGR2Z9cbd4v/R/EQJpSgCfYoFXZmBYNPgAtqtrUN0zzkU6vIgAoPvQ
Cl8upJs+G5MBda+ATpZAH5lr
=v6yv
-----END PGP SIGNATURE-----

--pgp-sign-Multipart_Tue_Mar_20_16:38:29_2007-1--