git: 445421abc914 - main - Makefile.inc1: Honour DB_FROM_SRC for NO_ROOT distributeworld

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Fri, 15 Jul 2022 22:18:02 UTC
The branch main has been updated by jrtc27:

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

commit 445421abc914536d6c36327a5dd1d1cd71e55a15
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2022-07-15 22:03:49 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2022-07-15 22:03:49 +0000

    Makefile.inc1: Honour DB_FROM_SRC for NO_ROOT distributeworld
    
    Currently the host's database files are used, but on non-FreeBSD these
    are not necessarily sufficient; in particular, Linux does not have a
    wheel group. Instead, use -N to use the in-tree database files when
    creating the METALOG entries, as is done for the recursive makes via
    IMAKE_MTREE.
    
    Reviewed by:    brooks
    Obtained from:  CheriBSD
    Differential Revision:  https://reviews.freebsd.org/D35810
---
 Makefile.inc1 | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 73bbba7fef54..43cd3c3344c8 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -964,12 +964,16 @@ WORLDTMP_MTREEFLAGS=	-deUW
 # that are created by mtree to be owned by root/wheel.
 DESTDIR_MTREEFLAGS+=	-W
 .endif
-DISTR_MTREE=	${MTREE_CMD}
+.if defined(DB_FROM_SRC)
+DISTR_MTREEFLAGS=	-N ${.CURDIR}/etc
+.endif
+DISTR_MTREECMD=	${MTREE_CMD}
 .if ${BUILD_WITH_STRICT_TMPPATH} != 0
-DISTR_MTREE=	${WORLDTMP}/legacy/usr/sbin/mtree
+DISTR_MTREECMD=	${WORLDTMP}/legacy/usr/sbin/mtree
 .endif
-WORLDTMP_MTREE=	${DISTR_MTREE} ${WORLDTMP_MTREEFLAGS}
-DESTDIR_MTREE=	${DISTR_MTREE} ${DESTDIR_MTREEFLAGS}
+DISTR_MTREE=	${DISTR_MTREECMD} ${DISTR_MTREEFLAGS}
+WORLDTMP_MTREE=	${DISTR_MTREECMD} ${WORLDTMP_MTREEFLAGS}
+DESTDIR_MTREE=	${DISTR_MTREECMD} ${DESTDIR_MTREEFLAGS}
 
 # kernel stage
 KMAKEENV=	${WMAKEENV:NSYSROOT=*}