This is related to my previous mail on groups and permissions of
gnu/usr.bin/cc.  include/Makefile does a recursive chown and sets
permissions of the headers and directories explicitly, but installs some
more headers afterward.

Let's move the chown and chmod to later. I changed chmod -R to chmod -RP
to set the owner and group of symlinks explicitly (the symlinks point to
files under /usr/include, so these files got chowned twice).  Set the
permissions of the symlinks explicitly in the second find command since
those are subject to the umask.

Index: include/Makefile
===================================================================
RCS file: /var/cvs/src/include/Makefile,v
retrieving revision 1.214
diff -u -p -r1.214 Makefile
--- include/Makefile    16 Oct 2016 19:28:44 -0000      1.214
+++ include/Makefile    8 Nov 2016 11:34:19 -0000
@@ -92,15 +92,15 @@ includes:
                rm -f ${DESTDIR}/usr/include/$$i && \
                ln -s machine/$$i ${DESTDIR}/usr/include/$$i; \
        done
-       chown -R ${BINOWN}:${BINGRP} ${DESTDIR}/usr/include
-       find ${DESTDIR}/usr/include -type f -print0 | \
-               xargs -0r chmod a=r
-       find ${DESTDIR}/usr/include -type d -print0 | \
-               xargs -0r chmod u=rwx,go=rx
        @for i in ${RDIRS}; do \
                echo installing in ${.CURDIR}/$$i; \
                cd ${.CURDIR}/$$i && ${RUN_MAKE}; \
        done
+       chown -RP ${BINOWN}:${BINGRP} ${DESTDIR}/usr/include
+       find ${DESTDIR}/usr/include -type f -print0 | \
+               xargs -0r chmod a=r
+       find ${DESTDIR}/usr/include \( -type d -o -type l \) -print0 | \
+               xargs -0r chmod -h u=rwx,go=rx
 
 copies:
        @echo copies: ${LDIRS}

Reply via email to