From owner-freebsd-ports@FreeBSD.ORG Sat Jul 5 12:05:04 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 3EB9D37B for ; Sat, 5 Jul 2014 12:05:04 +0000 (UTC) Received: from mail-la0-x241.google.com (mail-la0-x241.google.com [IPv6:2a00:1450:4010:c03::241]) (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 BB7FD2234 for ; Sat, 5 Jul 2014 12:05:03 +0000 (UTC) Received: by mail-la0-f65.google.com with SMTP id e16so607448lan.0 for ; Sat, 05 Jul 2014 05:05:01 -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:mime-version:content-type :content-disposition:user-agent; bh=5RyPT07pS9SMJ9QEFLwvS0x0OzvPUtrkfCrXHnrLJMU=; b=gZbBI0PcuR+4bbI/IGFxj7z257jfTkuPSLoj7EXdn5h/u5TXld+jXlGnmlf9eCoF/m hai3nrevOouAKdyJZf4Qa03zXENCU46JpOrtnMRGXvpBezVwfV5ic3+tuW77+XPlFN88 3TuAxIds4sSUdommNsINtVlnWCRtRiP5zUWmqeccExE5p5E50zCs7sr26nPELQMk6L4O WPNcBmXhi9U/WuDrPG50wLOX14GhlcszZKXWB6l4e0e+gfKBf7YX7R08LjfmlOqOU11M 6Z3lIziYEKngj+uRrYMiBxjsPJOzhxi1NlRqYMtSwpK7qxQz5FeujdKBKS2ScBJV0UiY JX8g== X-Received: by 10.112.13.137 with SMTP id h9mr12403928lbc.33.1404561901027; Sat, 05 Jul 2014 05:05:01 -0700 (PDT) Received: from localhost (93-77-155-216-ptr.volia-lviv.com. [93.77.155.216]) by mx.google.com with ESMTPSA id h2sm16256713lam.47.2014.07.05.05.04.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Jul 2014 05:05:00 -0700 (PDT) Sender: Mikolaj Golub Date: Sat, 5 Jul 2014 12:04:57 +0000 From: Mikolaj Golub To: freebsd-ports@freebsd.org Subject: COPYTREE_BIN/COPYTREE_SHARE does not work as expected Message-ID: <20140705120457.GA1772@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) 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: Sat, 05 Jul 2014 12:05:04 -0000 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. Below is a test that demonstrates this: [golub@zhuzha ~/freebsd/ports/test]$ cat Makefile TESTDIR= /tmp/test_COPYTREE_SHARE all: test1 test2 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 "! -name *.bak") @echo "=> Listing destination (no *.bak files are expected):" @${FIND} ${TESTDIR}/dst @${RM} -rf ${TESTDIR} test2: ${RM} -rf ${TESTDIR} ${MKDIR} ${TESTDIR}/src ${TOUCH} ${TESTDIR}/src/1.bak ${TOUCH} ${TESTDIR}/src/2.bak -(cd ${TESTDIR}/src && ${COPYTREE_SHARE} . ${TESTDIR}/dst "! -name *.bak") @${RM} -rf ${TESTDIR} .include [golub@zhuzha ~/freebsd/ports/test]$ make /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 -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 "! -name *.bak") => Listing destination (no *.bak files are expected): /tmp/test_COPYTREE_SHARE/dst /tmp/test_COPYTREE_SHARE/dst/1 /tmp/test_COPYTREE_SHARE/dst/1/2.bak /bin/rm -rf /tmp/test_COPYTREE_SHARE /bin/mkdir -p /tmp/test_COPYTREE_SHARE/src /usr/bin/touch /tmp/test_COPYTREE_SHARE/src/1.bak /usr/bin/touch /tmp/test_COPYTREE_SHARE/src/2.bak (cd /tmp/test_COPYTREE_SHARE/src && /bin/sh -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 "! -name *.bak") find: 2.bak: unknown primary or operator find: 2.bak: unknown primary or operator *** Error code 1 (ignored) In my case I workarounded this by using -regex instead of -name. One way to fix this is to disable pathname expansion in the find shell: -COPYTREE_SHARE= ${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \ +COPYTREE_SHARE= ${SH} -fc '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \ But then it will break cases like below, when expansion of the first argumemt is desirable: ${COPYTREE_SHARE} "*" ${TESTDIR} -- Mikolaj Golub