Source-Changes-HG archive

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

[src/netbsd-8]: src Pull up following revision(s) (requested by martin in tic...



details:   https://anonhg.NetBSD.org/src/rev/46ffd027ec2f
branches:  netbsd-8
changeset: 986244:46ffd027ec2f
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Sep 15 05:07:42 2021 +0000

description:
Pull up following revision(s) (requested by martin in ticket #1695):
        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=..

diffstat:

 build.sh |  68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 62 insertions(+), 6 deletions(-)

diffs (117 lines):

diff -r dcf79dd70b89 -r 46ffd027ec2f build.sh
--- a/build.sh  Tue Sep 07 22:29:07 2021 +0000
+++ b/build.sh  Wed Sep 15 05:07:42 2021 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/env sh
-#      $NetBSD: build.sh,v 1.316.4.2 2018/02/26 13:52:00 martin Exp $
+#      $NetBSD: build.sh,v 1.316.4.3 2021/09/15 05:07:42 msaitoh Exp $
 #
 # Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1052,6 +1052,8 @@
     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]
@@ -1323,7 +1325,12 @@
 
                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=*)
@@ -1907,7 +1914,7 @@
        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.316.4.2 2018/02/26 13:52:00 martin Exp $
+# Generated from:  \$NetBSD: build.sh,v 1.316.4.3 2021/09/15 05:07:42 msaitoh Exp $
 # with these arguments: ${_args}
 #
 
@@ -2203,22 +2210,71 @@
        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
 }
 



Home | Main Index | Thread Index | Old Index