git: 656183c21b58 - stable/14 - share/mk: Don't install only differing in case files on case insensitive fs

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 16 Apr 2024 20:12:17 UTC
The branch stable/14 has been updated by imp:

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

commit 656183c21b58cf6fe9b8c8ee78d2a9245b11fedd
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-03-15 04:33:33 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-04-16 19:54:20 +0000

    share/mk: Don't install only differing in case files on case insensitive fs
    
    MacOS has case insensitive filesystems by default. So trying to link
    between foo.X and FOO.X causes an error of some sort since we unlink the
    old foo file destroying the newly installed foo due to the insensitive
    nature of the FS. Assume that this is true on darwin/macos, though it is
    only try by default there.
    
    Perhaps install should grow smarts to know when this is the case, though
    that looked much trickier. There didn't seem to be a flag to check. This
    would be better, imho, since we could still write the METALOG data
    correctly (images created from these metalogs are imperfect due to this
    relatively issue...).
    
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D44347
    
    (cherry picked from commit d2a824c29d6925ba8675a811aa81f2ad7d92129d)
---
 share/mk/bsd.links.mk | 6 ++++++
 share/mk/bsd.man.mk   | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/share/mk/bsd.links.mk b/share/mk/bsd.links.mk
index 6070979612bf..437ffd0d3b34 100644
--- a/share/mk/bsd.links.mk
+++ b/share/mk/bsd.links.mk
@@ -14,16 +14,22 @@ afterinstall: _installlinks
 .ORDER: realinstall _installlinks
 _installlinks:
 .for s t in ${LINKS}
+# On MacOS, assume case folding FS, and don't install links from foo.x to FOO.x.
+.if ${.MAKE.OS} != "Darwin" || ${s:tu} != ${t:tu}
 .if defined(LINKTAGS)
 	${INSTALL_LINK} ${TAG_ARGS:D${TAG_ARGS},${LINKTAGS}} ${DESTDIR}${s} ${DESTDIR}${t}
 .else
 	${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}${s} ${DESTDIR}${t}
 .endif
+.endif
 .endfor
 .for s t in ${SYMLINKS}
+# On MacOS, assume case folding FS, and don't install links from foo.x to FOO.x.
+.if ${.MAKE.OS} != "Darwin" || ${s:tu} != ${t:tu}
 .if defined(LINKTAGS)
 	${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},${LINKTAGS}} ${s} ${DESTDIR}${t}
 .else
 	${INSTALL_SYMLINK} ${TAG_ARGS} ${s} ${DESTDIR}${t}
 .endif
+.endif
 .endfor
diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk
index 444144e6d626..04316c46b705 100644
--- a/share/mk/bsd.man.mk
+++ b/share/mk/bsd.man.mk
@@ -229,6 +229,8 @@ maninstall: ${MAN}
 .endif	# ${MK_MANCOMPRESS} == "no"
 .endif
 .for l t in ${_MANLINKS}
+# On MacOS, assume case folding FS, and don't install links from foo.x to FOO.x.
+.if ${.MAKE.OS} != "Darwin" || ${l:tu} != ${t:tu}
 .if ${MK_MANSPLITPKG} == "no"
 	rm -f ${DESTDIR}${t} ${DESTDIR}${t}${MCOMPRESS_EXT}; \
 	    ${INSTALL_MANLINK} ${TAG_ARGS} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT}
@@ -236,6 +238,7 @@ maninstall: ${MAN}
 	rm -f ${DESTDIR}${t} ${DESTDIR}${t}${MCOMPRESS_EXT}; \
 	    ${INSTALL_MANLINK} ${TAG_ARGS:D${TAG_ARGS},man} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT}
 .endif
+.endif
 .endfor
 
 manlint: