Bug 87234 - [patch] bsd.port.mk: add patch-dos2unix target
[patch] bsd.port.mk: add patch-dos2unix target
Status: Closed FIXED
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s)
Latest
Any Any
: Normal Affects Only Me
Assigned To: Edwin Groothuis
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-10-11 01:50 UTC by edwin
Modified: 2007-01-23 00:03 UTC (History)
0 users

See Also:


Attachments
file.diff (2.85 KB, patch)
2005-10-11 01:50 UTC, edwin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description edwin 2005-10-11 01:50:14 UTC
The porters handbook says at
http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/slow-patch.html:

    To quickly convert those files from CR/LF to just LF, you can
    do something like this:

    USE_REINPLACE= yes
    post-extract:
	@${FIND} -E ${WRKDIR} -type f -iregex ".*\.(c|cpp|h|txt)" -print0 | \
	    ${XARGS} -0 ${REINPLACE_CMD} -e 's/[[:cntrl:]]*$$//'

    Of course, if you need to process each and every file, -iregex
    above can be omitted. Be aware that this piece of code will
    strip all trailing control characters from each line of processed
    file (except \n).

Let's for simplicty sake replace that one ugly statement with a
simple USE_ statement and let bsd.port.mk figure out the rest:

    USE_DOS2UNIX=	yes
    			^-- run dos2unix over all files under WRKSRC
    USE_DOS2UNIX=	foo bar
    			^-- run dos2unix over WRKSRC/foo and WRKSRC/bar


Once commited (or on the row to be commited), I volunteer to...

- Fix the porters handbook with regarding to documentation, and
- Fix the ports with their own dos2unix implementation with this
  new statement.
Comment 1 Edwin Groothuis freebsd_committer 2005-10-11 02:12:46 UTC
Responsible Changed
From-To: freebsd-ports-bugs->port-mgr

Over to port-mgr
Comment 2 Edwin Groothuis freebsd_committer 2005-10-11 02:12:59 UTC
Responsible Changed
From-To: port-mgr->portmgr

Over to portmgr
Comment 3 edwin 2005-10-21 01:23:20 UTC
On Thu, Oct 20, 2005 at 07:59:28PM -0400, Kris Kennaway wrote:
> On Tue, Oct 11, 2005 at 01:13:06AM +0000, Edwin Groothuis wrote:
> How many ports currently have a home-grown version of this?

15 ports have :cntrl: in the Makefile:

    archivers/dzip/Makefile
    audio/mp3guessenc/Makefile
    emulators/fceu/Makefile
    emulators/yape/Makefile
    emulators/yape/Makefile
    emulators/o2em/Makefile
    games/meqcc/Makefile
    games/galaxyhack/Makefile
    games/cake/Makefile
    games/qccx/Makefile
    graphics/osg/Makefile
    misc/portell/Makefile
    misc/skyutils/Makefile
    multimedia/avidemux2/Makefile
    security/p5-Crypt-PasswdMD5/Makefile

34 ports have ^M's in the Makefile 

    archivers/py-lzma/Makefile
    audio/holyshout/Makefile
    audio/portaudio/Makefile
    audio/penguinsap/Makefile
    databases/mysqltcl/Makefile
    deskutils/gnomeutils2/Makefile
    devel/initutil/Makefile
    devel/pear-HTML_Page2/Makefile
    ftp/urlgfe/Makefile
    games/exhaust-ma/Makefile
    german/selfhtml/Makefile
    graphics/py-opengl/Makefile
    irc/xchat-fish/Makefile
    irc/xchat-mircryption/Makefile
    irc/irssi-fish/Makefile
    math/tomsfastmath/Makefile
    misc/edonkey-tool-slist/Makefile
    multimedia/linux-divx4linux/Makefile
    multimedia/linux-divx4linux4/Makefile
    net/linux-agsatellite/Makefile
    net/phex/Makefile
    print/mp-letter/Makefile
    security/altivore/Makefile
    security/p5-Crypt-RC6/Makefile
    security/newpki-lib/Makefile
    textproc/unrtf/Makefile
    textproc/silvercity/Makefile
    textproc/rtfx/Makefile
    textproc/clit/Makefile
    textproc/libextractor/Makefile
    x11/libgnome-java/Makefile
    x11/xscreensaver-gnome/Makefile
    x11-toolkits/ruby-wx/Makefile
    x11-toolkits/libgtk-java/Makefile

141 patch-files have ^M's in them:

    archivers/xmill/files/patch-src::Main.cpp
    archivers/xmill/files/patch-src::ZLib.cpp
    astro/wmsolar/files/patch-Vsop.h
    audio/faad/files/patch-configure.in
    audio/mp3info/files/patch-gmp3info.c
    audio/mac/files/patch-src-MACLib-APEInfo.cpp
    audio/mac/files/patch-src-MACLib-APETag.cpp
    audio/mac/files/patch-src-MACLib-Assembly-Assembly.h
    audio/mac/files/patch-src-MACLib-MACLib.cpp
    audio/mac/files/patch-src-MACLib-WAVInputSource.cpp
    audio/mac/files/patch-src-Shared-NoWindows.h
    audio/libmpcdec/files/patch-src_mpc_decoder.c
    audio/wavpack/files/patch-utils.c
    benchmarks/netperf/files/patch-netperf.c
    benchmarks/himenobench/files/patch-himenobmtxp_l.f
    benchmarks/himenobench/files/patch-himenobmtxp_m.f
    benchmarks/himenobench/files/patch-himenobmtxp_s.f
    benchmarks/himenobench/files/patch-himenobmtxp_xl.f
    benchmarks/himenobench/files/patch-himenobmtxps.c
    cad/ngspice_rework/files/patch-src:spicelib:analysis:cktncdump.c
    cad/ziarc/files/patch-rnetgui.py
    cad/ziarc/files/patch-setup.py
    comms/kpsk/files/patch-ac
    comms/mlan/files/patch-aa
    comms/mlan/files/patch-ad
    comms/mlan/files/patch-ae
    comms/mlan/files/patch-af
    comms/mlan3/files/patch-aa
    comms/twpsk/files/patch-psk31-transmitter.C
    converters/uudx/files/patch-aa
    databases/mysql-navigator/files/patch-aa
    databases/mysql-navigator/files/patch-ab
    databases/oracle_odbc_driver/files/patch-src-oracle_functions.c
    databases/ruby-rdbc1/files/patch-pg_rdbc1.rb
    devel/glui/files/patch-aa
    devel/glui/files/patch-ab
    devel/glui/files/patch-example1.cpp
    devel/glui/files/patch-example2.cpp
    devel/glui/files/patch-example3.cpp
    devel/glui/files/patch-example4.cpp
    devel/glui/files/patch-example5.cpp
    devel/glui/files/patch-glui.h
    devel/pedisassem/files/patch-main.c
    devel/pedisassem/files/patch-print.c
    devel/ruby-rbprof/files/patch-aspects::profiler::lib::rbprof.rb
    devel/ruby-rudl/files/patch-extconf.rb
    devel/sdts++/files/patch-ab
    devel/hs-tclhaskell-ghc/files/patch-ConcTcl.hs
    devel/hs-tclhaskell-ghc/files/patch-TclPrimGhc.hs
    [...]

So the answer is 49 ports with a home grown version on it, and with
141 patch-files with ^M's in them.

Edwin

-- 
Edwin Groothuis      |            Personal website: http://www.mavetju.org
edwin@mavetju.org    |          Weblog: http://weblog.barnet.com.au/edwin/
Comment 4 kris 2005-10-21 01:25:36 UTC
On Fri, Oct 21, 2005 at 10:23:20AM +1000, Edwin Groothuis wrote:
> On Thu, Oct 20, 2005 at 07:59:28PM -0400, Kris Kennaway wrote:
> > On Tue, Oct 11, 2005 at 01:13:06AM +0000, Edwin Groothuis wrote:
> > How many ports currently have a home-grown version of this?


> So the answer is 49 ports with a home grown version on it, and with
> 141 patch-files with ^M's in them.

Thanks, it sounds like this would be useful then.

Kris
Comment 5 edwin 2005-12-12 21:31:15 UTC
Synced against a 2005-12-13 bsd.port.mk:

--- bsd.port.mk.orig	Tue Dec 13 08:28:47 2005
+++ bsd.port.mk	Tue Dec 13 08:29:47 2005
@@ -276,6 +276,9 @@
 #				  compression.
 # USE_ZIP		- If set, this port distfile uses zip, not tar w/[bg]zip
 #				  for compression.
+# USE_DOS2UNIX  - If set to "YES", remove the ^M from all files
+#				  under ${WRKSRC}. If set to a string, remove in all
+#				  files under ${WRKSRC} with one of these names the ^Ms.
 # USE_GCC		- If set, this port requires this version of gcc, either in
 #				  the system or installed from a port.
 # USE_GMAKE		- If set, this port uses gmake.
@@ -1470,6 +1473,10 @@
 CONFIGURE_ENV+=	MAKE=${GMAKE}
 .endif
 
+.if defined(USE_DOS2UNIX)
+USE_REINPLACE=	yes
+.endif
+
 .if defined(USE_GCC)
 .include "${PORTSDIR}/Mk/bsd.gcc.mk"
 .endif
@@ -3174,9 +3181,27 @@
 
 # Patch
 
+.if !target(patch-dos2unix)
+patch-dos2unix:
+.if defined(USE_DOS2UNIX)
+.if ${USE_DOS2UNIX:U}=="YES"
+	@${ECHO_MSG} "===>   Converting DOS text files to UNIX text files"
+	@${FIND} -E ${WRKSRC} -type f -print0 | \
+			${XARGS} -0 ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//'
+.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}
+.endfor
+.else
+	${DO_NADA}
+.endif
+.endif
+
 .if !target(do-patch)
 do-patch:
 .if defined(PATCHFILES)
+.endif
 	@${ECHO_MSG} "===>  Applying distribution patches for ${PKGNAME}"
 	@(cd ${_DISTDIR}; \
 	  for i in ${_PATCHFILES}; do \
@@ -3676,9 +3701,9 @@
 # Please note that the order of the following targets is important, and
 # should not be modified.
 
-_SANITY_SEQ=		pre-everything check-makefile check-categories \
-			check-makevars check-depends check-deprecated \
-			check-vulnerable buildanyway-message options-message
+_SANITY_SEQ=	pre-everything check-makefile check-categories \
+				check-makevars check-depends check-deprecated \
+				check-vulnerable buildanyway-message options-message
 _FETCH_DEP=		check-sanity
 _FETCH_SEQ=		fetch-depends pre-fetch pre-fetch-script \
 				do-fetch post-fetch post-fetch-script
@@ -3687,12 +3712,12 @@
 				pre-extract-script do-extract \
 				post-extract post-extract-script
 _PATCH_DEP=		extract
-_PATCH_SEQ=		patch-message patch-depends pre-patch pre-patch-script \
-				do-patch post-patch post-patch-script
+_PATCH_SEQ=		patch-message patch-depends patch-dos2unix pre-patch \
+				pre-patch-script do-patch post-patch post-patch-script
 _CONFIGURE_DEP=	patch
 _CONFIGURE_SEQ=	build-depends lib-depends misc-depends configure-message \
-		pre-configure pre-configure-script patch-autotools \
-		run-autotools do-configure post-configure post-configure-script
+				pre-configure pre-configure-script patch-autotools \
+				run-autotools do-configure post-configure post-configure-script
 _BUILD_DEP=		configure
 _BUILD_SEQ=		build-message pre-build pre-build-script do-build \
 				post-build post-build-script

-- 
Edwin Groothuis      |            Personal website: http://www.mavetju.org
edwin@mavetju.org    |          Weblog: http://weblog.barnet.com.au/edwin/
Comment 6 Mark Linimon freebsd_committer 2005-12-19 01:27:40 UTC
State Changed
From-To: open->analyzed

Accepted for testing on the cluster.
Comment 7 Edwin Groothuis freebsd_committer 2006-01-06 22:50:16 UTC
linimon@ found an interested problem when running the patch: a
wrongly placed .endif. This is the new patch.

--- bsd.port.mk.orig	Thu Jan  5 17:11:44 2006
+++ bsd.port.mk	Sat Jan  7 09:48:01 2006
@@ -276,6 +276,9 @@
 #				  compression.
 # USE_ZIP		- If set, this port distfile uses zip, not tar w/[bg]zip
 #				  for compression.
+# USE_DOS2UNIX  - If set to "YES", remove the ^M from all files
+#				  under ${WRKSRC}. If set to a string, remove in all
+#				  files under ${WRKSRC} with one of these names the ^Ms.
 # USE_GCC		- If set, this port requires this version of gcc, either in
 #				  the system or installed from a port.
 # USE_GMAKE		- If set, this port uses gmake.
@@ -1477,6 +1480,10 @@
 CONFIGURE_ENV+=	MAKE=${GMAKE}
 .endif
 
+.if defined(USE_DOS2UNIX)
+USE_REINPLACE=	yes
+.endif
+
 .if defined(USE_GCC)
 .include "${PORTSDIR}/Mk/bsd.gcc.mk"
 .endif
@@ -3181,6 +3188,24 @@
 
 # Patch
 
+.if !target(patch-dos2unix)
+patch-dos2unix:
+.if defined(USE_DOS2UNIX)
+.if ${USE_DOS2UNIX:U}=="YES"
+	@${ECHO_MSG} "===>   Converting DOS text files to UNIX text files"
+	@${FIND} -E ${WRKSRC} -type f -print0 | \
+			${XARGS} -0 ${REINPLACE_CMD} -i"" -e 's/[[:cntrl:]]*$$//'
+.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}
+.endfor
+.endif
+.else
+	${DO_NADA}
+.endif
+.endif
+
 .if !target(do-patch)
 do-patch:
 .if defined(PATCHFILES)
@@ -3683,9 +3708,9 @@
 # Please note that the order of the following targets is important, and
 # should not be modified.
 
-_SANITY_SEQ=		pre-everything check-makefile check-categories \
-			check-makevars check-depends check-deprecated \
-			check-vulnerable buildanyway-message options-message
+_SANITY_SEQ=	pre-everything check-makefile check-categories \
+				check-makevars check-depends check-deprecated \
+				check-vulnerable buildanyway-message options-message
 _FETCH_DEP=		check-sanity
 _FETCH_SEQ=		fetch-depends pre-fetch pre-fetch-script \
 				do-fetch post-fetch post-fetch-script
@@ -3694,12 +3719,12 @@
 				pre-extract-script do-extract \
 				post-extract post-extract-script
 _PATCH_DEP=		extract
-_PATCH_SEQ=		patch-message patch-depends pre-patch pre-patch-script \
-				do-patch post-patch post-patch-script
+_PATCH_SEQ=		patch-message patch-depends patch-dos2unix pre-patch \
+				pre-patch-script do-patch post-patch post-patch-script
 _CONFIGURE_DEP=	patch
 _CONFIGURE_SEQ=	build-depends lib-depends misc-depends configure-message \
-		pre-configure pre-configure-script patch-autotools \
-		run-autotools do-configure post-configure post-configure-script
+				pre-configure pre-configure-script patch-autotools \
+				run-autotools do-configure post-configure post-configure-script
 _BUILD_DEP=		configure
 _BUILD_SEQ=		build-message pre-build pre-build-script do-build \
 				post-build post-build-script

-- 
Edwin Groothuis
edwin@freebsd.org
http://www.mavetju.org
Comment 8 Mark Linimon freebsd_committer 2006-01-21 19:51:48 UTC
State Changed
From-To: analyzed->closed

Committed, thanks.
Comment 9 Edwin Groothuis freebsd_committer 2006-01-21 21:48:34 UTC
State Changed
From-To: closed->open

over to myself for documentation and implementation 


Comment 10 Edwin Groothuis freebsd_committer 2006-01-21 21:48:34 UTC
Responsible Changed
From-To: portmgr->edwin

over to myself for documentation and implementation
Comment 11 edwin 2006-01-22 21:57:03 UTC
* nox-- added EXTRACT_BEFORE_ARGS+=   -aq because of the ^Ms in projectx

-- 
Edwin Groothuis      |            Personal website: http://www.mavetju.org
edwin@mavetju.org    |          Weblog: http://weblog.barnet.com.au/edwin/
Comment 12 pav freebsd_committer 2006-11-24 19:51:48 UTC
What are your plans with this PR, Edwin? I think it can be closed, all
the patches listed here were committed.

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

Distraction is water in the garden of apathy.
  -- Baker of http://www.jimburgessdesign.com/comics/
Comment 13 pav freebsd_committer 2007-01-23 00:03:07 UTC
State Changed
From-To: open->closed

All the patches here were committed