GNU patch and end-of-file newline (or lack thereof)

So I was trying to version bump the ebuild for dev-tcltk/tcllib-1.15-r1 into dev-tcltk/tcllib-1.16 (I needed tcl::chan::string 1.0.2 instead of 1.0.1).

tcllib comes with a cartload of man pages, some of which have names which conflict with Tcl ones. Thus, as is the case for dev-tcltk/tcllib-1.15-r1, I needed to remove/rename them in the ebuild. Those that were present in tcllib-1.15 were already taken care of, but there were a few new files to remove as well. Namely:

  • tcllib-tcllib_1_16/embedded/man/files/modules/coroutine/coroutine.n
  • tcllib-tcllib_1_16/embedded/man/files/modules/virtchannel_base/string.n
  • tcllib-tcllib_1_16/embedded/man/files/modules/virtchannel_base/variable.n
  • tcllib-tcllib_1_16/embedded/man/files/modules/virtchannel_transform/zlib.n

I created a patch file with the contents of all four files, with each line prepended with a “-” and the right headers, and applied the patch: failed. Supposedly the patch looked to patch as if it had already been applied, and forcing it to be applied (or reverse-applied) failed with no useful error message whatsoever.
It took me quite a while to figure out that what I was missing was this line at the end of each patch hunk:

\ No newline at end of file

Theses four files had no end-of-file newline, and without the above indication in the patch, patch would bail out because it’s picky (which is fine – but I’ve seen more explicit error reporting).

The moral here is that I should remember not to piece together my patch files by hand: letting diff handle that would have saved me some headaches…

Note: On the upside, dev-tcltk/tcllib-1.16 is now available in my overlay.

Leave a Reply

Your email address will not be published. Required fields are marked *