Date: Sun, 6 Jul 2014 16:34:30 +0200 (CEST) From: Melvyn Sopacua <melvyn@magemana.nl> To: Pawel Pekala <pawel@FreeBSD.org> Cc: freebsd-ports@freebsd.org Subject: Re: COPYTREE_BIN/COPYTREE_SHARE does not work as expected Message-ID: <alpine.BSF.2.00.1407061621430.932@fire.magemana.nl> In-Reply-To: <20140706153509.2d9dead2@FreeBSD.org> References: <20140705120457.GA1772@gmail.com> <20140706153509.2d9dead2@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, On Sun, 6 Jul 2014, Pawel Pekala wrote: > Dnia 2014-07-05, o godz. 12:04:57 > Mikolaj Golub <trociny@FreeBSD.org> napisał(a): > >> Hi, >> >> It looks like COPYTREE_BIN/COPYTREE_SHARE does not work as it is >> documented in bsd.port.mk: >> >> # Example use: >> # cd ${WRKSRC}/doc && ${COPYTREE_SHARE} . ${DOCSDIR} >> "! -name *.bak" # >> # Installs all directories and files from ${WRKSRC}/doc >> # to ${DOCSDIR} except sed backup files. >> >> If there is a "*.bak" file in . directory (e.g. test.bak), "*.bak" is >> expanded to this name, the condition "! -name *.bak" becomes "! -name >> test.bak", and other *.bak files are ignored. >> >> Worse, if there are several "*.bak" files, "*.bak" is expanded to the >> list and COPYTREE_SHARE fails. > > I made a mistake while documenting this macros, as '*' is a shell > wildcard it should be quoted. I believe the correct example should be: > > cd ${WRKSRC}/doc && ${COPYTREE_SHARE} . ${DOCSDIR} "! -name "*.bak"" It can't be done. sh -c will escape quotes. I've simplified the test and modified it to show what's going on. Your example doesn't escape the quotes, so quotes end and globbing starts. The normal way to specify a glob to -name is '*.bak', so let's see how that works out: /bin/rm -rf /tmp/test_COPYTREE_SHARE /bin/mkdir -p /tmp/test_COPYTREE_SHARE/src/1 /usr/bin/touch /tmp/test_COPYTREE_SHARE/src/1.bak /usr/bin/touch /tmp/test_COPYTREE_SHARE/src/1/1.bak /usr/bin/touch /tmp/test_COPYTREE_SHARE/src/1/2.bak (cd /tmp/test_COPYTREE_SHARE/src && /bin/sh -x -c '(/usr/bin/find -d $0 $2 | /usr/bin/cpio -dumpl $1 >/dev/null 2>&1) && /usr/bin/find -d $0 $2 -type d -exec chmod 755 $1/{} \; && /usr/bin/find -d $0 $2 -type f -exec chmod 444 $1/{} \;' -- . /tmp/test_COPYTREE_SHARE/dst "-not -name '*.bak'") + /usr/bin/find -d . -not -name \''*.bak'\' + /usr/bin/cpio -dumpl /tmp/test_COPYTREE_SHARE/dst + /usr/bin/find -d . -not -name \''*.bak'\' -type d -exec chmod 755 /tmp/test_COPYTREE_SHARE/dst/{} ';' + /usr/bin/find -d . -not -name \''*.bak'\' -type f -exec chmod 444 /tmp/test_COPYTREE_SHARE/dst/{} ';' [ ! -f /tmp/test_COPYTREE_SHARE/dst/1/2.bak ] *** [test1] Error code 1 Note how sh turns it into \''*.bak'\' effectively escaping the globbing at find runtime. Similar if we swap quotes to '-not -name "*.bak"': + /usr/bin/find -d . -not -name '"*.bak"' This has always been broken for globs as far as I know, which is why cleaning up in post-patch is done. I honestly think -fc is the best approach, since globbing the first path is easily overcome and rare. Not having to run cleanup in post-patch has advantages both at runtime and Makefile clutter. Simplified test: TESTDIR= /tmp/test_COPYTREE_SHARE SH= /bin/sh -x all: test1 test1: ${RM} -rf ${TESTDIR} ${MKDIR} ${TESTDIR}/src/1 ${TOUCH} ${TESTDIR}/src/1.bak ${TOUCH} ${TESTDIR}/src/1/1.bak ${TOUCH} ${TESTDIR}/src/1/2.bak (cd ${TESTDIR}/src && ${COPYTREE_SHARE} . ${TESTDIR}/dst "-not -name '*.bak'") [ ! -f ${TESTDIR}/dst/1/2.bak ] @${RM} -rf ${TESTDIR} .include <bsd.port.mk> From owner-freebsd-ports@FreeBSD.ORG Sun Jul 6 14:35:19 2014 Return-Path: <owner-freebsd-ports@FreeBSD.ORG> Delivered-To: ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2BFB4224 for <ports@freebsd.org>; Sun, 6 Jul 2014 14:35:19 +0000 (UTC) Received: from relay.mailchannels.net (aso-006-i400.relay.mailchannels.net [143.95.81.29]) by mx1.freebsd.org (Postfix) with ESMTP id 821E5273A for <ports@freebsd.org>; Sun, 6 Jul 2014 14:35:17 +0000 (UTC) X-Sender-Id: _forwarded-from|107.201.34.133 Received: from mail-24.name-services.com (unknown [10.218.133.212]) by relay.mailchannels.net (Postfix) with ESMTPA id 0E12F100047 for <ports@freebsd.org>; Sun, 6 Jul 2014 14:25:46 +0000 (UTC) X-Sender-Id: _forwarded-from|107.201.34.133 Received: from mail-24.name-services.com (mail-24.name-services.com [10.245.145.206]) (using TLSv1 with cipher AES128-SHA) by 0.0.0.0:2500 (trex/5.2.5); Sun, 06 Jul 2014 14:25:47 GMT X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|107.201.34.133 X-MailChannels-Auth-Id: demandmedia Received: from [10.0.10.1] (107-201-34-133.lightspeed.bcvloh.sbcglobal.net [107.201.34.133]) by mail-24.name-services.com with SMTP; Sun, 6 Jul 2014 07:25:42 -0700 Message-ID: <53B95C65.3050805@a1poweruser.com> Date: Sun, 06 Jul 2014 10:25:41 -0400 From: Fbsd8 <fbsd8@a1poweruser.com> User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: ports@FreeBSD.org Subject: These ports need commenter attention Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Porting software to FreeBSD <freebsd-ports.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-ports>, <mailto:freebsd-ports-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-ports/> List-Post: <mailto:freebsd-ports@freebsd.org> List-Help: <mailto:freebsd-ports-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-ports>, <mailto:freebsd-ports-request@freebsd.org?subject=subscribe> X-List-Received-Date: Sun, 06 Jul 2014 14:35:19 -0000 These ports already have been staged and are very simple script only ports which are ready to be committed. 191660 qjail bug fix 191502 qchroot new port 190259 ppars updated 186269 can be closed
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1407061621430.932>