svn commit: r310268 - in head: share/mk sys/boot/common tools/build/options

Ed Maste emaste at FreeBSD.org
Mon Dec 19 14:46:00 UTC 2016


Author: emaste
Date: Mon Dec 19 14:45:59 2016
New Revision: 310268
URL: https://svnweb.freebsd.org/changeset/base/310268

Log:
  Build loaders reproducibly when WITH_REPRODUCIBLE_BUILD
  
  When WITH_REPRODUCIBLE_BUILD=yes is set in src.conf(5), eliminate the
  time, user, and host from the loader's version information.  This allows
  builds to produce bit-for-bit identical output.
  
  Reviewed by:	bapt
  MFC after:	1 month
  Relnotes:	yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D8842

Modified:
  head/share/mk/src.opts.mk
  head/sys/boot/common/Makefile.inc
  head/sys/boot/common/newvers.sh
  head/tools/build/options/WITH_REPRODUCIBLE_BUILD

Modified: head/share/mk/src.opts.mk
==============================================================================
--- head/share/mk/src.opts.mk	Mon Dec 19 14:40:59 2016	(r310267)
+++ head/share/mk/src.opts.mk	Mon Dec 19 14:45:59 2016	(r310268)
@@ -190,6 +190,7 @@ __DEFAULT_NO_OPTIONS = \
     OFED \
     OPENLDAP \
     RCS \
+    REPRODUCIBLE_BUILD \
     SHARED_TOOLCHAIN \
     SORT_THREADS \
     SVN \

Modified: head/sys/boot/common/Makefile.inc
==============================================================================
--- head/sys/boot/common/Makefile.inc	Mon Dec 19 14:40:59 2016	(r310267)
+++ head/sys/boot/common/Makefile.inc	Mon Dec 19 14:45:59 2016	(r310268)
@@ -74,5 +74,9 @@ CFLAGS+=-I${.CURDIR}/../../../../lib/lib
 
 CLEANFILES+=	vers.c
 VERSION_FILE?=	${.CURDIR}/version
+.if ${MK_REPRODUCIBLE_BUILD} != no
+REPRO_FLAG=	-r
+.endif
 vers.c: ${SRCTOP}/sys/boot/common/newvers.sh ${VERSION_FILE}
-	sh ${SRCTOP}/sys/boot/common/newvers.sh ${VERSION_FILE} ${NEWVERSWHAT}
+	sh ${SRCTOP}/sys/boot/common/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \
+	    ${NEWVERSWHAT}

Modified: head/sys/boot/common/newvers.sh
==============================================================================
--- head/sys/boot/common/newvers.sh	Mon Dec 19 14:40:59 2016	(r310267)
+++ head/sys/boot/common/newvers.sh	Mon Dec 19 14:45:59 2016	(r310268)
@@ -35,11 +35,26 @@
 tempfile=$(mktemp tmp.XXXXXX) || exit
 trap "rm -f $tempfile" EXIT INT TERM
 
+include_metadata=true
+while getopts r opt; do
+	case "$opt" in
+	r)
+		include_metadata=
+		;;
+	esac
+done
+shift $((OPTIND - 1))
+
 LC_ALL=C; export LC_ALL
 u=${USER-root} h=${HOSTNAME-`hostname`} t=`date`
 #r=`head -n 6 $1 | tail -n 1 | awk -F: ' { print $1 } '`
 r=`awk -F: ' /^[0-9]\.[0-9]+:/ { print $1; exit }' $1`
 
-echo "char bootprog_info[] = \"FreeBSD/${3} ${2}, Revision ${r}\\n(${t} ${u}@${h})\\n\";" > $tempfile
+bootprog_info="FreeBSD/${3} ${2}, Revision ${r}\\n"
+if [ -n "${include_metadata}" ]; then
+	bootprog_info="$bootprog_info(${t} ${u}@${h})\\n"
+fi
+
+echo "char bootprog_info[] = \"$bootprog_info\";" > $tempfile
 echo "unsigned bootprog_rev = ${r%%.*}${r##*.};" >> $tempfile
 mv $tempfile vers.c

Modified: head/tools/build/options/WITH_REPRODUCIBLE_BUILD
==============================================================================
--- head/tools/build/options/WITH_REPRODUCIBLE_BUILD	Mon Dec 19 14:40:59 2016	(r310267)
+++ head/tools/build/options/WITH_REPRODUCIBLE_BUILD	Mon Dec 19 14:45:59 2016	(r310268)
@@ -1,3 +1,4 @@
 $FreeBSD$
-Set to exclude build metadata (build time, user, host and path) from the
-kernel and uname output.
+Set to exclude build metadata (such as the build time, user, or host)
+from the kernel, boot loaders, and uname output, so that builds produce
+bit-for-bit identical output.


More information about the svn-src-head mailing list