Find the answer to your Linux question:
Results 1 to 3 of 3
This is a question about patch, not about python-ogre, but just to give some context to my question : I'm following some instructions on some wiki about how to install ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2009
    Posts
    2

    A question about patch


    This is a question about patch, not about python-ogre, but just to give some context to my question : I'm following some instructions on some wiki about how to install python-ogre and at some point patch needs to run and do something, and fails. So undaunted, I run the command again, and look at the .patch file it's running, and the files that should be getting patched and everything looks sensible to me - I can see the line in the .h file that needs commenting out according to the patch file, and I can see what it should be replaced with, and patch has found the files, but it just won't do it, and all it says is:

    patching file ogre/Samples/Common/include/ExampleFrameListener.h
    Hunk #1 FAILED at 41.
    1 out of 1 hunk FAILED -- saving rejects to file ogre/Samples/Common/include/ExampleFrameListener.h.rej


    which isn't very useful. So I add the --verbose flag, and the only difference now is that it says:

    Hmm... Looks like a unified diff to me...

    and also

    Patching file ogre/Samples/Common/include/ExampleFrameListener.h using Plan A... (Am I supposed to know what Plan A is, or how this is any better / worse than Plans B, C or D, and whether this is related to it not working?)

    So for my particular python-ogre problem I'm just going to do the patch by hand using a text editor since I can see exactly what the .patch file is trying to do and where, and it looks perfectly sensible to me, and then I'll see what happens, BUT my question about patch in general is:

    When patch fails, is there any way of finding out why it fails? If the patch file is there, and I look inside it and can find the file it's trying to patch, and the line in the file, and I can't see any reason for it not working, then what do I do next? Just patch the files by hand?

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    When patch fails, is there any way of finding out why it fails?
    Yes.

    Code:
    1 out of 1 hunk FAILED -- saving rejects to file ogre/Samples/Common/include/ExampleFrameListener.h.rej
    In that file, the rejected hunks will be saved. When the patch can't be applied is because there's is a mismatch between the patch and the file which is to be patched. The slightest variation will make it fail, even if it's just a carriage return that you can't see in your editor. That's why it's a good idea to send and download patches directly, rather than copy/pasting them into a forum or some similar place. That way you are sure that phpbb is not adding some fun to the text.

    Another common cause of failure is when the patch is designed for a different version of the file. A patch made for version X will some times fail to apply on version Y of the same program. Again, the .rej file will tell you which is what couldn't be done.

    If the patch file is there, and I look inside it and can find the file it's trying to patch, and the line in the file, and I can't see any reason for it not working, then what do I do next? Just patch the files by hand?[/B]
    You can patch the files by hand, or you can fix the patches, that's up to you. However, if the patch is supposed to work and it's not working you should instead try to figure what the root of the problem is. Most likely you are using an incorrect version of the patch over an incorrect version of the program that's to be patched. Maybe you are using an old version of the patch on a newer version of the program which already includes the functionality of the patch... I can't really say much more without looking at the code.

  3. #3
    Just Joined!
    Join Date
    Aug 2009
    Posts
    2
    Thanks i92guboj, very helpful post. It turns out in this particular case the line-endings between the .patch file and the .h file were different - one uses unix format and the other uses windows format so of course to me the lines looked identical but after your post I looked at them in Kate which has a nice menu option for viewing / changing the line endings and realised what was going on

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •