git: 91970dfbaf29 - stable/15 - pkgbootstrap: Gate building from ports

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Sat, 20 Sep 2025 23:28:08 UTC
The branch stable/15 has been updated by cperciva:

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

commit 91970dfbaf29ec4902f95a346ffe6c14e4498b01
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2025-09-19 16:46:21 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-09-20 13:50:56 +0000

    pkgbootstrap: Gate building from ports
    
    In release builds we want to build pkg from the ports tree for reasons
    mentioned in a previous commit; but non-release pkgbase builds may be
    just fine with installing pkg from pkg.freebsd.org.
    
    Gate it behind BOOTSTRAP_PKG_FROM_PORTS rather than building form ports
    any time we have a ports tree available.
    
    While I'm here, make the pkgbase-repo target in release/Makefile
    create the temporary directories we need for building.
    
    Reviewed by:    ivy
    MFC after:      6 hours
    Sponsored by:   https://www.patreon.com/cperciva
    Fixes:  2c06b824436d ("pkgbootstrap: Build pkg if PORTSDIR exists")
    
    (cherry picked from commit e87b75a8bfc8fb7fda8225e55255d9ad99cdefb2)
---
 Makefile.inc1    | 2 +-
 release/Makefile | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 65149beb9eb6..6744a25965c6 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -1992,7 +1992,7 @@ PKG_ABI!=	${PKG_CMD} -o ABI_FILE=${PKG_ABI_FILE} config ABI
 
 _pkgbootstrap: .PHONY
 .if make(*package*) && !exists(${LOCALBASE}/sbin/pkg)
-.if exists(${PORTSDIR}/ports-mgmt/pkg/Makefile)
+.if defined(BOOTSTRAP_PKG_FROM_PORTS)
 	env - UNAME_r=${UNAME_r} PATH=$$PATH \
 	    make -C ${PORTSDIR}/ports-mgmt/pkg \
 	    I_DONT_CARE_IF_MY_BUILDS_TARGET_THE_WRONG_RELEASE=1 \
diff --git a/release/Makefile b/release/Makefile
index 3d1e2d44e4a8..35eae4083d14 100644
--- a/release/Makefile
+++ b/release/Makefile
@@ -195,8 +195,9 @@ PKG_ABI=	$$(${PKG_CMD} -o ABI_FILE=${.TARGET}/usr/bin/uname config ABI)
 
 pkgbase-repo:
 	mkdir -p pkgbase-repo
+	mkdir -p /tmp/ports /tmp/distfiles
 	( ${IMAKE} -C ${WORLDDIR} packages REPODIR=${.OBJDIR}/pkgbase-repo \
-	    INCLUDE_PKG_IN_PKGBASE_REPO=YES )
+	    INCLUDE_PKG_IN_PKGBASE_REPO=YES BOOTSTRAP_PKG_FROM_PORTS=YES )
 
 disc1: ${PKGBASE_REPO}
 # Install system