Module Name: src
Committed By: christos
Date: Sun Dec 18 02:20:30 UTC 2016
Modified Files:
src: build.sh
Log Message:
Add -P for reproducible builds based on the latest cvs timestamp.
To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/build.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/build.sh
diff -u src/build.sh:1.311 src/build.sh:1.312
--- src/build.sh:1.311 Sun Nov 13 09:47:46 2016
+++ src/build.sh Sat Dec 17 21:20:30 2016
@@ -1,5 +1,5 @@
#! /usr/bin/env sh
-# $NetBSD: build.sh,v 1.311 2016/11/13 14:47:46 ast Exp $
+# $NetBSD: build.sh,v 1.312 2016/12/18 02:20:30 christos Exp $
#
# Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -1003,7 +1003,7 @@ usage()
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 @@ Usage: ${progname} [-EhnorUuxy] [-a arch
-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 @@ _usage_
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 @@ parseoptions()
MKOBJDIRS=no
;;
+ -P)
+ MKREPRO=yes
+ ;;
+
-R)
eval ${optargcmd}; resolvepath OPTARG
setmakeenv RELEASEDIR "${OPTARG}"
@@ -1435,38 +1441,20 @@ sanitycheck()
;;
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 @@ print_tooldir_make()
)"
# 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 @@ print_tooldir_make()
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.
#
@@ -1876,7 +1892,7 @@ createmakewrapper()
eval cat <<EOF ${makewrapout}
#! ${HOST_SH}
# Set proper variables to allow easy "make" building of a NetBSD subtree.
-# Generated from: \$NetBSD: build.sh,v 1.311 2016/11/13 14:47:46 ast Exp $
+# Generated from: \$NetBSD: build.sh,v 1.312 2016/12/18 02:20:30 christos Exp $
# with these arguments: ${_args}
#
@@ -1907,8 +1923,8 @@ EOF
make_in_dir()
{
- dir="$1"
- op="$2"
+ local dir="$1"
+ local op="$2"
${runcmd} cd "${dir}" ||
bomb "Failed to cd to \"${dir}\""
${runcmd} "${makewrapper}" ${parallel} ${op} ||
@@ -2172,6 +2188,22 @@ dorump()
statusmsg "Rump build&link tests successful"
}
+setup_mkrepro()
+{
+ if [ ${MKREPRO-no} != "yes" ]; then
+ return
+ fi
+ buildtools
+ local dirs=${NETBSDSRCDIR-/usr/src}
+ if [ ${MKX11-no} = "yes" ]; then
+ dirs="$dirs ${X11SRCDIR-/usr/xsrc}"
+ fi
+ local cvslatest=$(print_tooldir_program cvslatest)
+ MKREPRO_TIMESTAMP=$(${cvslatest} ${dirs})
+ statusmsg2 "MKREPRO_TIMESTAMP" "$(date -r ${MKREPRO_TIMESTAMP})"
+ export MKREPRO MKREPRO_TIMESTAMP
+}
+
main()
{
initdefaults
@@ -2224,7 +2256,14 @@ main()
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}"