Bug 93007

Summary: Add power of find utility to USE_DOS2UNIX
Product: Ports & Packages Reporter: Dmitry Marakasov <amdmi3>
Component: Individual Port(s)Assignee: Port Management Team <portmgr>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch-bsd.port.mk.name
none
file.diff none

Description Dmitry Marakasov 2006-02-08 01:10:04 UTC
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 convert all makefiles and all source/header files under ${WRKSRC}/src and
it's descendant directories, which is very useful if you need to convert many
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.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2006-02-08 22:16:14 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr

portmgr territory
Comment 2 Pav Lucistnik freebsd_committer freebsd_triage 2006-11-24 20:10:26 UTC
State Changed
From-To: open->feedback

Your patches no longer applies. Sorry for not getting to you earlier. 

Currently, a part of the functionality you propose is already implemented. You 
can have 

USE_DOS2UNIX=	src/*.cpp src/*.h 

but not the extension matching you propose. 

Because it's too late to change existing behaviour, can I suggest adding 
something like: 

USE_DOS2UNIX=	yes 
DOS2UNIX_REGEX=	*.cpp *.h 

which would then go and operate on all .cpp .h files in all subdirectories? 
What do you think? Can you submit an updated patch to implement this?
Comment 3 Pav Lucistnik freebsd_committer freebsd_triage 2006-11-29 20:03:28 UTC
I have prepared a fresh patch that implements all you suggested in this
PR. Please see ports/106029

-- 
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

Any Palm app requiring an 90+ page manual has lost its vision.
    -- words about DateBk4 on Action Names list
Comment 4 Erwin Lansing freebsd_committer freebsd_triage 2006-12-29 21:51:58 UTC
State Changed
From-To: feedback->closed

Superseded by ports/106029 with a better patch.  Thanks for 
your submission!