Index: head/share/mk/src.opts.mk =================================================================== --- head/share/mk/src.opts.mk +++ head/share/mk/src.opts.mk @@ -190,6 +190,7 @@ OFED \ OPENLDAP \ RCS \ + REPRODUCIBLE_BUILD \ SHARED_TOOLCHAIN \ SORT_THREADS \ SVN \ Index: head/sys/boot/common/Makefile.inc =================================================================== --- head/sys/boot/common/Makefile.inc +++ head/sys/boot/common/Makefile.inc @@ -74,5 +74,9 @@ 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} Index: head/sys/boot/common/newvers.sh =================================================================== --- head/sys/boot/common/newvers.sh +++ head/sys/boot/common/newvers.sh @@ -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 Index: head/tools/build/options/WITH_REPRODUCIBLE_BUILD =================================================================== --- head/tools/build/options/WITH_REPRODUCIBLE_BUILD +++ head/tools/build/options/WITH_REPRODUCIBLE_BUILD @@ -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.