Skip to content

Commit

Permalink
stand: Use SOURCE_DATE_EPOCH in newvers.sh
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cperciva committed Feb 3, 2025
1 parent 70ccb89 commit 44a768e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion stand/common/newvers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 44a768e

Please sign in to comment.