add macro to dial with directory trees

Stanislav Sedov ssedov at
Fri Jul 28 18:32:15 UTC 2006

>Submitter-Id:	current-users
>Originator:	Stanislav Sedov
>Organization:	MBSD labs, Inc.
>Confidential:	no 
>Synopsis:	add macro to dial with directory trees
>Severity:	non-critical
>Priority:	medium
>Category:	ports
>Class:		change-request
>Release:	FreeBSD 7.0-CURRENT i386
System: FreeBSD fonon.realnet 7.0-CURRENT FreeBSD 7.0-CURRENT #7: Sun Jun 18 20:51:36 MSD 2006 root at fonon.realnet:/work/src/fbsd-cur/src/sys/i386/compile/FONON i386

        We have a lot of ports (thousands, actually), that need
        to copy entire directory trees to specific location,
        e.g. when installing examples for port one could issue:

        @${TAR} -cf - -C ${WRKSRC} copyfs cryptfs gzipfs uuencodefs tests | \
                       ${TAR} -xf - -C ${EXAMPLESDIR}
        @${FIND} ${EXAMPLESDIR} -type f -exec ${CHMOD} ${SHAREMODE} {} \;
        @${FIND} ${EXAMPLESDIR} -exec ${CHOWN} ${SHAREOWN} {} \;

        There are many other solutions (e.g. using PAX, FIND, CPIO combinations)
        , buth every require one important step - set up permissions for
        installed files, since this files are not processed by INSTALL_XXX

        A lot of ports usually forget to do this - I began to fix some
        of them - but it's tedios and giant work...

        The macros introduced allows to dial with such tree ierarchies
        in handy and efficient way. For previos example one can use:

        cd ${WRKSRC} && ${COPYTREE_SHARE} "copyfs cryptfs gzipfs uuencodefs test
        s" "${EXAMPLESDIR}"

        and that's all.

        I decided to use CPIO (though I don't like it)  since it can be used
        with find program, that allows to manipulate on file sets with a great
        power. Additional commands to FIND program might be passed by third
        argument to macro, e.g. to eclude 'Makefile" file we can use:
        cd ${WRKSRC} && ${COPYTREE_BIN} docs "${DOCSDIR}" "! -name Makefile"
        Thus, this macro allows to use the whole power of FIND program.

	Also, I've used "-l" swith in CPIO to speed-up copies in some
	cases. That's why I've redirected cpio output to /dev/null ;-)

        It would be nice to have you comments/suggestions here. Thanks!



--- portmk.diff begins here ---
---	Fri Jul 28 22:09:42 2006
+++	Fri Jul 28 22:13:32 2006
@@ -1970,6 +1970,18 @@
+# Macro for coping entire directory tree with correct permissions
+COPYTREE_BIN=	${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \
+					2>&1) && \
+					${CHOWN} -R ${BINOWN}:${BINGRP} $$1 && \
+					${FIND} $$1 -type d -exec chmod 755 {} \; && \
+					${FIND} $$1 -type f -exec chmod ${BINMODE} {} \;' --
+COPYTREE_SHARE=	${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \
+					2>&1) && \
+					${CHOWN} -R ${SHAREOWN}:${SHAREGRP} $$1 && \
+					${FIND} $$1 -type d -exec chmod 755 {} \; && \
+					${FIND} $$1 -type f -exec chmod ${SHAREMODE} {} \;' --
 # Names of cookies used to skip already completed stages
 EXTRACT_COOKIE?=	${WRKDIR}/.extract_done.${PORTNAME}.${PREFIX:S/\//_/g}
 CONFIGURE_COOKIE?=	${WRKDIR}/.configure_done.${PORTNAME}.${PREFIX:S/\//_/g}
--- portmk.diff ends here ---

More information about the freebsd-ports mailing list