git: 5050b464aeda - stable/14 - release: Pass PKG_INSTALL_EPOCH to vmimage.subr

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Sat, 26 Apr 2025 19:21:45 UTC
The branch stable/14 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=5050b464aeda1d775a5f36d000daa7473a214977

commit 5050b464aeda1d775a5f36d000daa7473a214977
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2025-04-10 06:05:55 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-04-26 19:19:11 +0000

    release: Pass PKG_INSTALL_EPOCH to vmimage.subr
    
    This value, if not already set, comes from the timestamp of the most
    recent git commit (which is now also available in src/release code as
    GITEPOCH) or 0 if git is not installed.
    
    This should allow /var/db/pkg/local.sqlite to be reproducible in VM
    images which have packages installed (e.g. cloudware).
    
    Reviewed by:    emaste, bapt
    MFC after:      5 days
    Sponsored by:   Amazon
    Differential Revision:  https://reviews.freebsd.org/D49760
    
    (cherry picked from commit 81ca663642ef1ed5111a88d2e9102f6788fab407)
---
 release/Makefile.inc1 | 9 ++++++---
 release/Makefile.vm   | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/release/Makefile.inc1 b/release/Makefile.inc1
index 552b6cb60f3c..569b72df5106 100644
--- a/release/Makefile.inc1
+++ b/release/Makefile.inc1
@@ -1,6 +1,3 @@
-#
-#
-
 # Figure out where the git binary is.
 .for _P in /usr/bin /usr/local/bin
 . if !defined(GIT_CMD) || empty(GIT_CMD)
@@ -24,13 +21,19 @@ GITREV!=	${GIT_CMD} -C ${.CURDIR} rev-parse --verify --short HEAD 2>/dev/null ||
 GITCOUNT!=	${GIT_CMD} -C ${.CURDIR} rev-list --first-parent --count HEAD 2>/dev/null || true
 . export GITCOUNT
 . endif
+. if !defined(GITEPOCH) || empty(GITEPOCH)
+GITEPOCH!=	${GIT_CMD} -C ${.CURDIR} show -s --format=%ct HEAD 2>/dev/null || true
+. export GITEPOCH
+. endif
 .else
 GITBRANCH=	nullbranch
 GITREV=		nullhash
 GITCOUNT=	nullcount
+GITEPOCH=	0
 . export GITBRANCH
 . export GITREV
 . export GITCOUNT
+. export GITEPOCH
 .endif
 
 # Set the build date, primarily for snapshot builds.
diff --git a/release/Makefile.vm b/release/Makefile.vm
index 7de07c6da714..61bd42f7bfa5 100644
--- a/release/Makefile.vm
+++ b/release/Makefile.vm
@@ -174,6 +174,7 @@ vm-image:	${QEMUTGT}
 	mkdir -p ${.OBJDIR}/${.TARGET}-${FORMAT}-${FS}
 	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} SWAPSIZE=${SWAPSIZE} \
 		QEMUSTATIC=${QEMUSTATIC} \
+		PKG_INSTALL_EPOCH=${PKG_INSTALL_EPOCH:U${GITEPOCH}} \
 		${.CURDIR}/scripts/mk-vmimage.sh \
 		-C ${.CURDIR}/tools/vmimage.subr \
 		-d ${.OBJDIR}/${.TARGET}-${FORMAT}-${FS} -F ${FS} \