git: d2a824c29d69 - main - share/mk: Don't install only differing in case files on case insensitive fs

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 15 Mar 2024 15:02:00 UTC
The branch main has been updated by imp:

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

commit d2a824c29d6925ba8675a811aa81f2ad7d92129d
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-03-15 04:33:33 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-03-15 15:01:25 +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
---
 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 c80c618e48db..2845d0c1fc1c 100644
--- a/share/mk/bsd.man.mk
+++ b/share/mk/bsd.man.mk
@@ -234,6 +234,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}
@@ -241,6 +243,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: