From owner-freebsd-ports@FreeBSD.ORG Sun Jul 6 15:40:35 2014 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4494E777 for ; Sun, 6 Jul 2014 15:40:35 +0000 (UTC) Received: from mail-wi0-x234.google.com (mail-wi0-x234.google.com [IPv6:2a00:1450:400c:c05::234]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D04672BA1 for ; Sun, 6 Jul 2014 15:40:34 +0000 (UTC) Received: by mail-wi0-f180.google.com with SMTP id hi2so5573516wib.13 for ; Sun, 06 Jul 2014 08:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=RlzCtfKjFmr0zGY5qj99q9B2FanMTzf+hR89N9/+fn0=; b=oCWpyLPmzJDnHP0Q84+9yEwClcu6Oi2jy97oYDh74CeluwuT20yNQWE5Bvym0nRPgj g682Z4kNnoxdZxtdsrPlHVbuK2zs6v2AOshjLgHktVIRAdAXJLtg47+SiTHPeq4H4tH7 2p52mGKDjkf1ZnawowHrVOLkSG9L6oCm+IpNu8jFKSpS6w7ZC/uTnEn3++5qErvShbMq LmIf2FcTBCYlyoyU6cA+YxYvILi6WkgKHB7VoL2E6N2z35zCjtQPSxLmP4OK0FvFqOj/ LDMtzKSwqmNMRHbiK3kctbX74T6WhwRY3bpIpxCVs39L1K5qz+OwA9ppWnRXjfHDl2l5 /hSA== X-Received: by 10.180.198.116 with SMTP id jb20mr30319902wic.59.1404661232911; Sun, 06 Jul 2014 08:40:32 -0700 (PDT) Received: from localhost ([176.109.164.5]) by mx.google.com with ESMTPSA id ev9sm104207800wic.24.2014.07.06.08.40.31 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Sun, 06 Jul 2014 08:40:32 -0700 (PDT) Sender: =?UTF-8?B?UGF3ZcWCIFDEmWthbGE=?= Date: Sun, 6 Jul 2014 17:39:03 +0200 From: Pawel Pekala To: freebsd-ports@freebsd.org Subject: Re: COPYTREE_BIN/COPYTREE_SHARE does not work as expected Message-ID: <20140706173903.6a17da01@FreeBSD.org> In-Reply-To: References: <20140705120457.GA1772@gmail.com> <20140706153509.2d9dead2@FreeBSD.org> X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.22; amd64-portbld-freebsd11.0) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jul 2014 15:40:35 -0000 Hi Melvyn, On 2014-07-06 16:34 +0200, Melvyn Sopacua wrote: >Hi, > >On Sun, 6 Jul 2014, Pawel Pekala wrote: > >> Dnia 2014-07-05, o godz. 12:04:57 >> Mikolaj Golub napisa=B3(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. Little hackish, but this seems to work: (cd ${TESTDIR}/src && ${COPYTREE_SHARE} . ${TESTDIR}/dst "-not -name *\.bak= ") --=20 pozdrawiam / with regards Pawe=B3 P=EAkala