This patch adds DOS text files detection support for the "patch-dos2unix target", and only removes the (one) trailing CR (\r) character. This is because the conversion can (actually does) damage non-text files. Also the current version will delete all control characters at the end of the line, not only a CR (this can produce unexpected results).
Responsible Changed From-To: freebsd-ports-bugs->portmgr Portmgr territory
>Submitter-Id: current-users >Originator: Alejandro Pulver >Organization: >Confidential: no >Synopsis: Re: ports/92688: [PATCH] bsd.port.mk: add check to USE_DOS2UNIX >Severity: non-critical >Priority: low >Category: ports >Class: update >Release: FreeBSD 5.4-RELEASE i386 >Environment: System: FreeBSD 5.4-RELEASE #0: Sat May 21 12:14:47 ART 2005 root@ale.varnet.bsd:/usr/src/sys/i386/compile/ATHLON-ALE >Description: * Change -i"" to -i "" to avoid the next argument being interpreted as the backup suffix (that is -e). >How-To-Repeat: >Fix: --- bsd.port.mk.diff begins here --- --- /usr/ports/Mk/bsd.port.mk Fri Jan 27 23:11:05 2006 +++ bsd.port.mk Wed Feb 1 19:56:52 2006 @@ -3231,12 +3231,15 @@ .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:]]*$$//' + @${FIND} ${WRKSRC} -type f -print0 | ${XARGS} -0 ${SH} -c \ + 'while [ $$# -gt 0 ]; do ${FILE} "$$1" | ${GREP} -q CRLF && \ + ${REINPLACE_CMD} -i "" -e "s/`${PRINTF} \"\r\"`$$//" "$$1"; \ + shift; done' sep .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} + @${FILE} "${WRKSRC}/${f}" | ${GREP} -q CRLF && \ + ${REINPLACE_CMD} -i "" -e "s/`${PRINTF} '\r'`$$//" "${WRKSRC}/${f}" .endfor .endif .else --- bsd.port.mk.diff ends here ---
State Changed From-To: open->feedback When I apply this patch and try to make e.g. textproc/silvercity, no substitution is done. Without this patch, it works.
>Submitter-Id: current-users >Originator: Alejandro Pulver >Organization: >Confidential: no >Synopsis: Re: ports/92688: [PATCH] bsd.port.mk: add check to USE_DOS2UNIX >Severity: non-critical >Priority: low >Category: ports >Class: update >Release: FreeBSD 5.4-RELEASE i386 >Environment: System: FreeBSD 5.4-RELEASE #0: Sat May 21 12:14:47 ART 2005 root@ale.varnet.bsd:/usr/src/sys/i386/compile/ATHLON-ALE >Description: Here is a summary of the changes: - Change -i"" to -i "" so the "-e" argument isn't interpreted as a backup suffix. - Remove useless "-E" parameter to ${FIND}. - Change the regexp so it only removes one CR character. - Check the files are text files before patching them (on FreeBSD >= 5.X the files are also checked for being DOS text files). >How-To-Repeat: >Fix: --- bsd.port.mk.diff begins here --- --- /usr/ports/Mk/bsd.port.mk Fri Jan 27 23:11:05 2006 +++ bsd.port.mk Fri Feb 3 22:33:59 2006 @@ -1505,6 +1505,14 @@ CONFIGURE_ENV+= MAKE=${GMAKE} .endif +.if defined(USE_DOS2UNIX) +.if ${OSVERSION} < 500000 +DOS2UNIX_FP= text +.else +DOS2UNIX_FP= CRLF +.endif +.endif + .if defined(USE_GCC) .include "${PORTSDIR}/Mk/bsd.gcc.mk" .endif @@ -3231,12 +3239,15 @@ .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:]]*$$//' + @${FIND} ${WRKSRC} -type f -print0 | ${XARGS} -0 ${SH} -c \ + 'while [ $$# -gt 0 ]; do ${FILE} "$$1" | ${GREP} -q ${DOS2UNIX_FP} && \ + ${REINPLACE_CMD} -i "" -e "s/`${PRINTF} \"\r\"`$$//" "$$1"; \ + shift; done' sep .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} + @${FILE} "${WRKSRC}/${f}" | ${GREP} -q ${DOS2UNIX_FP} && \ + ${REINPLACE_CMD} -i "" -e "s/`${PRINTF} '\r'`$$//" "${WRKSRC}/${f}" .endfor .endif .else --- bsd.port.mk.diff ends here ---
State Changed From-To: feedback->open Force notify.
State Changed From-To: open->feedback As of the commit to bsd.port.mk in 1.525, this patch no longer applies. That patch fixed at least one error, but does not add the use of file(1) as this one does. Please work with edwin to see if you can agree on a corrected patch that adds the file(1) check (if necessary?), and incorporates the other, existing, change. Thanks.
State Changed From-To: feedback->closed Patch no longer applies and is partly already implemented and the last feature is waiting to be tested in ports/106029. Thanks for your submission!