Trouble with creating a patchfile (when hitting a file with missing newline at end of file)

Marko Käning MK-MacPorts at techno.ms
Mon Nov 15 12:31:33 PST 2010


Hi guys,

I am having severe trouble with a patchfile which I try to apply in the kmymoney4 port.

I created the patchfile with the command

	$ svn diff svn://anonsvn.kde.org/home/kde/tags/kmymoney/4.5.1 svn://anonsvn.kde.org/home/kde/trunk/extragear/office/kmymoney >patch.diff

OK. So far so good.

I test the patch by applying it to a local working copy being at the old revision

	$ patch -p0 <patch.diff

and it runs through without any problem.

BUT, when I try the same using my portfile's patchfiles like this 
---
.
.
.
patchfiles       patch.diff
patch.dir         ${workpath}/${distname}
patch.pre_args    -p0
.
.
.
---
I eventually end up with an error like this:
---
$ sudo port patch
.
.
.
:info:patch patching file developer-doc/phb/CMakeLists.txt
:info:patch /usr/bin/patch: **** malformed patch at line 130:  KDE4_CREATE_HANDBOOK(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kmymoney-developer)
:info:patch
:info:patch shell command " cd "/opt/macports-test/var/macports/build/_Users_marko_WC_MacPorts_ports_kde_kmymoney4/work/kmymoney-4.5.1" && /usr/bin/patch -p0 < '/Users/marko/WC/MacPorts/ports/kde/kmymoney4/files/patch_to_r1197424.diff'" returned error 2
:error:patch Target org.macports.patch returned: shell command failed (see log for details)
:debug:patch Backtrace: shell command failed (see log for details)
    while executing
"command_exec patch "" "< '$patch'""
    (procedure "portpatch::patch_main" line 35)
    invoked from within
"$procedure $targetname"
:info:patch Warning: the following items did not execute (for kmymoney4): org.macports.patch
---

This all seems to be caused by that the said file developer-doc/phb/CMakeLists.txt misses a newline at the end of the file, as you can see when peeking into the patchfile:
---
.
.
.
Index: developer-doc/phb/CMakeLists.txt
===================================================================
--- developer-doc/phb/CMakeLists.txt    (.../tags/kmymoney/4.5.1)   (revision 1197422)
+++ developer-doc/phb/CMakeLists.txt    (.../trunk/extragear/office/kmymoney)   (revision 1197422)
@@ -1,2 +1,2 @@
 KDE4_CREATE_HANDBOOK(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kmymoney-developer)
-INSTALL(FILES kmymoney-developer.desktop  DESTINATION  ${XDG_APPS_INSTALL_DIR})
\ No newline at end of file
+INSTALL(PROGRAMS kmymoney-developer.desktop  DESTINATION  ${XDG_APPS_INSTALL_DIR})
\ No newline at end of file
Index: README.ofx
===================================================================
.
.
.
---
This seems to irritate the patch command.

I have no idea, though, why it works if I apply it manually, but fails when I try it using "port patch".

I am aware of that missing newlines at end of file are often a problem for patch, but I wonder what's causing this differences here.
I already wasted hours to find a solution, yesterday and today. :-(

I hope so much you guys have a hint for me.

Greets,
Marko


More information about the macports-dev mailing list