Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Oct 2025 01:37:54 GMT
From:      Lexi Winter <ivy@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 09cd3decf0fa - main - etc, ypserv: Fix symlink creation for pkgbase
Message-ID:  <202510020137.5921bsx1035605@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by ivy:

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

commit 09cd3decf0fae4b769b04c1e900ed5935c40957e
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-10-02 01:10:28 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-10-02 01:37:35 +0000

    etc, ypserv: Fix symlink creation for pkgbase
    
    The Makefile logic for /etc/aliases, /var/yp/Makefile and /etc/unbound
    tries to avoid creating the symlink if it already exists in the target,
    but this breaks with pkgbase since the symlink won't be installed (and
    therefore won't be added to METALOG) if building with an existing
    worldstage, meaning it's missing from the generated package.
    
    Change the logic to forcibly install the symlink if NO_ROOT is defined,
    but keep the existing logic for non-package builds to avoid trashing
    the user's custom symlinks on non-pkgbase installworld.
    
    MFC after:      3 seconds
    Reported by:    cperciva
    Reviewed by:    cperciva, emaste
    Sponsored by:   https://www.patreon.com/bsdivy
    Differential Revision:  https://reviews.freebsd.org/D52834
---
 etc/Makefile             | 23 +++++++++++++++--------
 usr.sbin/ypserv/Makefile |  5 ++++-
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/etc/Makefile b/etc/Makefile
index ab799b2f6c80..93d4b489ec7d 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -64,9 +64,12 @@ distribution:
 	${INSTALL_SYMLINK} -T "package=runtime" ../var/run/os-release \
 		${DESTDIR}/etc/os-release
 .if ${MK_UNBOUND} != "no"
-	if [ ! -e ${DESTDIR}/etc/unbound ]; then \
-		${INSTALL_SYMLINK} -T "package=unbound" \
-		../var/unbound ${DESTDIR}/etc/unbound; \
+# If NO_ROOT is defined, we are doing a stage install and always need to
+# install the /etc/unbound symlink, otherwise, don't overwrite the user's
+# existing symlink.
+	if [ "${NO_ROOT:Dtrue}" = true -o ! -e ${DESTDIR}/etc/unbound ]; then \
+		${INSTALL_SYMLINK} -Tpackage=unbound ../var/unbound \
+			${DESTDIR}/etc/unbound; \
 	fi
 .endif
 .if ${MK_SENDMAIL} != "no"
@@ -82,12 +85,16 @@ distribution:
 .if ${MK_MAIL} != "no"
 	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
 	    -T "package=runtime,config" ${ETCMAIL} ${DESTDIR}/etc/mail
-	if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/mail/aliases -a \
-	      ! -f ${DESTDIR}/etc/aliases ]; then \
-		${INSTALL_SYMLINK} -T "package=runtime" \
-		mail/aliases ${DESTDIR}/etc/aliases; \
+# If NO_ROOT is defined, we are doing a stage install and always need to
+# install the /etc/aliases symlink, otherwise, don't overwrite the user's
+# existing symlink.
+	if [ "${NO_ROOT:Dtrue}" = true -o \( -f ${DESTDIR}/etc/mail/aliases -a \
+	   ! -f ${DESTDIR}/etc/aliases \) ]; then \
+		${INSTALL_SYMLINK} -Tpackage=runtime mail/aliases \
+			${DESTDIR}/etc/aliases; \
 	fi
-.endif
+.endif	# ${MK_MAIL} != "no"
+
 .if ${MK_SENDMAIL} != "no"
 	cd ${.CURDIR}/mail; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 644 \
 		-T "package=sendmail" ${ETCMAIL_SENDMAIL} ${DESTDIR}/etc/mail
diff --git a/usr.sbin/ypserv/Makefile b/usr.sbin/ypserv/Makefile
index ba7eb1f86267..b4e59b719692 100644
--- a/usr.sbin/ypserv/Makefile
+++ b/usr.sbin/ypserv/Makefile
@@ -41,7 +41,10 @@ FILESNAME= Makefile.dist
 FILESDIR= /var/yp
 SCRIPTS= ypinit.sh
 
-.if !exists(${DESTDIR}${FILESDIR}/Makefile)
+# If NO_ROOT is defined, we are doing a stage install and always need to
+# install the symlink, otherwise, don't overwrite the user's existing
+# symlink.
+.if defined(NO_ROOT) || !exists(${DESTDIR}${FILESDIR}/Makefile)
 SYMLINKS= ${FILESNAME} ${FILESDIR}/Makefile
 .endif
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510020137.5921bsx1035605>