git: 3238878379d3 - main - newvers: Add a builddir parameter
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 21 Aug 2025 15:58:20 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=3238878379d3bd4bb9796ccb41c090139bbde94f
commit 3238878379d3bd4bb9796ccb41c090139bbde94f
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-08-21 14:05:19 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-08-21 15:56:23 +0000
newvers: Add a builddir parameter
When reproducible builds are configured, we should use /usr/obj as the
canonical objdir. Add a parameter to newvers.sh to ensure that build
metadata is reproducible.
Reviewed by: emaste
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D50954
---
sys/conf/kern.post.mk | 2 +-
sys/conf/newvers.sh | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk
index 1accd3fa8df4..bb3c7af82a4d 100644
--- a/sys/conf/kern.post.mk
+++ b/sys/conf/kern.post.mk
@@ -467,7 +467,7 @@ config.o env.o hints.o vers.o vnode_if.o:
NEWVERS_ENV+= MAKE="${MAKE}"
.if ${MK_REPRODUCIBLE_BUILD} != "no"
-NEWVERS_ARGS+= -R
+NEWVERS_ARGS+= -R -d ${PREFIX_OBJDIR}
.endif
vers.c: .NOMETA_CMP $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP:Nvers.*}
${NEWVERS_ENV} sh $S/conf/newvers.sh ${NEWVERS_ARGS} ${KERN_IDENT}
diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
index 66926805052c..8b60da95741e 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -110,14 +110,18 @@ COPYRIGHT="$COPYRIGHT
# We expand include_metadata later since we may set it to the
# future value of modified.
+builddir=$(pwd)
include_metadata=yes
modified=no
-while getopts crRvV: opt; do
+while getopts cd:rRvV: opt; do
case "$opt" in
c)
echo "$COPYRIGHT"
exit 0
;;
+ d)
+ builddir=$OPTARG
+ ;;
r)
include_metadata=no
;;
@@ -187,7 +191,7 @@ fi
touch version
v=$(cat version)
u=${USER:-root}
-d=$(pwd)
+d=$builddir
h=${HOSTNAME:-$(hostname)}
if [ -n "$SOURCE_DATE_EPOCH" ]; then
if ! t=$(date -ur $SOURCE_DATE_EPOCH 2>/dev/null); then