From owner-freebsd-ports@FreeBSD.ORG Fri Jul 28 18:32:15 2006 Return-Path: X-Original-To: freebsd-ports@freebsd.org Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EC20716A4DE; Fri, 28 Jul 2006 18:32:14 +0000 (UTC) (envelope-from ssedov@mbsd.msk.ru) Received: from com1.ht-systems.ru (com1.ht-systems.ru [83.97.104.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id D8C6243D5D; Fri, 28 Jul 2006 18:32:13 +0000 (GMT) (envelope-from ssedov@mbsd.msk.ru) Received: from [217.118.83.1] (helo=fonon.realnet) by com1.ht-systems.ru with esmtpa (Exim 4.62) (envelope-from ) id 1G6XFq-0000uJ-UD; Fri, 28 Jul 2006 22:40:14 +0400 Received: by fonon.realnet (Postfix, from userid 1001) id 2CC651209D; Fri, 28 Jul 2006 22:31:47 +0400 (MSD) To: FreeBSD-gnats-submit@freebsd.org From: Stanislav Sedov X-send-pr-version: 3.113 X-GNATS-Notify: Message-Id: <20060728183147.2CC651209D@fonon.realnet> Date: Fri, 28 Jul 2006 22:31:47 +0400 (MSD) X-Spam-Flag: SKIP X-Spam-Yversion: Spamooborona 1.5.2 Cc: freebsd-ports@freebsd.org Subject: add macro to dial with directory trees X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jul 2006 18:32:15 -0000 >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 >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 ---