Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello all,

I am trying to build Net::Pcap on Win32, I have followed a thread previously written on this site and ended up at :

https://rt.cpan.org/Public/Bug/Display.html?id=53292#txn-912966

Problem is, being moderately stupid, I don't know how to patch what needs to be patched. I have strawberry Perl 5.14.2 and the 'patch' program appears to be included.

The only time I have patched previously, was with 'patch -np1' on Linux boxes, but that doesn't appear to work.

I seemingly had a little success with pathc -p0 < patchname.patch for one of the patches and then it all went destined for the u-bend.

Any help would be graciously received.

Many thanks !
  • Comment on How to patch modules with CPAN patch releases

Replies are listed 'Best First'.
Re: How to patch modules with CPAN patch releases
by moritz (Cardinal) on May 27, 2012 at 13:48 UTC

    Point one: patch wants to reach its patches from standard input by default, not from a file you give it on the command line.

    Point two: the patch files themselves contain the paths of the files to be patched:

    diff --git a/Makefile.PL b/Makefile.PL index 26ab13e..b966faa 100644 --- a/Makefile.PL # original file name +++ b/Makefile.PL # name of modified file

    (comments added by me).

    The filnames are a/Makefile.PL and b/Makefile.PL. But if your Makefile.PL is in the current directory, you need to tell patch to strip the a/ and b/ prefix. That's just one directory level each, so you need the -p1 option.

    In summary, in the directory that contains the code, to have patch modify the files in-place, run:

    patch -p1 < file-with-the-patches.diff
      Thanks folks for taking the time out of your day to answer my question. I have noted your answers, (--dry-run will forever remain in my brain ;) but, sadly I am still getting error(s) :

      With # patch -p1 < patchname.patch

      patching file Makefile.PL
      Assertion failed: hunk, file .\src\patch\2.5.9\patch-2.5.9-src\patch.c, line 354
      This application has requested the Runtime to terminate it in an unusual way.
      Please contact the application's support team for more information.

      I am not sure how to proceed...

Re: How to patch modules with CPAN patch releases
by tobyink (Canon) on May 27, 2012 at 13:21 UTC

    Personally I can never figure out the correct -p0, -p1, -p2 incantation to get patch to work correctly. Yes, I understand what the -pn options do, but I always end up getting the wrong number because of fencepost errors.

    My general technique is to try -p0, -p1, -p2, etc in conjunction with the --dry-run option until something looks like it's worked, then re-do without --dry-run.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: How to patch modules with CPAN patch releases
by Anonymous Monk on May 28, 2012 at 00:44 UTC
    probably need to run dos2unix or unix2dos on the patch file before applying