Module Name: src Committed By: msaitoh Date: Tue Sep 14 02:21:35 UTC 2021
Modified Files: src [netbsd-9]: build.sh Log Message: Pull up following revision(s) (requested by martin in ticket #1345): build.sh: revision 1.348 build.sh: revision 1.349 build.sh: revision 1.350 build.sh: revision 1.351 build.sh: revision 1.352 build.sh: revision 1.356 ignore cvslatest errors in expert mode Handle git and mercurial for reproducible builds. for mercurial, use the latest revision instead of limiting the output to 1 (requested by joerg) handle different flavors of date(1) kre@ does not like the subshell :-) Add a new operation "mkrepro-timestamp" to extract the timestamp a build with -P would use. Example usage: ./build.sh -T /usr/tools -P mkrepro-timestamp This allows us to extract this information once, make other use of it, and replicate it on other machines with -V MKREPRO=yes -V MKREPRO_TIMESTAMP=.. To generate a diff of this commit: cvs rdiff -u -r1.333 -r1.333.2.1 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.333 src/build.sh:1.333.2.1 --- src/build.sh:1.333 Fri Jun 7 15:49:20 2019 +++ src/build.sh Tue Sep 14 02:21:34 2021 @@ -1,5 +1,5 @@ #! /usr/bin/env sh -# $NetBSD: build.sh,v 1.333 2019/06/07 15:49:20 sborrill Exp $ +# $NetBSD: build.sh,v 1.333.2.1 2021/09/14 02:21:34 msaitoh Exp $ # # Copyright (c) 2001-2011 The NetBSD Foundation, Inc. # All rights reserved. @@ -1077,6 +1077,8 @@ Usage: ${progname} [-EhnoPRrUuxy] [-a ar list-arch Display a list of valid MACHINE/MACHINE_ARCH values, and exit. The list may be narrowed by passing glob patterns or exact values in MACHINE or MACHINE_ARCH. + mkrepro-timestamp Show the latest source timestamp used for reproducable + builds and exit. Requires -P or -V MKREPRO=yes. Options: -a arch Set MACHINE_ARCH to arch. [Default: deduced from MACHINE] @@ -1351,7 +1353,12 @@ parseoptions() list-arch) listarch "${MACHINE}" "${MACHINE_ARCH}" - exit $? + exit + ;; + mkrepro-timestamp) + setup_mkrepro quiet + echo ${MKREPRO_TIMESTAMP:-0} + [ ${MKREPRO_TIMESTAMP:-0} -ne 0 ]; exit ;; kernel=*|releasekernel=*|kernel.gdb=*) @@ -1937,7 +1944,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.333 2019/06/07 15:49:20 sborrill Exp $ +# Generated from: \$NetBSD: build.sh,v 1.333.2.1 2021/09/14 02:21:34 msaitoh Exp $ # with these arguments: ${_args} # @@ -2248,22 +2255,71 @@ dorump() statusmsg "Rump build&link tests successful" } +repro_date() { + # try the bsd date fail back the the linux one + date -u -r "$1" 2> /dev/null || date -u -d "@$1" +} + setup_mkrepro() { + local quiet="$1" + if [ ${MKREPRO-no} != "yes" ]; then return fi + if [ ${MKREPRO_TIMESTAMP-0} -ne 0 ]; then + return; + fi + local dirs=${NETBSDSRCDIR-/usr/src}/ if [ ${MKX11-no} = "yes" ]; then dirs="$dirs ${X11SRCDIR-/usr/xsrc}/" fi + local cvslatest=$(print_tooldir_program cvslatest) if [ ! -x "${cvslatest}" ]; then buildtools fi - MKREPRO_TIMESTAMP=$("${cvslatest}" ${dirs}) - [ -n "${MKREPRO_TIMESTAMP}" ] || bomb "Failed to compute timestamp" - statusmsg2 "MKREPRO_TIMESTAMP" "$(TZ=UTC date -r ${MKREPRO_TIMESTAMP})" + + local cvslatestflags= + if ${do_expertmode}; then + cvslatestflags=-i + fi + + MKREPRO_TIMESTAMP=0 + local d + local t + local vcs + for d in ${dirs}; do + if [ -d "${d}CVS" ]; then + t=$("${cvslatest}" ${cvslatestflags} "${d}") + vcs=cvs + elif [ -d "${d}.git" ]; then + t=$(cd "${d}" && git log -1 --format=%ct) + vcs=git + elif [ -d "${d}.hg" ]; then + t=$(cd "${d}" && + hg log -r . --template '{date(date, "%s")}\n') + vcs=hg + else + bomb "Cannot determine VCS for '$d'" + fi + + if [ -z "$t" ]; then + bomb "Failed to get timestamp for vcs=$vcs in '$d'" + fi + + #echo "latest $d $vcs $t" + if [ "$t" -gt "$MKREPRO_TIMESTAMP" ]; then + MKREPRO_TIMESTAMP="$t" + fi + done + + [ "${MKREPRO_TIMESTAMP}" != "0" ] || bomb "Failed to compute timestamp" + if [ -z "${quiet}" ]; then + statusmsg2 "MKREPRO_TIMESTAMP" \ + "$(repro_date "${MKREPRO_TIMESTAMP}")" + fi export MKREPRO MKREPRO_TIMESTAMP }