git: f103de98b855 - stable/14 - sh, csh: Add config tag to /.profile and /.cshrc

From: Lexi Winter <ivy_at_FreeBSD.org>
Date: Wed, 10 Sep 2025 20:41:41 UTC
The branch stable/14 has been updated by ivy:

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

commit f103de98b855e69f1c0e1e90f7a174ae06acf892
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-09-02 08:22:56 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-09-10 20:41:08 +0000

    sh, csh: Add config tag to /.profile and /.cshrc
    
    The file /.profile is installed as a hard link to /root/.profile. The
    file in /root has the config tag, but the file in / does not, which
    causes it to be overwritten by pkg upgrade. Since they're linked, this
    also overwrites the file in /root.
    
    Add the config tag to the file in / as well, so pkg treates both links
    as config files and won't overwrite them.
    
    For stable/14, also add this to /.cshrc, which is no longer installed
    in 15.0.
    
    PR:             289097
    MFC after:      3 days
    Reviewed by:    bapt, emaste
    Differential Revision:  https://reviews.freebsd.org/D52162
    
    (cherry picked from commit aa730a66bc74696df85b21ec2719c75d8eab8c9f)
    
    sh: Fix non-NO_ROOT installconfig
    
    When building without NO_ROOT, ${TAG_ARGS} is not set, which means we
    pass ",config" as an install(1) argument.  Only add the config tag if
    ${TAG_ARGS} is defined to begin with.
    
    Fixes:  aa730a66bc74 ("sh: Add config tag to /.profile")
    Reported by:    bz
    
    (cherry picked from commit b197d2abcb6895d78bc9df8404e374397aa44748)
---
 bin/csh/Makefile | 4 ++--
 bin/sh/Makefile  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bin/csh/Makefile b/bin/csh/Makefile
index 7e20c187dee2..712341ba2c26 100644
--- a/bin/csh/Makefile
+++ b/bin/csh/Makefile
@@ -172,7 +172,7 @@ beforeinstallconfig:
 afterinstallconfig:
 	# XXX Set link mode explicitly via -m.  We cannot use LINKMODE for this
 	# link, as it would also apply to the tcsh link above.
-	${INSTALL_LINK} ${TAG_ARGS} -m ${CONFMODE} ${DESTDIR}/root/.cshrc \
-	    ${DESTDIR}/.cshrc
+	${INSTALL_LINK} ${TAG_ARGS:D${TAG_ARGS},config} -m ${CONFMODE} \
+	    ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc
 
 .include <bsd.prog.mk>
diff --git a/bin/sh/Makefile b/bin/sh/Makefile
index 48b6d2852444..7197b248189c 100644
--- a/bin/sh/Makefile
+++ b/bin/sh/Makefile
@@ -76,6 +76,6 @@ beforeinstallconfig:
 
 LINKMODE=${CONFMODE}
 afterinstallconfig:
-	${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
+	${INSTALL_LINK} ${TAG_ARGS:D${TAG_ARGS},config} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
 
 .include <bsd.prog.mk>