Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: use of "build.sh -B BUILDID".... with patch and more questions



So the patch below works A-OK for me now (except for rebuilding tools).

It includes a couple of bug fixes, mostly to do with mixups between
RELEASEDIR and RELEASEMACHINEDIR, and inconsistencies between Makefile
default settings and those usually supplied by build.sh.  There was also
some apparent mixup with $TOP_obj vs. $TOP_objdir in build.sh that I'm
pretty sure was a bug as it only works correctly now that I've fixed it.

I don't like the default location of DESTDIR and RELEASEDIR being within
the TOP_objdir so I still use another wrapper to adjust those.

I think I've discovered the main difference between -O and -M, and I now
vastly prefer -O, though I can see some advantage to -M if one is doing
a lot of testing of different branches, and in those cases the default
location of DESTDIR, and maybe RELEASEDIR too, make more sense.  I would
propose moving those defaults out to TOP_objdir if -O is given and only
leave them as they are if -M is given, but I suspect there might be
pushback on that.

The remaining headache is the mixing of objects for tools with objects
for the target resulting in the rebuilding of tools for each BUILDID.

The only solution I can think of is to build the tools separately with a
separate objdir and then have the build skip them entirely if a tooldir
is supplied and seems to contain what's needed.  That could break manual
invocations of "make build" unless the invoker has the right setting in
their environment.

Sort of like USETOOLS=no, but still obeying $TOOLDIR.

If any one has any comments....

--
					Greg A. Woods <gwoods%acm.org@localhost>

Kelowna, BC     +1 250 762-7675           RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost>     Avoncote Farms <woods%avoncote.ca@localhost>


diff --git a/BUILDING b/BUILDING
index 51c078f43cfb..7806164365fe 100644
--- a/BUILDING
+++ b/BUILDING
@@ -650,7 +650,9 @@ BUILDING
                Set the value of BUILDID to buildid.  This will also append the
                build identifier to the name of the nbmake-MACHINE wrapper
                script so that the resulting name is of the form
-               "nbmake-MACHINE-BUILDID".
+               "nbmake-MACHINE-BUILDID".  The build ID will also be appended
+               to the internal RELEASEMACHINEDIR subdirectory name, as well as
+               to the object directory name(s) (done by <bsd.obj.mk>).

      -C cdextras
                Append cdextras to the CDEXTRA variable, which is a space-
@@ -706,6 +708,12 @@ BUILDING
                /usr/obj/usr/src/bin, /usr/obj/usr/src/lib,
                /usr/obj/usr/src/usr.bin, and so forth.

+               This might be useful if you want one shared main "obj"
+               directory but you build from multiple different source
+               trees, however since it also, by default, places
+               RELEASEDIR and TOOLDIR under /usr/obj/usr/src it can be
+               cumbersome, so see "-O" instead!
+
                If a relative path is specified, it will be converted to an
                absolute path before being used.  build.sh imposes the
                restriction that the argument to the -M option must not begin
diff --git a/build.sh b/build.sh
index c6ef6291fdb1..dbaed7e93539 100755
--- a/build.sh
+++ b/build.sh
@@ -1072,6 +1072,9 @@ resolvepath()
 	local var="$1"
 	local val
 	eval val=\"\${${var}}\"
+	# remove any leading (and trailing) whitespace
+	val=${val##*[[:blank:]]}
+	val=${val%%*[[:blank:]]}
 	case "${val}" in
 	/)
 		;;
@@ -1175,7 +1178,7 @@ help()
     -h             Show this help message, and exit.
     -j NJOB        Run up to NJOB jobs in parallel; see make(1) -j.
     -M MOBJ        Set obj root directory to MOBJ; sets MAKEOBJDIRPREFIX=MOBJ,
-                   unsets MAKEOBJDIR.
+                   unsets MAKEOBJDIR.  "/BUILDID", if given, is appended.
     -m MACH        Set MACHINE=MACH.  Some MACH values are actually
                    aliases that set MACHINE/MACHINE_ARCH pairs.
                    [Default: deduced from the host system if the host
@@ -1274,7 +1277,7 @@ parseoptions()

 		-B)
 			eval ${optargcmd}
-			BUILDID=${OPTARG}
+			setmakeenv BUILDID "${OPTARG}"
 			;;

 		-C)
@@ -1363,7 +1366,7 @@ parseoptions()
 				;;
 			esac
 			unsetmakeenv MAKEOBJDIRPREFIX
-			setmakeenv MAKEOBJDIR "\${.CURDIR:C,^$TOP,$OPTARG,}"
+			setmakeenv MAKEOBJDIR "\${.CURDIR:C,^${TOP},${OPTARG}${BUILDID:+/${BUILDID}},}"
 			;;

 		-o)
@@ -1513,9 +1516,9 @@ parseoptions()

 		disk-image=*)
 			arg=${op#*=}
-			op=disk_image
+			op=disk_image # XXX how/why can this have an '_', or a '-'????
 			[ -n "${arg}" ] ||
-			    bomb "Must supply a target name with '${op}=...'"
+			    bomb "Must supply a target/kernel name with '${op}=...'"

 			;;

@@ -1600,8 +1603,16 @@ parseoptions()

 	# Set up default make(1) environment.
 	#
+	if [ -n "${BUILDID}" ]; then
+		if [ -n "${MAKEOBJDIRPREFIX}" -a -n "${TOP_objdir}" ]; then
+			# xxx this will dup MAKEOBJDIRPREFIX in $makeenv but
+			# unsetmakeenv doesn't remove var from $makeenv so it
+			# can't help here
+			setmakeenv MAKEOBJDIRPREFIX "${MAKEOBJDIRPREFIX}/${BUILDID}"
+			TOP_objdir="${MAKEOBJDIRPREFIX}/${TOP}"
+		fi
+	fi
 	makeenv="${makeenv} TOOLDIR MACHINE MACHINE_ARCH MAKEFLAGS"
-	[ -z "${BUILDID}" ] || makeenv="${makeenv} BUILDID"
 	[ -z "${BUILDINFO}" ] || makeenv="${makeenv} BUILDINFO"
 	MAKEFLAGS="-de -m ${TOP}/share/mk ${MAKEFLAGS}"
 	MAKEFLAGS="${MAKEFLAGS} MKOBJDIRS=${MKOBJDIRS-yes}"
@@ -2012,7 +2023,7 @@ validatemakeparams()
 		# could be handled either way, but we choose to handle
 		# it similarly to MAKEOBJDIRPREFIX.
 		#
-		if [ -n "${TOP_obj}" ]
+		if [ -n "${TOP_objdir}" ]
 		then
 			# It must have been set by the "-M" or "-O"
 			# command line options, so there's no need to
@@ -2020,16 +2031,16 @@ validatemakeparams()
 			:
 		elif [ -n "$MAKEOBJDIRPREFIX" ]
 		then
-			TOP_obj="$(getmakevar MAKEOBJDIRPREFIX)${TOP}"
+			TOP_objdir="$(getmakevar MAKEOBJDIRPREFIX)${TOP}"
 		elif [ -n "$MAKEOBJDIR" ]
 		then
-			TOP_obj="$(getmakevar MAKEOBJDIR)"
+			TOP_objdir="$(getmakevar MAKEOBJDIR)"
 		fi
-		if [ -n "$TOP_obj" ]
+		if [ -n "$TOP_objdir" ]
 		then
-		    ${runcmd} mkdir -p "${TOP_obj}" ||
+		    ${runcmd} mkdir -p "${TOP_objdir}" ||
 			bomb "Can't create top level object directory" \
-			     "${TOP_obj}"
+			     "${TOP_objdir}"
 		else
 		    ${runcmd} "${make}" -m "${TOP}/share/mk" obj NOSUBDIR= ||
 			    bomb "Can't create top level object directory" \
@@ -2057,16 +2068,20 @@ validatemakeparams()
 		newval="$(getmakevar $var)"
 		if ! $do_expertmode
 		then
+			# xxx this should be outside the for loop!?!?!?!
 			: ${_SRC_TOP_OBJ_:=$(getmakevar _SRC_TOP_OBJ_)}
 			case "$var" in
 			DESTDIR)
 				: ${newval:=${_SRC_TOP_OBJ_}/destdir.${MACHINE}}
-				makeenv="${makeenv} DESTDIR"
 				;;
 			RELEASEDIR)
-				: ${newval:=${_SRC_TOP_OBJ_}/releasedir}
-				makeenv="${makeenv} RELEASEDIR"
+				if [ -n "${BUILDID}" ]; then
+					: ${newval:=$(echo ${_SRC_TOP_OBJ_} | sed "s|/${BUILDID}||")/releasedir}
+				else
+					: ${newval:=${_SRC_TOP_OBJ_}/releasedir}
+				fi
 				;;
+			# n.b.:  TOOLDIR will have the correct value from getmakevar
 			esac
 		fi
 		if [ -n "$oldval" ] && [ "$oldval" != "$newval" ]
@@ -2076,10 +2091,15 @@ validatemakeparams()
 		fi
 		eval ${var}=\"\${newval}\"
 		eval export ${var}
+		makeenv="${makeenv} ${var}"
 		statusmsg2 "${var} path:" "${newval}"
+
+		# XXX could/should make these directories now too???
 	done

-	# RELEASEMACHINEDIR is just a subdir name, e.g. "i386".
+	# RELEASEMACHINEDIR is just a subdir name, e.g. "i386", with ".$BUILDID"
+	# appended if BUILDID is set (see <bsd.own.mk>)
+	#
 	RELEASEMACHINEDIR=$(getmakevar RELEASEMACHINEDIR)

 	# Check validity of TOOLDIR and DESTDIR.
@@ -2169,7 +2189,7 @@ createmakewrapper()
 		done
 	fi

-	# Recreate $TOOLDIR.
+	# (Re)create $TOOLDIR.
 	#
 	${runcmd} mkdir -p "${TOOLDIR}/bin" ||
 	    bomb "mkdir of '${TOOLDIR}/bin' failed"
@@ -2343,6 +2363,10 @@ diskimage()
 	kernel="${kerneldir}/netbsd-${ARG}.gz"
 	[ -f "${kernel}" ] ||
 	    bomb "The kernel ${kernel} must be built first"
+	#
+	# XXX this seems specific only to evbarm, evbmips, evbppc, and riscv; or
+	# at least those are the only architectures that have smp_* targets!
+	#
 	make_in_dir "${NETBSDSRCDIR}/etc" "smp_${1}"
 }

@@ -2825,6 +2849,8 @@ setup_mkrepro()
 			bomb "Failed to get timestamp for vcs=$vcs in '$d'"
 		fi

+		# XXX this assumes all of ${dirs} were updated at nearly the same time!!!
+
 		#echo "latest $d $vcs $t"
 		if [ "$t" -gt "$MKREPRO_TIMESTAMP" ]
 		then
@@ -2838,6 +2864,7 @@ setup_mkrepro()
 		statusmsg2 "MKREPRO_TIMESTAMP" \
 			"$(repro_date "${MKREPRO_TIMESTAMP}")"
 	fi
+	# XXX why are these not in $makeenv???
 	export MKREPRO MKREPRO_TIMESTAMP NETBSD_REVISIONID
 }

diff --git a/distrib/common/Makefile.bootcd b/distrib/common/Makefile.bootcd
index 519302c3a415..12b0be5d612b 100644
--- a/distrib/common/Makefile.bootcd
+++ b/distrib/common/Makefile.bootcd
@@ -48,7 +48,7 @@ CDRELEASE?=	false
 CDSOURCE?=	false
 CDDEV_POPULATE?=false
 .if ${CDRELEASE} == false
-CDROMS_RELEASEDIR?=	${MACHINE}/installation/cdrom
+CDROMS_RELEASEDIR?=	${RELEASEMACHINEDIR}/installation/cdrom
 .else
 CDROMS_RELEASEDIR?=	images
 .endif
@@ -123,11 +123,11 @@ CHMOD?=		chmod
 ECHO?=		echo

 .if ${CDRELEASE} == false
-CDIMAGE=	${CDBASE}.iso
+CDIMAGE=	${CDBASE}.iso	# xxx ${BUILDID:D-${BUILDID}} not needed as in RELEASEMACHINEDIR?
 .elif ${CDBASE:M*dvd}
-CDIMAGE=	NetBSD-${DISTRIBVER}-${CDBASE:S/dvd$//}-dvd.iso
+CDIMAGE=	NetBSD-${DISTRIBVER}-${CDBASE:S/dvd$//}${BUILDID:D-${BUILDID}}-dvd.iso
 .else
-CDIMAGE=	NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso
+CDIMAGE=	NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}${BUILDID:D-${BUILDID}}.iso
 .endif
 WORKSPEC=	fs.spec

@@ -200,7 +200,7 @@ PAX_v?= -v
 PAX_v?=
 .endif

-# Copy $RELEASEDIR/${MACHINE} in the CDROM dir
+# Copy $RELEASEDIR/${MACHINERELEASEDIR} in the CDROM dir
 #
 # XXX This could be done a lot easier if makefs(8) could
 # XXX include more than one directory on the image - HF
diff --git a/distrib/common/bootimage/Makefile.bootimage b/distrib/common/bootimage/Makefile.bootimage
index c95fe0013b8a..8543cee0a6d8 100644
--- a/distrib/common/bootimage/Makefile.bootimage
+++ b/distrib/common/bootimage/Makefile.bootimage
@@ -247,7 +247,10 @@ SWAPDISK_UUID=`${TOOL_GPT} ${GPT_TIMESTAMP} ${WORKMBR} show -i 3 | ${TOOL_AWK} '
 #
 # definitions to create root fs
 #
-SETS_DEFAULT=	modules base etc comp games gpufw man misc rescue text
+SETS_DEFAULT=	base etc comp games gpufw man misc rescue text
+.if ${MKKMOD} != "no"
+SETS_DEFAULT+=	modules
+.endif
 .if ${MKATF} != "no"
 SETS_DEFAULT+=	tests
 .endif
diff --git a/distrib/common/bootimage/Makefile.installimage b/distrib/common/bootimage/Makefile.installimage
index a0bed1abf8e7..73c5b3afedfe 100644
--- a/distrib/common/bootimage/Makefile.installimage
+++ b/distrib/common/bootimage/Makefile.installimage
@@ -32,7 +32,11 @@ IMAGEMB=	${INSTIMAGEMB}
 SWAPMB=		0			# no swap

 KERN_SET?=	kern-GENERIC
+.if ${MKKMOD} != "no"
 SETS?=		gpufw modules base etc
+.else
+SETS?=		gpufw base etc
+.endif

 FSTAB_IN?=	${NETBSDSRCDIR}/distrib/common/bootimage/fstab.install.in

@@ -54,14 +58,19 @@ IMGDIR_EXCLUDE+=	-s ',./installation/installimage.*,,gp'
 IMGDIR_EXCLUDE+=	${MD_IMGDIR_EXCLUDE}
 .endif

-IMGBASE=        ${INSTIMGBASE}
+# figure out the installed name so it can live with others
+.if !empty(BUILDID)
+IMGBASE=	${INSTIMGBASE:C/(-install)/-${BUILDID}\1/}
+.else
+IMGBASE=	${INSTIMGBASE}
+.endif

 .include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage"

 # INSTIMG_RELEASEDIR specifies where to install ${INSTIMGBASE}.img.gz.
 # This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc
 # but also set default here for manual builds.
-INSTIMG_RELEASEDIR?=	${RELEASEMACHINEDIR}/installation/installimage
+INSTIMG_RELEASEDIR?=	${RELEASEDIR}/images

 # should be defined elsewhere?
 MKDIR?=		mkdir -p
diff --git a/distrib/common/bootimage/Makefile.liveimage b/distrib/common/bootimage/Makefile.liveimage
index 14b8abc9040a..a8a71be05727 100644
--- a/distrib/common/bootimage/Makefile.liveimage
+++ b/distrib/common/bootimage/Makefile.liveimage
@@ -30,14 +30,19 @@ check_LIVEIMGBASE: .PHONY .NOTMAIN
 IMAGEMB=	${LIVEIMAGEMB}
 .endif

+# figure out the installed name so it can live with others
+.if !empty(BUILDID)
+IMGBASE=	${LIVEIMGBASE:C/(-install)/-${BUILDID}\1/}
+.else
 IMGBASE=	${LIVEIMGBASE}
+.endif

 .include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage"

 # LIVEIMG_RELEASEDIR specifies where to install ${LIVEIMGBASE}.img.gz.
 # This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc
 # but also set default here for manual builds.
-LIVEIMG_RELEASEDIR?=	${RELEASEMACHINEDIR}/installation/liveimage
+LIVEIMG_RELEASEDIR?=	${RELEASEDIR}/images

 # should be defined elsewhere?
 MKDIR?=		mkdir -p
diff --git a/etc/Makefile b/etc/Makefile
index 7cacec34e6a7..463b1284b05d 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -432,7 +432,7 @@ release snapshot: .PHONY .MAKE check_DESTDIR check_RELEASEDIR snap_md_post
 #	Note: At least mkisofs 2.0 should be used.
 #
 CDROM_NAME_ADD?=
-CDROM_IMAGE?=${RELEASEDIR}/images/NetBSD-${DISTRIBVER}-${MACHINE}.iso
+CDROM_IMAGE?=${RELEASEDIR}/images/NetBSD-${DISTRIBVER}-${MACHINE}${BUILDID:D-${BUILDID}}.iso
 CDROM.dir=	${.OBJDIR}/cdrom.dir
 CDROM.pathlist=	${.OBJDIR}/cdrom.pathlist

Attachment: pgpJbUPZlGevI.pgp
Description: OpenPGP Digital Signature



Home | Main Index | Thread Index | Old Index