git: deb79782a9b8 - main - Mk/bsd.port.mk: stop ports from finding the ports tree's git repository

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Thu, 26 Dec 2024 10:47:08 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=deb79782a9b87c64d06441e4bf67e46bf19c45c3

commit deb79782a9b87c64d06441e4bf67e46bf19c45c3
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2024-11-30 13:35:18 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2024-12-26 10:46:28 +0000

    Mk/bsd.port.mk: stop ports from finding the ports tree's git repository
    
    When building from source, the ports tree is by default a parent
    directory of WRKDIR.  When ports try to use git to find the git commit
    they are built from, they'll some times find the port's git repository
    and produce bogus metadata.  Set GIT_CEILING_DIRS in WRK_ENV to ensure
    that git does not escape WRK_ENV trying to look for a git repository
    that doesn't exist.
    
    This doesn't affect Poudriere builds as for these, WRKDIR is by default
    not a subdirectory of the ports tree, and neither is git installed in
    builder jails unless explicitly needed.  As a result, bugs of this kind
    tend to go unnoticed by maintainers, but do affect source builders.
    
    Approved by:    portmgr (mat)
    Exp-run by:     antoine
    PR:             283098
    Differential Revision: https://reviews.freebsd.org/D47850
---
 Mk/bsd.port.mk | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index 01dc08c265f5..d6a6cd4c7e25 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -1615,9 +1615,12 @@ PKG_NOTES+=	flavor
 PKG_NOTE_flavor=	${FLAVOR}
 .    endif
 
+# GIT_CEILING_DIRECTORIES prevents ports that try to find their version
+# using git from finding the ports tree's git repository.
 WRK_ENV+=		HOME=${WRKDIR} \
 				MACHINE_ARCH=${MACHINE_ARCH} \
 				PWD="$${PWD}" \
+				GIT_CEILING_DIRECTORIES=${WRKDIR} \
 				__MAKE_CONF=${NONEXISTENT}
 .    for e in OSVERSION PATH TERM TMPDIR \
 				UNAME_b UNAME_i UNAME_K UNAME_m UNAME_n \