Click to See Complete Forum and Search --> : adding a patch?


ron1e69
09-22-2002, 05:15 PM
Hi i'm quite a newb to linux, and need a little help.

How do you add a a patch to a program?? I have the the code to be added but dont now how to edit the original prog. I have mandrake 8.1 if it makes a difference.

truls
09-23-2002, 11:52 AM
Bit unclear on the question.

Do you have a diff file (patch for a program)?
If so, simply do a 'patch source diff-file', or check 'man patch' which should explain it. Otherwise just edit the source in an editor. If this doesn't solve it, please post more details on the files you have and their content.

ron1e69
09-24-2002, 09:04 AM
Sorry for being so vague, i've only been using linux a few days.

I have the source code for the patch saved in a text file, i need to add this code to the original program. I've been looking around and as far as i can tell this isn't possible, is it??

I'm pretty sure i've a C compiler installed as i have been able to compile tar.gz files, or am i miles of the mark here???

Do i have to get all the original source code for the program i would like to patch, add the patch code and then compile?? If so how do i start the compiler and compile.

Sorry for asking such a wide open question, but all the texts i've been reading are a bit advanced at the moment. Thanx for the help :0)

bwkaz
09-24-2002, 09:22 AM
Yes, you need the original source to apply your patch to. Also, the version of the program that you get the source for has to match the version that the patch was created against, unless you want to grovel through the source trying to figure out what got changed in the patch, and change it manually. Kinda defeats the purpose of the patch. For example, if I have a patch against the Linux kernel, version 2.4.19-pre8, then I had better apply it to version 2.4.19-pre8, otherwise it won't be very clean. Or it might have already been applied in 2.4.19-pre10. Or whatever.

Which program are you patching, and where'd you get the patch from?

ron1e69
09-24-2002, 09:53 AM
OK im with ya. I would like to add a patch to traceroute, the patch just adds a new switch. As for where i got the patch from i dont know found it using google and saved the source to disk.

Right so i need to find the v of traceroute which matches this code. So how do i start the c compiler. Has any1 got any links for info on this???

ron1e69
09-26-2002, 09:10 AM
After doing some reading i realise my original question was quite stooopid :0)

Ok i've wrote the src code for the patch in vi, it's a diff, so should i name the file .diff??

I've got the correct v of traceroute for the diff, it came as an rpm. It's installed but i cant find the src code file for it? Any ideas? I should be looking for the .c file shouldn't I?

Now if i'm understanding this correctly to add the diff file i run: patch origfile difffile

then compile it. Am i on the right lines here??

truls
09-26-2002, 09:18 AM
You'll be wanting the RPMS (Package Source) which contains the sourcecode. The easiest thing is to find the .tar.gz version of traceroute and unpack that for the sourcecode. RPM-packages are binary-only, no sourcecode.

I found a source for slackware traceroute, along with a patch here (http://www.cr.postgresql.org/Unix/Linux/Slackware/slackware/source/n/traceroute/) . Check that out to see what I mean.