看板 FB_ports 關於我們 聯絡資訊
Hi, On Sun, 6 Jul 2014, Pawel Pekala wrote: > Dnia 2014-07-05, o godz. 12:04:57 > Mikolaj Golub <trociny@FreeBSD.org> 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. 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=3D /tmp/test_COPYTREE_SHARE SH=3D /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 '*.b= ak'") [ ! -f ${TESTDIR}/dst/1/2.bak ] @${RM} -rf ${TESTDIR} ..include <bsd.port.mk> _______________________________________________ freebsd-ports@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-ports To unsubscribe, send any mail to "freebsd-ports-unsubscribe@freebsd.org"