git: db6f2bb93a97 - main - Makefile.inc1: Conditionalize some package related variables

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 10 Mar 2025 17:30:57 UTC
The branch main has been updated by jhb:

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

commit db6f2bb93a9706963f66d270edb5ee62c37a9296
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-03-10 17:30:26 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-03-10 17:30:26 +0000

    Makefile.inc1: Conditionalize some package related variables
    
    In particular, don't invoke git to compute SOURCE_DATE_EPOCH for
    unrelated targets like check-old or delete-old.  If the git invocation
    fails (e.g. when using a git worktree mounted over NFS) it can
    generate a lot of irrelevant warning spam.
    
    Reviewed by:    emaste
    Fixes:          8a3537aaf7c1 ("Makefile.inc1: Make package timestamps reproducible by default")
    Differential Revision:  https://reviews.freebsd.org/D49278
---
 Makefile.inc1 | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 0b4167790133..9cd4d3b63cae 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -596,6 +596,7 @@ PKG_VERSION:=	${_PKG_REVISION}${EXTRA_REVISION:C/[[:space:]]//g}
 .endif
 .endif	# !defined(_MKSHOWCONFIG)
 
+.if make(*package*)
 .if !defined(PKG_TIMESTAMP)
 .if !empty(GIT_CMD) && exists(${GIT_CMD}) && exists(${SRCDIR}/.git)
 SOURCE_DATE_EPOCH!=	${GIT_CMD} -C ${SRCDIR} show -s --format=%ct HEAD
@@ -614,6 +615,7 @@ PKG_WWW?=		https://www.FreeBSD.org
 .export PKG_NAME_PREFIX
 .export PKG_MAINTAINER
 .export PKG_WWW
+.endif
 
 .if !defined(_MKSHOWCONFIG)
 _CPUTYPE!=	MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \