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 17:13:11
--pgp-sign-Multipart_Tue_Mar_20_17:13:09_2007-1
Content-Type: multipart/mixed;
 boundary="Multipart_Tue_Mar_20_17:13:09_2007-1"

--Multipart_Tue_Mar_20_17:13:09_2007-1
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

At Tue, 20 Mar 2007 16:44:37 -0400 (EDT),
der Mouse wrote:
>=20
> >> mv: 1: Syntax error: "(" unexpected
> >> [cascade of failures up to the top level, snipped]
>=20
> > Actually IMNSHO the problem is more that the system build allows the
> > process environment of the invoking user to influence its behaviour.
>=20
> This is, unfortunately, necessary, and will remain so until all of the
> backdoor arguments passed through the environment move to command-line
> options.  (The ones I'm most aware of, because they're the ones I've
> used recently, are TOOLDIR, NOCLEANDIR, and USETOOLS, but there are
> many more; /usr/src/BUILDING includes a fairly long list.)

Hmmm... I'm not sure I agree, though I admit my needs for controlling
the build infrastructure are relatively limited and well within the
lines already supported by the extremely flexible "build.sh" command
line parameters already supported.

E.g. NOCLEANDIR is essentially the same as "build.sh -u", no?

TOOLDIR is definitely settable with "build.sh -T"

USETOOLS is, it seems to me, mandatory -- as far as I can see you can't
override it -- it is always set to "yes" when using build.sh

I think all the rest can be controlled with "build.sh -V var=3Dvalue"

Attached is the entire wrapper script I currently use for netbsd-4.  It
needs a few other files near the end to create the CD labels, but other
than that it might "just work" as-is.

--=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>


--Multipart_Tue_Mar_20_17:13:09_2007-1
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="mybuild"
Content-Transfer-Encoding: quoted-printable

#! /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

### It may be possible to get rid of the separate install of the
### "-no-g" variant and to include /usr/libdata/debug files everywhere
### by simply setting MKDEBUG=3Dyes and MKDEBUGLIB=3Dyes (and possibly
### also setting COPTS=3D-g (and perhaps deprecate my DBG again too?)

# XXX ksh is needed because of ${var:+$var} quoting bugs
#
#	a wrapper for a wrapper
#
# Install "sysutils/cdrecord" and "graphics/cdlabelgen" first if you
# want to make a CD-ROM!  (may still need sysutils/mksunbootcd?)  Also
# may need pkgtools/cdpack if building packages CDs.
#
# TODO:
#
# Consider implementing an option to do dynamic builds using a "-dyn"
# identifier in the various directory names
#
#
# NOTE:
#
# To build and install something direct to / -- i.e. to patch the host syst=
em:
#
#	. ./myhelpers.ksh
#	eval set$(uname -m)tools
#	nbmake-$(uname -m) MKUNPRIVED=3Dno install DESTDIR=3D/
#
# To do this on a system where you don't normally do full builds
# you'll need to do the following to create a working build
# environment before you can build an individual program:
#
#	./mybuild.sh -L [-u]		# XXX build.sh only does -t
#
# Also, to build a custom kernel use:
#
#	./mybuild.sh -f -k CONFFILE
#

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

argv0=3D$(basename $0)

HOST_MACHINE=3D$(uname -m)
HOSTNAME=3D$(uname -n)

# This identifies the objdir, tooldir, destdir, & releasedir with the
# branch this source tree is checked out from.  I don't use OSRELEASE
# for this because it changes along the branch.
#
MYBRANCH=3D$(sed 's/^T//' CVS/Tag)

# this is used primarily just for the CD labels
#
OSRELEASE=3D$(sh sys/conf/osrelease.sh)

START_DATE=3D$(date '+%Y/%m/%d')

# Normally the workspace will be simply in /build/${USER}/${HOSTNAME}
# regardless of whether that filesystem is local or NFS mounted.
#
# If there is no local disk and you'd rather use the mount point
# directly then, assuming the mount-point is /servername/bulid you can
# set this in your environment:
#
#	BUILD_HOME=3D/${BUILD_NFS_SERVER}/build/${USER}/${HOSTNAME}
#
: ${BUILD_HOME:=3D/build/${USER}/${HOSTNAME}}

if [ ! -d ${BUILD_HOME} ]; then
	mkdir -p ${BUILD_HOME}
	if [ ! -d ${BUILD_HOME} ]; then
		echo "$argv0: BUILD_HOME[${BUILD_HOME}]: not found and cannot be made." 1=
>&2
		exit 1
	fi
fi

DEBUG=3Dfalse
DEBUG_ECHO=3D""
#
# use ${DQ} in front of and after any quoted multi-token parameters on
# command lines that are preceded by "${DEBUG_ECHO} \"
#
DQ=3D""

DO_KERNEL=3D""

OPTIONS=3D"-V MAKECONF=3D\${NETBSDSRCDIR}/etc/mk.conf"

DO_REBUILD=3Dfalse
DO_UPDATE=3Dfalse
NBMAKE_ONLY=3Dfalse
TOOLS_ONLY=3Dfalse
KERN_ONLY=3Dfalse
LIBS_ONLY=3Dfalse
LOG_IT=3Dtrue
NO_CPU_OPTIM=3Dfalse
MKSRCSETS=3Dfalse
MKPKGS=3Dfalse
MKPKGISO=3Dfalse
NO_EXEC=3Dfalse

OPER=3D""

SHOW_NO_G=3D""
SHOW_DESTDIR=3Dfalse
SHOW_OBJDIR=3Dfalse
SHOW_RELEASEDIR=3Dfalse
SHOW_TOOLDIR=3Dfalse

SHOW_UPDATE_DEFAULT=3D""
case $argv0 in
"myupdate.sh")
	if ! cmp $argv0 mybuild.sh; then
		echo "$argv0: the link to mybuild.sh appears to be broken and this copy i=
s different" 1>&2
		exit 3
	fi
	DO_UPDATE=3Dtrue
	OPTIONS=3D"${OPTIONS} -u"
	SHOW_UPDATE_DEFAULT=3D"(default)"
	;;
esac

case ${HOSTNAME} in
"building")
	nJOBS=3D"6"
	;;
"becoming")
	nJOBS=3D"4"
	;;
*)
	nJOBS=3D"1"
	;;
esac

while getopts 'bdfhj:k:m:noprstuxDGHILNORT' opt; do
	case "$opt" in
	"b")
		if ${TOOLS_ONLY}; then
			echo "$argv0: -b (nbmake) is not compatible with -t (tools)" 1>&2
			exit 2
		fi
		if ${LIBS_ONLY}; then
			echo "$argv0: -b (nbmake) is not compatible with -L (libs)" 1>&2
			exit 2
		fi
		NBMAKE_ONLY=3Dtrue
		OPER=3D"makewrapper"
		;;
	"d")
		DEBUG=3Dtrue
		DEBUG_ECHO=3Decho
		DQ=3D"'"
		;;
	"f")
		LOG_IT=3Dfalse
		;;
	"j")
		nJOBS=3D${OPTARG}
		;;
	"k")
		KERN_ONLY=3Dtrue
		OPER=3D"kernel=3D${OPTARG}"
		;;
	"m")
		TARGET_MACHINE=3D${OPTARG}
		;;
	"n")
		NO_EXEC=3Dtrue
		LOG_IT=3Dfalse
		OPTIONS=3D"${OPTIONS} -n"
		;;
	"o")
		OPTIONS=3D"${OPTIONS} -o"
		;;
	"p")
		MKPKGISO=3Dtrue
		;;
	"r")
		if ${DO_UPDATE}; then
			echo "$argv0: -r (rebuild) is not compatible with -u (update)" 1>&2
			exit 2
		fi
		DO_REBUILD=3Dtrue
		OPTIONS=3D"${OPTIONS} -r"
		;;
	"s")
		MKSRCSETS=3Dtrue
		;;
	"t")
		if ${LIBS_ONLY}; then
			echo "$argv0: -t (tools) is not compatible with -L (libs)" 1>&2
			exit 2
		fi
		if ${NBMAKE_ONLY}; then
			echo "$argv0: -t (tools) is not compatible with -b (nbmake)" 1>&2
			exit 2
		fi
		TOOLS_ONLY=3Dtrue
		OPER=3Dtools
		;;
	"u")
		if ${DO_REBUILD}; then
			echo "$argv0: -u (update) is not compatible with -r (rebuild)" 1>&2
			exit 2
		fi
		DO_UPDATE=3Dtrue
		OPTIONS=3D"${OPTIONS} -u"
		;;
	"D")
		SHOW_DESTDIR=3Dtrue
		;;
	"G")
		SHOW_NO_G=3D"-no-g"
		;;
	"H")
		echo ${BUILD_HOME}
		exit 0
		;;
	"L")
		echo "$argv0: -L (libs) is not currently possible" 1>&2
		exit 2
		if ${TOOLS_ONLY}; then
			echo "$argv0: -L (libs) is not compatible with -t (tools)" 1>&2
			exit 2
		fi
		LIBS_ONLY=3Dtrue
		OPER=3Dtools
		;;
	"N")
		NO_CPU_OPTIM=3Dtrue
		;;
	"O")
		SHOW_OBJDIR=3Dtrue
		;;
	"R")
		SHOW_RELEASEDIR=3Dtrue
		;;
	"T")
		SHOW_TOOLDIR=3Dtrue
		;;
	"h")
		cat <<__EOF__
Usage: (one of the following forms)

$argv0 [-m MACHINE] [-G] -[D|H|O|R|T]

	-D	show DESTDIR
	-H	show BUILD_HOME
	-O	show MY_OBJDIR
	-R	show RELEASEDIR
	-T	show TOOLDIR

	-G	show the "-no-g" (debug stripped) variant

$argv0 [-d] [-m MACHINE] -I [-p]

	Make ISO(s) only (assuming RELEASEDIR is complete)

$argv0 [-d] [-m MACHINE] [-u|-r] -[b|t|L|x|k kernconf]

	-b	Build nbmake and nbmake-MACH wrapper script only (to TOOLDIR)
	-t	Build tools only (to TOOLDIR)
	-L	Build libraries only (not implemented)
	-k cnf	Build kernel using cnf as the config file

Common Options:

	-d	debug -- show what would be done (implies -b)
	-f	foreground -- do not redirect output to the log file.
	-m MACH	build for target MACHine (alpha, i386, sparc, sun3, pmax, vax)
	-n	no-execute -- build.sh shows what it would do
	-N	do not use any special CPU optimisations
	-o	Set MKOBJDIRS=3Dno; do not create objdirs at start of build.
	-u	update ${SHOW_UPDATE_DEFAULT}
	-r	Force complete rebuild
	-s	include source sets in RELEASEDIR-no-g/source/sets
	-p	also build a binpkg ISO.

This script needs sysutils/cdrecord and graphics/cdlabelgen to be
installed in order to go all the way to creating a CD-ROM ISO image.
__EOF__
		exit 0
		;;
	*)
		echo "Usage: $argv0 [-do] [-m MACHINE] [-N] [-[D|H|O|R|T] | -I[p] | [-u|-=
r] [ [-t|-L] | [-p] [-X] ] | -x]" 1>&2
		exit 2
		;;
	esac
done

#
#
if ! ${KERN_ONLY} && ! ${TOOLS_ONLY} && ! ${NBMAKE_ONLY}; then
	# build a full distribution by default
	#
	OPTIONS=3D"${OPTIONS}"
	OPER=3D"distribution"
fi

if [ -z "${TARGET_MACHINE}" ]; then
	TARGET_MACHINE=3D$(uname -m)
	echo "$argv0: TARGET_MACHINE was not set from environ or cmd-line, using: =
${TARGET_MACHINE}" 1>&2
fi

# CPU_OPTIM_NM is just a dash-prefixed name to use to allow separate
# builds of optimized and non-optimized produucts.
#
# The names given should reflect the '-m' options given in=20
#
CPU_OPTIM_NM=3D""

case ${TARGET_MACHINE} in
alpha)
	MACHINE_DESCR=3D"DEC Alpha"
	CPU_OPTIM_NM=3D"-21164a"
	;;
i386)
	MACHINE_DESCR=3D"Intel iAPX x86"
	CPU_OPTIM_NM=3D"-ppro"
	;;
pmax)
	MACHINE_DESCR=3D"Digital MIPS"
	;;
sparc)
	MACHINE_DESCR=3D"Sun SPARC"
	CPU_OPTIM_NM=3D"-ssv8"
	;;
sun3)
	MACHINE_DESCR=3D"Sun m68k"
	;;
vax)
	MACHINE_DESCR=3D"Digital VAX"
	;;
esac

if [ ${nJOBS} -gt 1 ]; then
	PARALLEL=3D"-j ${nJOBS}"
else
	PARALLEL=3D""
fi

if $NO_CPU_OPTIM; then
	echo "$argv0: building a default non-CPU-specific product"
	CPU_OPTIM_NM=3D""				# to clobber the suffix name in directories
	CPU_OPTIM_FLG=3D"-N"			# for build.sh to pass NO_CPU_OPTIM=3D1 to make
	CPU_OPTIM_MK=3D"NO_CPU_OPTIM=3D1"		# for our own make invocations
fi

# from here on down we fail on any error -- just like 'make' does....
#
set -e

# Note that while xsrc doesn't use the build tools -- just the native
# tools, lndir may have to be bootstrapped and we'll do that into our
# ${TOOLDIR}/bin
#
TOOLDIR=3D${BUILD_HOME}/${MYBRANCH}-${HOST_MACHINE}-${TARGET_MACHINE}-tools
if [ ! -d $TOOLDIR ]; then
	mkdir -p ${TOOLDIR}
fi
DESTDIR=3D${BUILD_HOME}/${MYBRANCH}-${TARGET_MACHINE}${CPU_OPTIM_NM}-destdir
if [ ! -d $DESTDIR ]; then
	mkdir -p ${DESTDIR}
fi
if [ ! -d ${DESTDIR}-no-g ]; then
	mkdir -p ${DESTDIR}-no-g
fi
RELEASEDIR=3D${BUILD_HOME}/${MYBRANCH}-${TARGET_MACHINE}${CPU_OPTIM_NM}-rel=
ease
if [ ! -d $RELEASEDIR ]; then
	mkdir -p ${RELEASEDIR}
fi
if [ ! -d ${RELEASEDIR}-no-g ]; then
	mkdir -p ${RELEASEDIR}-no-g
fi

LOGFILE=3D${BUILD_HOME}/${MYBRANCH}-${TARGET_MACHINE}${CPU_OPTIM_NM}.log

# Note since we share MAKEOBJDIRPREFIX with both tools and the product
# OS we can't leave the ${HOST_MACHINE} out of this path....
#
MY_OBJDIR=3D${BUILD_HOME}/${MYBRANCH}-${HOST_MACHINE}-${TARGET_MACHINE}${CP=
U_OPTIM_NM}-obj

if ${SHOW_DESTDIR}; then
	echo ${DESTDIR}${SHOW_NO_G}
	exit 0
fi
if ${SHOW_OBJDIR}; then
	echo ${MY_OBJDIR}
	exit 0
fi
if ${SHOW_RELEASEDIR}; then
	echo ${RELEASEDIR}${SHOW_NO_G}
	exit 0
fi
if ${SHOW_TOOLDIR}; then
	echo ${TOOLDIR}
	exit 0
fi

if ! ${DEBUG} && ! ${NO_EXEC}; then
	if ${LOG_IT}; then
		echo ""
		echo "Now logging to $LOGFILE"
		echo ""
		exec 1>> $LOGFILE 2>&1
	fi
fi

if ${DO_REBUILD}; then
	# "build.sh -r" doesn't currently remove $MAKEOBJDIRPREFIX
	${DEBUG_ECHO} \
	rm -rf ${MY_OBJDIR}
	# and of course "build.sh -r" doesn't currently remove ${DESTDIR}-no-g
	${DEBUG_ECHO} \
	rm -rf ${DESTDIR}-no-g
	# xxx ignore the release directories for now....
fi
if [ ! -d $MY_OBJDIR ]; then
	# include true cwd for objdir symlinks
	mkdir -p ${MY_OBJDIR}/$(/bin/pwd)
fi

# set/fix up symlinks for the cd*obj aliases in myhelpers.ksh to deal with =
the
# possibility that either the source is in /work/${USER}/<something>, or is=
 on
# an NFS server in that location.  Otherwise we assume it really is /usr/sr=
c.
#
# Assume we also work from within a /usr/src (or /usr/src-4) symlink
# pointing to the real CVS working directory, i.e.:
#
#	ln -s ../work/${USER}/m-NetBSD-4 /usr/src
#
# In order to handle going from a $PWD in the /usr/src symlink location to =
the
# object directory with the ksh "cd old new" feature you first need to make
# sure you have any necessary symlinks (for each architecture), such as:
#
#	ln -s work ${BUILD_HOME}/${MYBRANCH}-${HOST_MACHINE}-${TARGET}-obj/usr
#	ln -s ${USER}/m-NetBSD-4 ${BUILD_HOME}/${MYBRANCH}-${HOST_MACHINE}-${TARG=
ET}${CPU_OPTIM_NM}-obj/usr/src
#
# or, on an NFS client:
#
#	ln -s proven/work ${BUILD_HOME}/${MYBRANCH}-${HOST_MACHINE}-${TARGET}-obj=
/usr
#	ln -s ${USER}/m-NetBSD-4 ${BUILD_HOME}/${MYBRANCH}-${HOST_MACHINE}-${TARG=
ET}${CPU_OPTIM_NM}-obj/usr/src
#
src_dir=3D${PWD#/}
src_top_dir=3D${src_dir%%/*}
src_work_dir=3D${src_dir##*/}
case ${src_top_dir} in
"usr")
	;;
"work")
	rm -f ${MY_OBJDIR}/usr
	ln -s work ${MY_OBJDIR}/usr
	;;
"mfbd")
	rm -f ${MY_OBJDIR}/usr
	ln -s mfbd ${MY_OBJDIR}/usr
	;;
*)
	rm -f ${MY_OBJDIR}/usr
	ln -s ${src_top_dir}/work ${MY_OBJDIR}/usr
	;;
esac
src_br_id=3D${src_work_dir##*-}
#echo '*****' src_br_id =3D $src_br_id
rm -f ${MY_OBJDIR}/usr/src
rm -f ${MY_OBJDIR}/usr/src-${src_br_id}
ln -s ${USER}/${src_work_dir} ${MY_OBJDIR}/usr/src
ln -s ${USER}/${src_work_dir} ${MY_OBJDIR}/usr/src-${src_br_id}

if ${DEBUG}; then
	# XXX this needs to bootstrap nbmake and does "makewrapper" too
	sh ./build.sh ${PARALLEL} -m ${TARGET_MACHINE} ${CPU_OPTIM_FLG} ${OPTIONS}=
 -U -D $DESTDIR -R $RELEASEDIR -T $TOOLDIR -M $MY_OBJDIR params
fi

# first do the full update of the build and the initial update of the insta=
ll
# to $DESTDIR (unless '-t' or '-L' were given, of course, in which case it'=
ll
# only be the tools that are built/updated and installed)
#
${DEBUG_ECHO} \
sh ./build.sh ${PARALLEL} -m ${TARGET_MACHINE} ${CPU_OPTIM_FLG} ${OPTIONS} =
-U -D $DESTDIR -R $RELEASEDIR -T $TOOLDIR -M $MY_OBJDIR ${OPER}

if ${TOOLS_ONLY}; then
	exit 0
fi
if ${KERN_ONLY}; then
	exit 0
fi
if ${NBMAKE_ONLY}; then
	exit 0
fi

# XXX untested!!!  Needs porting forward to 3.x
#
# we just did the tools alone above, now if we want to do just
# the libs this uses a similar hack of building just the
# needed internal top-level Makefile targets in much the same
# way "build.sh -t" itself builds just the tools
#
if ${LIBS_ONLY}; then
	if ${DO_UPDATE}; then
		LIBS_UPDATE=3D"UPDATE=3D1"
	else
		LIBS_UPDATE=3D""
	fi
	${DEBUG_ECHO} \
	${TOOLDIR}/bin/nbmake-${TARGET_MACHINE} ${CPU_OPTIM_MK} ${LIBS_UPDATE} do-=
distrib-dirs
	${DEBUG_ECHO} \
	${TOOLDIR}/bin/nbmake-${TARGET_MACHINE} ${CPU_OPTIM_MK} ${LIBS_UPDATE} obj
	${DEBUG_ECHO} \
	${TOOLDIR}/bin/nbmake-${TARGET_MACHINE} ${CPU_OPTIM_MK} ${LIBS_UPDATE} inc=
ludes
	${DEBUG_ECHO} \
	${TOOLDIR}/bin/nbmake-${TARGET_MACHINE} ${CPU_OPTIM_MK} ${LIBS_UPDATE} libs
	exit 0
fi

# echo a checkpoint comment to the end of ${DESTDIR}/METALOG
#
if ! ${DEBUG} && ! ${NO_EXEC}; then
	echo "# full install DO_UPDATE=3D${DO_UPDATE}  completed: $(date '+%Y%m%d-=
%T')" >> ${DESTDIR}/METALOG
fi

#
# now install a no-debug version
#

# echo a checkpoint comment to the end of ${DESTDIR}/METALOG
#
if ! ${DEBUG} && ! ${NO_EXEC}; then
	echo "# full install DO_UPDATE=3D${DO_UPDATE}  started: $(date '+%Y%m%d-%T=
')" >> ${DESTDIR}-no-g/METALOG
fi

# this does a lot more work than necessary...
#
${DEBUG_ECHO} \
sh ./build.sh ${PARALLEL} -m ${TARGET_MACHINE} ${CPU_OPTIM_FLG} ${OPTIONS} =
-U -u -D ${DESTDIR}-no-g -R ${RELEASEDIR}-no-g -T $TOOLDIR -M $MY_OBJDIR -V=
 STRIPFLAG=3D${DQ}'-sS "-g"'${DQ} release

# echo a checkpoint comment to the end of ${DESTDIR}-no-g/METALOG
#
if ! ${DEBUG} && ! ${NO_EXEC}; then
	echo "# full DO_UPDATE=3D${DO_UPDATE} install completed: $(date '+%Y/%m/%d=
-%T')" >> ${DESTDIR}-no-g/METALOG
fi

# if all went well then make a copy of the sources into the no-debug release
#
# (this should/could be done when making sets if INCLUDE_SRC was
# defined in make, but we don't need to waste time and space making
# source sets for the debug version)
#
if ${MKSRCSETS}; then
	${DEBUG_ECHO} \
	sh ./build.sh ${PARALLEL} -m ${TARGET_MACHINE} ${OPTIONS} -U -D ${DESTDIR}=
-no-g -R ${RELEASEDIR}-no-g -T $TOOLDIR -M $MY_OBJDIR sourcesets
fi

# Now put the various documentation files into ${RELEASEDIR}-no-g
#
if ! ${NO_EXEC}; then
	${DEBUG_ECHO} \
	cp doc/CHANGES doc/CHANGES-* doc/LAST_MINUTE doc/README* ${RELEASEDIR}-no-g

	if ${DEBUG}; then
		echo TZ=3DUTC0 stat -f '%Sm' -t '%FT%TZ' CVS '>' ${RELEASEDIR}-no-g/SOURC=
E_DATE
	else
		TZ=3DUTC0 stat -f '%Sm' -t '%FT%TZ' CVS > ${RELEASEDIR}-no-g/SOURCE_DATE
	fi
fi

# now we need add-on packages....
#
# specifically we need:  sysutils/cdrecord, graphics/cdlabelgen
# and maybe also:  sysutils/mksunbootcd, pkgtools/cdpack
#
PATH=3D$PATH:/usr/pkg/bin

BUILD_FLAGS=3D"CFLAGS=3D\"$(${TOOLDIR}/bin/nbmake-${TARGET_MACHINE} -V OPTI=
M ${CPU_OPTIM_MK} MACHINE=3D${TARGET_MACHINE})\""
BUILD_LDSTATIC=3D"\"ld $(${TOOLDIR}/bin/nbmake-${TARGET_MACHINE} -V LDSTATI=
C ${CPU_OPTIM_MK} MACHINE=3D${TARGET_MACHINE})\""

if ${MKPKGS} && ! ${NO_EXEC}; then
	#
	# XXX first we should nuke all the existing packages!
	#
	su root -c 'PATH=3D$PATH:/sbin:/usr/sbin:/usr/pkg/sbin;				\
			cd /usr/pkgsrc/pkgtools/pkg_chk && make update;			\
			pkg_chk -v -C /usr/pkgsrc/pkgchk.conf -s -a -c -D primary'
fi

# this won't exist yet....
#
if ! ${NO_EXEC}; then
	${DEBUG_ECHO} \
	mkdir -p ${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom/

	${DEBUG_ECHO} \
	cdlabelgen -l 0 -t cd-tmplt-av8931.ps -e netbsd-all-logos.eps -E netbsd-to=
aster-logo.eps -T 1.0,-0.1,0.0 -c NetBSD/${TARGET_MACHINE} -s ${DQ}"Planix,=
 Inc.  ${MYBRANCH}"${DQ} -i ${DQ}"NetBSD/${TARGET_MACHINE}-${OSRELEASE} for=
 ${MACHINE_DESCR}%%Bootable Binary Installation CD%%Built with:%${BUILD_FLA=
GS}${BUILD_LDSTATIC:+%and ${BUILD_LDSTATIC}}%%%%For more information see:%%=
http://www.NetBSD.org/                        http://www.planix.ca/"${DQ} -=
v 20 -d ${START_DATE} -o ${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/=
cdrom/netbsd-${TARGET_MACHINE}-case.ps

	${DEBUG_ECHO} \
	cdlabelgen -l 0 -t cd-tmplt-av8931.ps -e netbsd-all-logos.eps -E netbsd-to=
aster-logo.eps -T 1.0,-0.1,0.0 -c NetBSD/${TARGET_MACHINE} -s ${DQ}"Planix,=
 Inc.  ${MYBRANCH} + binpkg"${DQ} -i ${DQ}"NetBSD/${TARGET_MACHINE}-${OSREL=
EASE} for ${MACHINE_DESCR}%%Disc 0:  Bootable Binary Installation CD%%Disc =
1:  NetBSD/${TARGET_MACHINE} Binary Packages CD%%Built with:%${BUILD_FLAGS}=
${BUILD_LDSTATIC:+%and ${BUILD_LDSTATIC}}%%For more information see:%%http:=
//www.NetBSD.org/                        http://www.planix.ca/"${DQ} -v 20 =
-d ${START_DATE} -o ${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom=
/netbsd-${TARGET_MACHINE}-2cd-case.ps
fi

REDIRFILE=3D${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom/netbsd-=
${TARGET_MACHINE}-cd-labels.ps
if ! ${DEBUG} && ! ${NO_EXEC}; then
	exec > ${REDIRFILE}
	SHOWREDIR=3D""
else
	SHOWREDIR=3D"> ${REDIRFILE}"
fi

if ! ${NO_EXEC}; then
	${DEBUG_ECHO} \
	sed -e ${DQ}"s|TOKEN_TARGET_MACHINE|${TARGET_MACHINE}|"${DQ} \
	    -e ${DQ}"s|TOKEN_LABEL1_DESCR|${OSRELEASE} Bootable Binary Installatio=
n CD|"${DQ} \
	    -e ${DQ}"s|TOKEN_LABEL1_NUMBER|0|"${DQ} \
	    -e ${DQ}"s|TOKEN_LABEL2_DESCR|Some Binary Packages for ${OSRELEASE}|"$=
{DQ} \
	    -e ${DQ}"s|TOKEN_LABEL2_NUMBER|1|"${DQ} \
	    -e ${DQ}"s|TOKEN_DATE|   ${START_DATE}|"${DQ} \
	    -e ${DQ}"s|TOKEN_MYBRANCH|${MYBRANCH}|"${DQ} \
	    -e ${DQ}"s|TOKEN_MACHINE_DESCR|${MACHINE_DESCR}|"${DQ} \
	    -e ${DQ}"s|TOKEN_BUILD_FLAGS|${BUILD_FLAGS}|"${DQ} \
	    -e ${DQ}"s|TOKEN_LDSTATIC|${BUILD_LDSTATIC}|"${DQ} \
		cd-label-template.ps ${SHOWREDIR}
fi

if ! ${DEBUG} && ! ${NO_EXEC}; then
	REDIRFILE=3D""
	# WARNING:  this will cause the script to fail if it is nohup'ed and tty H=
UPs
	exec > /dev/tty
	SHOWREDIR=3D""
fi

if ${MKPKGISO} && ! ${NO_EXEC}; then

	# It doesn't necessarily make a whole lot of sense to make
	# this CD image right now, since esp. for static builds the
	# base OS has to be installed first and all the packages need
	# to be rebuilt, so we just make the labels and then tell the
	# user how to build it later...
	#
	${DEBUG_ECHO} \
	cdlabelgen -l 0 -t cd-tmplt-av8931.ps -e netbsd-all-logos.eps -E netbsd-to=
aster-logo.eps -T 1.0,-0.1,0.0 -c NetBSD/${TARGET_MACHINE} -s ${DQ}"Planix,=
 Inc.  ${MYBRANCH} + binpkg"${DQ} -i ${DQ}"NetBSD/${TARGET_MACHINE}-${OSREL=
EASE} for ${MACHINE_DESCR}%%Binary Packages CD%%Built with:%${BUILD_FLAGS}$=
{BUILD_LDSTATIC:+%and ${BUILD_LDSTATIC}}%%%%For more information see:%%http=
://www.NetBSD.org/                        http://www.planix.ca/"${DQ} -v 20=
 -d ${START_DATE} -o ${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdro=
m/netbsd-${TARGET_MACHINE}-pkgs-case.ps

	${DEBUG_ECHO} \
	cdlabelgen -l 0 -t cd-tmplt-av8931.ps -e netbsd-all-logos.eps -E netbsd-to=
aster-logo.eps -T 1.0,-0.1,0.0 -c NetBSD/${TARGET_MACHINE} -s ${DQ}"Planix,=
 Inc.  ${MYBRANCH} + binpkg"${DQ} -i ${DQ}"NetBSD/${TARGET_MACHINE}-${OSREL=
EASE} for ${MACHINE_DESCR}%%Disc 2:  NetBSD/${TARGET_MACHINE} Binary Packag=
es CD%%Disc 3:  NetBSD/${TARGET_MACHINE} Binary Packages CD%%Built with:%${=
BUILD_FLAGS}${BUILD_LDSTATIC:+%and ${BUILD_LDSTATIC}}%%For more information=
 see:%%http://www.NetBSD.org/                        http://www.planix.ca/"=
${DQ} -v 20 -d ${START_DATE} -o ${RELEASEDIR}-no-g/${TARGET_MACHINE}/instal=
lation/cdrom/netbsd-${TARGET_MACHINE}-pkgs-2cd-case.ps

	REDIRFILE=3D${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom/netbsd=
-${TARGET_MACHINE}-pkgs-cd-labels.ps
	if ! ${DEBUG} && ! ${NO_EXEC}; then
		exec > ${REDIRFILE}
		SHOWREDIR=3D""
	else
		SHOWREDIR=3D"> ${REDIRFILE}"
	fi

	${DEBUG_ECHO} \
	sed -e ${DQ}"s|TOKEN_TARGET_MACHINE|${TARGET_MACHINE}|"${DQ} \
	    -e ${DQ}"s|TOKEN_LABEL1_DESCR|Some Binary Packages for ${OSRELEASE}|"$=
{DQ} \
	    -e ${DQ}"s|TOKEN_LABEL1_NUMBER|2|"${DQ} \
	    -e ${DQ}"s|TOKEN_LABEL2_DESCR|Some Binary Packages for ${OSRELEASE}|"$=
{DQ} \
	    -e ${DQ}"s|TOKEN_LABEL2_NUMBER|3|"${DQ} \
	    -e ${DQ}"s|TOKEN_DATE|   ${START_DATE}|"${DQ} \
	    -e ${DQ}"s|TOKEN_MYBRANCH|${MYBRANCH}|"${DQ} \
	    -e ${DQ}"s|TOKEN_MACHINE_DESCR|${MACHINE_DESCR}|"${DQ} \
	    -e ${DQ}"s|TOKEN_BUILD_FLAGS|${BUILD_FLAGS}|"${DQ} \
	    -e ${DQ}"s|TOKEN_LDSTATIC|${BUILD_LDSTATIC}|"${DQ} \
		cd-label-template.ps ${SHOWREDIR}

	if ! ${DEBUG} && ! ${NO_EXEC}; then
		REDIRFILE=3D""
		# WARNING:  this will cause the script to fail if it is nohup'ed and tty =
HUPs
		exec > /dev/tty
		SHOWREDIR=3D""
	fi
fi

# first make ISOs of the packages, if we're asked to.
#
# We do this first to allow the "nbmake-* iso-image" rules to include
# these files in the "makesums" calculations
#
if ${MKPKGISO} && ! ${NO_EXEC}; then

	mkdir -p ${RELEASEDIR}-no-g/pkgsrc
	rm -f ${RELEASEDIR}-no-g/pkgsrc/pkgsrc.tgz
	ln -s ../source/sets/pkgsrc.tgz ${RELEASEDIR}-no-g/pkgsrc

	# NOTE: To make use of the '-p' and '-P' options of mkisofs
	# you must put your information in ~/.mkisofsrc
	#
	${DEBUG_ECHO} \
	cdpack -v -m ${TARGET_MACHINE} -o NetBSD -r ${OSRELEASE} -R -ac -af -X ${R=
ELEASEDIR}-no-g/pkgsrc /var/packages/All ${RELEASEDIR}-no-g/${TARGET_MACHIN=
E}/installation/cdrom/
fi

# XXX create a bootable -rescue ISO too!

# lastly make an ISO of the no-debug release
#
if ! ${NO_EXEC}; then
	${DEBUG_ECHO} \
	${TOOLDIR}/bin/nbmake-${TARGET_MACHINE} UNPRIVED=3Dyes UPDATE=3Dyes DESTDI=
R=3D${DESTDIR}-no-g RELEASEDIR=3D${RELEASEDIR}-no-g iso-image
fi

#
# NOTE:  6x is too fast to pull the data over NFS via 10baseT...
#        5x, which is really 4x on the yamaha 6x4x16, does usually
#        work with fs=3D4m (the default), but 16m is safer.
#
echo ""
echo "If all went well you can now burn a CD-ROM of the new release!"
echo ""
echo "	cdrecord -vvv dev=3D/dev/cd0c speed=3D4 fs=3D32m -data ${RELEASEDIR}=
-no-g/${TARGET_MACHINE}/installation/cdrom/netbsd-${TARGET_MACHINE}.iso"
if ${MKPKGISO}; then
	echo ""
	echo "as well as the binary packages CD-ROMs:"
	echo ""
	for iso in ${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom/disk*.i=
so; do
		echo "	cdrecord -vvv dev=3D/dev/cd0c speed=3D4 fs=3D32m -data $iso"
	done
fi
echo ""
echo "You can print custom labels for the new CD-ROM(s) & case(s) using the=
se files:"
echo ""
echo "	${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom/netbsd-${TAR=
GET_MACHINE}-cd-labels.ps"
echo "	${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom/netbsd-${TAR=
GET_MACHINE}-case.ps"
if ${MKPKGISO}; then
	echo "	${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom/netbsd-${TA=
RGET_MACHINE}-pkgs-cd-labels.ps"
	echo "	${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom/netbsd-${TA=
RGET_MACHINE}-pkgs-case.ps"
	echo ""
	echo "Alternately you can print 2-disc case inserts using these files:"
	echo ""
	echo "	${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom/netbsd-${TA=
RGET_MACHINE}-2cd-case.ps"
	echo "	${RELEASEDIR}-no-g/${TARGET_MACHINE}/installation/cdrom/netbsd-${TA=
RGET_MACHINE}-pkgs-2cd-case.ps"
fi
echo ""


exit 0

--Multipart_Tue_Mar_20_17:13:09_2007-1--

--pgp-sign-Multipart_Tue_Mar_20_17:13:09_2007-1
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

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

iQA/AwUBRgBOZ2Z9cbd4v/R/EQL/AwCgnTUgI9Yq2psRXa23LTlgidlDjxYAoL1D
XM0zy+Qqx791gve85MXIVB+n
=BULV
-----END PGP SIGNATURE-----

--pgp-sign-Multipart_Tue_Mar_20_17:13:09_2007-1--