From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Feb 8 01:10:06 2006 Return-Path: X-Original-To: freebsd-ports-bugs@hub.freebsd.org Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2050A16A420 for ; Wed, 8 Feb 2006 01:10:06 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7FCBD43D49 for ; Wed, 8 Feb 2006 01:10:05 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k181A53j034839 for ; Wed, 8 Feb 2006 01:10:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k181A5IU034834; Wed, 8 Feb 2006 01:10:05 GMT (envelope-from gnats) Resent-Date: Wed, 8 Feb 2006 01:10:05 GMT Resent-Message-Id: <200602080110.k181A5IU034834@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dmitry Marakasov Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B3FFB16A420 for ; Wed, 8 Feb 2006 01:02:31 +0000 (GMT) (envelope-from amdmi3@mail.ru) Received: from mx6.mail.ru (mx6.mail.ru [194.67.23.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 16D3C43D46 for ; Wed, 8 Feb 2006 01:02:30 +0000 (GMT) (envelope-from amdmi3@mail.ru) Received: from [213.148.29.33] (port=29128 helo=nexii.panopticon) by mx6.mail.ru with esmtp id 1F6dj3-000LPZ-00 for FreeBSD-gnats-submit@freebsd.org; Wed, 08 Feb 2006 04:02:29 +0300 Received: from hades.panopticon (hades.panopticon [192.168.0.2]) by nexii.panopticon (Postfix) with ESMTP id AF30D1143D for ; Wed, 8 Feb 2006 04:06:04 +0300 (MSK) Received: by hades.panopticon (Postfix, from userid 1000) id 3CE5B47B; Wed, 8 Feb 2006 04:02:35 +0300 (MSK) Message-Id: <20060208010235.3CE5B47B@hades.panopticon> Date: Wed, 8 Feb 2006 04:02:35 +0300 (MSK) From: Dmitry Marakasov To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: ports/93007: Add power of find utility to USE_DOS2UNIX X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dmitry Marakasov List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Feb 2006 01:10:06 -0000 >Number: 93007 >Category: ports >Synopsis: Add power of find utility to USE_DOS2UNIX >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Feb 08 01:10:04 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Dmitry Marakasov >Release: FreeBSD 6.0-RELEASE-p4 i386 >Organization: >Environment: System: FreeBSD hades.panopticon 6.0-RELEASE-p4 FreeBSD 6.0-RELEASE-p4 #1: Fri Jan 27 12:07:19 MSK 2006 amdmi3@hades.panopticon:/usr/obj/usr/src/sys/HADES i386 >Description: Recently added USE_DOS2UNIX variable is useful feature, making it possible to replace ugly `${REINPLACE_CMD} -e "s|$$(${PRINTF} '\r')||g"' and `${REINPLACE_CMD} -e 's/[[:cntrl:]]*$$//` like constructions with one simple variable. But, it lacks some power of `find' utility (which is widely used along with above-mentioned sed calls). For example, if a port has many (nested) directories with source files, and all these files need to be converted, every directory should be specified in USE_DOS2UNIX variable, so it'll look like this: USE_DOS2UNIX= dir1/*.cpp dir1/*.h dir1/dir2/*.cpp dir1/dir2/*.h dir3/*.cpp dir3/*.h ... I know of `USE_DOS2UNIX=YES', which converts all files, but it is not always possible to use it, as it may corrupt binary files that come with the port. So, I think it's clever to make it possible to specify find patterns along with globs. That's exactly what the patch does. After it's applied, items defined in USE_DOS2UNIX are interpreted in different way, depending on whether they contain slash or not. If they do, they are interpreted as globs (as it is now). But if they don't, they are interpreted as find patterns, and find utility with corresponding arguments is applied to ${WRKSRC}. For example, this: USE_DOS2UNIX= /Makefile /src/*.cpp /src/*.h will covert Makefile in ${WRKSRC} and all source files in ${WRKSRC}/src (behavior not changed). But now this: USE_DOS2UNIX= Makefile *.cpp *.h will covert all makefiles and all source/header files under ${WRKSRC}/src and it's descendant directories, which is very useful if you need to convert may files and don't want to touch EVERY file. I've also made version of a patch to use find's `-iregex' parameter instead of `-name'. Find's -iregex is used is many ports (see `find /usr/ports -name Makefile -exec cat {} \; | grep -EB1 "XARGS.*cntrl"`), but such strings USE_DOS2UNIX= .*\.(c|cpp|h|txt|php) make Makefiles less readable. So I recommend first version of the patch. >How-To-Repeat: Get a port with many subdirectories which contain files you need to convert and try to use USE_DOS2UNIX. >Fix: --- patch-bsd.port.mk.name begins here --- --- bsd.port.mk.orig Sat Jan 28 05:11:05 2006 +++ bsd.port.mk Wed Feb 8 03:47:59 2006 @@ -3236,7 +3236,12 @@ .else .for f in ${USE_DOS2UNIX} @${ECHO_MSG} "===> Converting DOS text file to UNIX text file: ${f}" - @${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//' ${WRKSRC}/${f} + @if ${ECHO_CMD} '${f}' | ${GREP} / > /dev/null 2>&1; then \ + ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//' ${WRKSRC}/${f}; \ + else \ + ${FIND} -E ${WRKSRC} -type f -name '${f}' -print0 | \ + ${XARGS} -0 ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//'; \ + fi .endfor .endif .else --- patch-bsd.port.mk.name ends here --- --- patch-bsd.port.mk.regex begins here --- --- bsd.port.mk.orig Sat Jan 28 05:11:05 2006 +++ bsd.port.mk Wed Feb 8 03:41:56 2006 @@ -3236,7 +3236,12 @@ .else .for f in ${USE_DOS2UNIX} @${ECHO_MSG} "===> Converting DOS text file to UNIX text file: ${f}" - @${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//' ${WRKSRC}/${f} + @if ${ECHO_CMD} '${f}' | ${GREP} / > /dev/null 2>&1; then \ + ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//' `echo '${WRKSRC}/${f}'`; \ + else \ + ${FIND} -E ${WRKSRC} -type f -iregex '${f}' -print0 | \ + ${XARGS} -0 ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//'; \ + fi .endfor .endif .else --- patch-bsd.port.mk.regex ends here --- >Release-Note: >Audit-Trail: >Unformatted: