Index: build.sh =================================================================== RCS file: /cvsroot/src/build.sh,v retrieving revision 1.311 diff -u -u -r1.311 build.sh --- build.sh 13 Nov 2016 14:47:46 -0000 1.311 +++ build.sh 17 Dec 2016 18:06:04 -0000 @@ -1003,7 +1003,7 @@ fi cat <<_usage_ -Usage: ${progname} [-EhnorUuxy] [-a arch] [-B buildid] [-C cdextras] +Usage: ${progname} [-EhnoPRrUuxy] [-a arch] [-B buildid] [-C cdextras] [-D dest] [-j njob] [-M obj] [-m mach] [-N noisy] [-O obj] [-R release] [-S seed] [-T tools] [-V var=[value]] [-w wrapper] [-X x11src] [-Y extsrcsrc] @@ -1078,6 +1078,8 @@ -O obj Set obj root directory to obj; sets a MAKEOBJDIR pattern. Unsets MAKEOBJDIRPREFIX. -o Set MKOBJDIRS=no; do not create objdirs at start of build. + -P Set MKREPRO and MKREPRO_TIMESTAMP to the latest source + CVS timestamp for reproducible builds. -R release Set RELEASEDIR to release. [Default: releasedir] -r Remove contents of TOOLDIR and DESTDIR before building. -S seed Set BUILDSEED to seed. [Default: NetBSD-majorversion] @@ -1103,7 +1105,7 @@ parseoptions() { - opts='a:B:C:D:Ehj:M:m:N:nO:oR:rS:T:UuV:w:X:xY:yZ:' + opts='a:B:C:D:Ehj:M:m:N:nO:oPR:rS:T:UuV:w:X:xY:yZ:' opt_a=false opt_m=false @@ -1219,6 +1221,10 @@ MKOBJDIRS=no ;; + -P) + MKREPRO=yes + ;; + -R) eval ${optargcmd}; resolvepath OPTARG setmakeenv RELEASEDIR "${OPTARG}" @@ -1435,38 +1441,20 @@ ;; esac } - # print_tooldir_make -- # Try to find and print a path to an existing -# ${TOOLDIR}/bin/${toolprefix}make, for use by rebuildmake() before a -# new version of ${toolprefix}make has been built. -# -# * If TOOLDIR was set in the environment or on the command line, use -# that value. -# * Otherwise try to guess what TOOLDIR would be if not overridden by -# /etc/mk.conf, and check whether the resulting directory contains -# a copy of ${toolprefix}make (this should work for everybody who -# doesn't override TOOLDIR via /etc/mk.conf); -# * Failing that, search for ${toolprefix}make, nbmake, bmake, or make, -# in the PATH (this might accidentally find a version of make that -# does not understand the syntax used by NetBSD make, and that will -# lead to failure in the next step); -# * If a copy of make was found above, try to use it with -# nobomb_getmakevar to find the correct value for TOOLDIR, and believe the -# result only if it's a directory that already exists; -# * If a value of TOOLDIR was found above, and if -# ${TOOLDIR}/bin/${toolprefix}make exists, print that value. -# -print_tooldir_make() +# ${TOOLDIR}/bin/${toolprefix}program +print_tooldir_program() { local possible_TOP_OBJ local possible_TOOLDIR - local possible_make - local tooldir_make + local possible_program + local tooldir_program + local program=${1} if [ -n "${TOOLDIR}" ]; then - echo "${TOOLDIR}/bin/${toolprefix}make" - return 0 + echo "${TOOLDIR}/bin/${toolprefix}${program}" + return fi # Set host_ostype to something like "NetBSD-4.5.6-i386". This @@ -1479,8 +1467,8 @@ )" # Look in a few potential locations for - # ${possible_TOOLDIR}/bin/${toolprefix}make. - # If we find it, then set possible_make. + # ${possible_TOOLDIR}/bin/${toolprefix}${program}. + # If we find it, then set possible_program. # # In the usual case (without interference from environment # variables or /etc/mk.conf), <bsd.own.mk> should set TOOLDIR to @@ -1501,14 +1489,42 @@ do [ -n "${possible_TOP_OBJ}" ] || continue possible_TOOLDIR="${possible_TOP_OBJ}/tooldir.${host_ostype}" - possible_make="${possible_TOOLDIR}/bin/${toolprefix}make" + possible_program="${possible_TOOLDIR}/bin/${toolprefix}${program}" if [ -x "${possible_make}" ]; then - break - else - unset possible_make + echo ${possible_program} + return; fi done + echo "" +} +# print_tooldir_make -- +# Try to find and print a path to an existing +# ${TOOLDIR}/bin/${toolprefix}make, for use by rebuildmake() before a +# new version of ${toolprefix}make has been built. +# +# * If TOOLDIR was set in the environment or on the command line, use +# that value. +# * Otherwise try to guess what TOOLDIR would be if not overridden by +# /etc/mk.conf, and check whether the resulting directory contains +# a copy of ${toolprefix}make (this should work for everybody who +# doesn't override TOOLDIR via /etc/mk.conf); +# * Failing that, search for ${toolprefix}make, nbmake, bmake, or make, +# in the PATH (this might accidentally find a version of make that +# does not understand the syntax used by NetBSD make, and that will +# lead to failure in the next step); +# * If a copy of make was found above, try to use it with +# nobomb_getmakevar to find the correct value for TOOLDIR, and believe the +# result only if it's a directory that already exists; +# * If a value of TOOLDIR was found above, and if +# ${TOOLDIR}/bin/${toolprefix}make exists, print that value. +# +print_tooldir_make() +{ + local possible_make + local possible_TOOLDIR + local tooldir_make + possible_make=$(print_tooldir_program make) # If the above didn't work, search the PATH for a suitable # ${toolprefix}make, nbmake, bmake, or make. # @@ -2172,6 +2188,23 @@ statusmsg "Rump build&link tests successful" } +setup_mkrepro() +{ + if [ ${MKREPRO-no} != "yes" ]; then + return + fi + ${runcmd} "${makewrapper}" ${parallel} tools || + bomb "Failed to make tools" + local dirs=${NETBSDSRCDIR} + if [ ${MKX11-no} = "yes" ]; then + dirs="$dirs $X11XRCDIR" + fi + local cvslatest=$(print_tooldir_program cvslatest) + MKREPRO_TIMESTAMP=$(${cvslatest} ${dirs}) + statusmsg2 "MKREPRO_TIMESTAMP" "$(date ${MKREPRO_TIMESTAMP})" + export MKREPRO MKREPRO_TIMESTAMP +} + main() { initdefaults @@ -2224,7 +2257,14 @@ statusmsg "Built sets to ${setdir}" ;; - cleandir|obj|build|distribution|release|sourcesets|syspkgs|params) + build|distribution|release) + setup_mkrepro + ${runcmd} "${makewrapper}" ${parallel} ${op} || + bomb "Failed to make ${op}" + statusmsg "Successful make ${op}" + ;; + + cleandir|obj|sourcesets|syspkgs|params) ${runcmd} "${makewrapper}" ${parallel} ${op} || bomb "Failed to make ${op}" statusmsg "Successful make ${op}"