Jump to content
Tuts 4 You

How to apply patches from diff in MinGW?


LCF-AT

Recommended Posts

Hi guys,

today I have a new question so maybe anyone can help me.I was playing around with MinGW to compile some files similar like in the past where I compiled some FFmpeg versions for doing some tests.Now I was trying to compile rtmpdump / librtmp files and its also working so far.The problem I have now is how to apply patches (.diff file) in MinGW shell?This seems not to work correctly.On internet and readme file of the patch / diff file I found some infos using commandline like this...

patch -p0 -i Patch.diff
or
patch -p0 < Patch.diff
                      
make
                      
make install prefix=/usr

....I tried them and first some many same messages....

$ patch -p0 < Patch.diff
patching file Makefile
Reversed (or previously applied) patch detected!  Assume -R? [n] y
patching file librtmp/Makefile
Reversed (or previously applied) patch detected!  Assume -R? [n] y
patching file librtmp/amf.c
Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 succeeded at 320 (offset 1 line).
Hunk #2 succeeded at 510 (offset 7 lines).
Hunk #3 succeeded at 595 (offset 9 lines).
Hunk #4 succeeded at 631 (offset 11 lines).
...etc
Hunk #31 FAILED at 2902.
Hunk #32 FAILED at 2930.
Hunk #33 FAILED at 2975.
Hunk #34 FAILED at 3003.
....
Hunk #56 succeeded at 5803 (offset 67 lines).
21 out of 56 hunks FAILED -- saving rejects to file librtmp/rtmp.c.rej
....
                        
                        
$ make
make[1]: Entering directory `/c/compiletest/rtmpdump-ksv-master/librtmp'
gcc -Wall   -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL  -O2 -fPIC   -c -o rtmp.o rtmp.c
rtmp.c:60:25: fatal error: openssl/ssl.h: No such file or directory
 #include <openssl/ssl.h>
                         ^
compilation terminated.
make[1]: *** [rtmp.o] Error 1
make[1]: Leaving directory `/c/compiletest/rtmpdump-ksv-master/librtmp'
make: *** [librtmp/librtmp.a] Error 2


$ make install prefix=/usr
gcc -Wall   -DRTMPDUMP_VERSION=\"v2.4\"   -O2   -c -o rtmpdump.o rtmpdump.c
rtmpdump.c: In function 'GetLastKeyframe':
rtmpdump.c:296:52: warning: unknown conversion type character 'l' in format [-Wformat=]
   RTMP_Log(RTMP_LOGDEBUG, "bAudioOnly: %d, size: %llu", bAudioOnly,
                                                    ^
rtmpdump.c:296:27: warning: too many arguments for format [-Wformat-extra-args]
   RTMP_Log(RTMP_LOGDEBUG, "bAudioOnly: %d, size: %llu", bAudioOnly,
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: Entering directory `/c/compiletest/rtmpdump-ksv-master/librtmp'
gcc -Wall   -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL  -O2 -fPIC   -c -o rtmp.o rtmp.c
rtmp.c:60:25: fatal error: openssl/ssl.h: No such file or directory
 #include <openssl/ssl.h>
                         ^
compilation terminated.
make[1]: *** [rtmp.o] Error 1
make[1]: Leaving directory `/c/compiletest/rtmpdump-ksv-master/librtmp'
make: *** [librtmp/librtmp.a] Error 2

So you see I get some errors.New files was created into folders but also one rejected file (no clue why some patches was rejected).First I would like to know what it does ask me the whole time about patch detected and whether I need to choose y or n!?Does it mean the patch is already in the sources present and I dont need to press y?How to fix that openssl/ssl.h error?I tried to put the file into folder but still get the errors.Maybe anyone can tell me how to make that correctly if possible to apply the patches in that diff file.I also have to say I am not advanced with using MinGW.The source and diff file inside you can download here...

https://github.com/sstativa/rtmpdump-ksv/archive/master.zip

Thank you

Link to comment

HI kao,

thanks for your answer so far.So if you day the patches are already applied why are then some patches done?I get some hunk succeeded and some failed.Some are done some not.So I checked now the source file of rtmp.c

https://github.com/sstativa/rtmpdump-ksv/blob/master/librtmp/rtmp.c

and its not updated = missing patches.Now I checked the rtmp.c file on the link you did post of the patches and there I see the patches.

https://github.com/sstativa/rtmpdump-ksv/blob/df3369dd798443a26ac99a089a671de5e21e06fb/librtmp/rtmp.c

Both files are diffrent.If I download the package of the source = patches missing and if I try to apply then = failed and some success.

Example:
Source from package
https://github.com/sstativa/rtmpdump-ksv/blob/master/librtmp/rtmp.c
Now see at line 3258 there you can see this code line below
if (strlen(pageUrl) > 8)

Now the other rtmp.c file
https://github.com/sstativa/rtmpdump-ksv/blob/df3369dd798443a26ac99a089a671de5e21e06fb/librtmp/rtmp.c
See at line 3256 there you can see this code line below
if (strlen(pageUrl) > 7)

In the patch.diff file you can see this patch too at line 1251
if (strlen(pageUrl) > 7)

So this is one patch for example which fails if I try to make the patch and using it with the source of the rtmpdump-ksv-master.zip package.In this case it means the patches or not all patches are already applied in this source package but makeing the patch fails.The question now is why.....and why the source package is not updated etc you know.Somehow I dont check that so far.

Ok,I did download now the other package....from here...

https://github.com/sstativa/rtmpdump-ksv/tree/df3369dd798443a26ac99a089a671de5e21e06fb

..this rtmp.c has the patch inside.Ok,its strange again,so why are there more packages to download here below?

https://github.com/sstativa/rtmpdump-ksv/commits/master

Anyhow its again too high for me. :) Would be cool if you maybe could explain that for me to get on the right track.Should I just download the latest pack from the commits section and if yes should I then still trying to use that patch / diff!?

greetz

Link to comment

I already explained what I think you should do - get the latest version and just compile it. But if you wish to complicate things (like you always do), you're welcome to keep messing with the patch file.

You can use the blame feature to find out why that line says "if (strlen(pageUrl) > 8)":  https://github.com/sstativa/rtmpdump-ksv/blame/master/librtmp/rtmp.c#L3258
Apparently, it needed to be "> 8" to work with chaturbate. Don't ask me why, I didn't make that commit.

 

  • Like 1
Link to comment

Hi,

nobody wants to complicate it kao.Just wanna check that.

One question,so what is the latest version there?

https://github.com/sstativa/rtmpdump-ksv
or from tree..
https://github.com/sstativa/rtmpdump-ksv/tree/946c8a980902515f435e0fcb3225823268df4cc3

Just downloading from main page (no commit / tree package) and compile = done,without using the diff cheese?So nobody said that using the diff isnt needed anymore.

greetz

Link to comment

At this moment of time, both links will get you the same code. In the future, they will be different.

https://github.com/sstativa/rtmpdump-ksv - this will always get you the latest version. If there will be new commits, downloading for this link you'll get those commits too.
https://github.com/sstativa/rtmpdump-ksv/tree/946c8a980902515f435e0fcb3225823268df4cc3 - this will always get you that specific version, with everything including a fix for chaturbate but no new commits after that.

  • Like 1
Link to comment

There are many tools to apply a *.diff file TortoiseSvn  etc....

but my favorite is Winmerge a good tool to compare files and make patches.

Edited by ragdog
  • Like 1
Link to comment

Hi guys,

the last commit package = same inside like latest package I can download on main site?So you mean the last commit version = latest version + actually commit patch X (extra or also patched?),yes?Maybe I did checked that now correctly. :) Good ok,but why they dont update the latest package / infos like that its not needed to execute that diff patches file anymore,you know.

PS: Thanks for that Winmerge tool info raggy. :)

greetz

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...