stand: Use SOURCE_DATE_EPOCH in newvers.sh

The newvers.sh script is used to generate vers.c for 10 programs (at
latest count on amd64): 4 EFI loaders, 3 x86 loaders, two userboots,
and one kboot.  When building without MK_REPRODUCIBLE_BUILD this
resulted in 10 different timestamps being compiled into various files.

If SOURCE_DATE_EPOCH is set, use that value rather than the current
date and time.

Reviewed by:	emaste, imp
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D48803
This commit is contained in:
Colin Percival
2025-02-02 19:37:56 -08:00
parent 70ccb89db2
commit 44a768e1a8
+9 -1
View File
@@ -43,7 +43,15 @@ done
shift $((OPTIND - 1))
LC_ALL=C; export LC_ALL
u=${USER-root} h=${HOSTNAME-`hostname`} t=`date`
u=${USER-root} h=${HOSTNAME-`hostname`}
if [ -n "$SOURCE_DATE_EPOCH" ]; then
if ! t=$(date -ur $SOURCE_DATE_EPOCH 2>/dev/null); then
echo "Invalid SOURCE_DATE_EPOCH" >&2
exit 1
fi
else
t=`date`
fi
r=`awk -F: ' /^[0-9]\.[0-9]+:/ { print $1; exit }' $1`
bootprog_info="FreeBSD/${3} ${2}, Revision ${r}\\n"