aboutsummaryrefslogtreecommitdiff
path: root/sys/conf/newvers.sh
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2015-12-03 12:17:09 +0000
committerEd Maste <emaste@FreeBSD.org>2015-12-03 12:17:09 +0000
commit484df459f0ab50671bf5c8440f7b9f91a446858f (patch)
tree1dc7f5aab51972f5b5712de1fa2df09689fabd67 /sys/conf/newvers.sh
parent9ce5ab9ce6e7fc15345d6b36ba431afa9581897f (diff)
downloadsrc-484df459f0ab50671bf5c8440f7b9f91a446858f.tar.gz
src-484df459f0ab50671bf5c8440f7b9f91a446858f.zip
newvers: Honour SOURCE_DATE_EPOCH as a build reproducibility measure
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. Reviewed by: bapt MFC after: 1 week Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=291691
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 2239ac673ab7..fc812c515e2d 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -97,7 +97,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 -w 'version')