Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Jul 2006 22:31:47 +0400 (MSD)
From:      Stanislav Sedov <ssedov@mbsd.msk.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        freebsd-ports@FreeBSD.org
Subject:   ports/100996: add macro to dial with directory trees
Message-ID:  <20060728183147.2CC651209D@fonon.realnet>
Resent-Message-ID: <200607281840.k6SIeE0O097583@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         100996
>Category:       ports
>Synopsis:       add macro to dial with directory trees
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 28 18:40:14 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Stanislav Sedov
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
MBSD labs, Inc.
>Environment:
System: FreeBSD fonon.realnet 7.0-CURRENT FreeBSD 7.0-CURRENT #7: Sun Jun 18 20:51:36 MSD 2006 root@fonon.realnet:/work/src/fbsd-cur/src/sys/i386/compile/FONON i386


	
>Description:
        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
        program.

        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!

>How-To-Repeat:
	
>Fix:

	

--- portmk.diff begins here ---
--- bsd.port.mk.orig	Fri Jul 28 22:09:42 2006
+++ bsd.port.mk	Fri Jul 28 22:13:32 2006
@@ -1970,6 +1970,18 @@
 REINPLACE_ARGS?=	-i.bak
 REINPLACE_CMD?=	${SED} ${REINPLACE_ARGS}
 
+# 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 ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060728183147.2CC651209D>