summaryrefslogtreecommitdiffstats
path: root/sys/conf/newvers.sh
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2016-01-07 17:00:35 +0000
committeremaste <emaste@FreeBSD.org>2016-01-07 17:00:35 +0000
commite7b112012dcca2e1a25fae7b7f859d56c3ae6266 (patch)
tree37d6f87f440f84c000f69293ff7e9f4b514fc215 /sys/conf/newvers.sh
parent8c4e8fd3fd280f39cdbd53cf5317ec7cb2bb7914 (diff)
downloadFreeBSD-src-e7b112012dcca2e1a25fae7b7f859d56c3ae6266.zip
FreeBSD-src-e7b112012dcca2e1a25fae7b7f859d56c3ae6266.tar.gz
MFC r291691: newvers: Honour SOURCE_DATE_EPOCH for build reproducibility
One reason the kernel does not build reproducibly is that it includes a timestamp in the version string. SOURCE_DATE_EPOCH provides a standard method to address this: it should be set to the last modification time of the source, and build processes use the specified timestamp instead of the "current" date and time. This change uses SOURCE_DATE_EPOCH if it is set; how it gets set needs to be addressed elsewhere.
Diffstat (limited to 'sys/conf/newvers.sh')
-rw-r--r--sys/conf/newvers.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
index 55ac59b..97bec5c 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -87,7 +87,15 @@ then
fi
touch version
-v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date`
+v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`}
+if [ -n "$SOURCE_DATE_EPOCH" ]; then
+ if ! t=`date -r $SOURCE_DATE_EPOCH 2>/dev/null`; then
+ echo "Invalid SOURCE_DATE_EPOCH" >&2
+ exit 1
+ fi
+else
+ t=`date`
+fi
i=`${MAKE:-make} -V KERN_IDENT`
compiler_v=$($(${MAKE:-make} -V CC) -v 2>&1 | grep 'version')
OpenPOWER on IntegriCloud