Re: Reading and applying patches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chong Yu Meng wrote:
> On Tue, 2006-09-05 at 01:44 -0400, Todd Zullinger wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Chong Yu Meng wrote:
>>> Hi all,
>>>
>>> I'm having some difficulty understanding patching in general. A
>>> little background: I downloaded the source tarball for a program and
>>> it will not "make" cleanly. Checking the forum on the website,
>>> someone had published a patch in the form of text in an email that
>>> looks like this:
>>>
>>> --- mlrate/mlrate.c 2003-01-27 10:31:31.000000000 +0100 
>>> +++ mlrate.new/mlrate.c 2004-11-22 12:37:52.086783325 +0100 
>>> @@ -25,6 +25,8 @@ 
>>> #include <string.h> 
>>> ... and continues for a bit longer
>>>
>> To apply this patch you would use the patch program.  Usage is
>> something like this:
>>
>> cd /where/your/mlrate/tarball/is/
>> patch -p1 < /path/to/your/saved/patch
>>
>> The -p1 option tells patch to strip off the first directory when
>> looking for the file(s) to patch.  So if you have a diff that starts
>> with "--- mlrate/mlrate.c" and you're in the directory where mlrate.c
>> is, -p1 would remove the mlrate/ part from the diff and find the file
>> to patch properly.
> 
> Thanks, all!
> 
> Let me see if I understand this correctly:
> 
> I have untarred the source tarball into /usr/src/mlrate, and mlrate.c
> is now inside /use/src/mlrate/src directory. So, now I copy and paste
> the text from the forum to a text file (say, mlrate.patch) and save it
> under /usr/src/mlrate/src. Then I go into the directory
> /usr/src/mlrate/src and enter the command:
> 
> patch -p0 < mlrate.patch
> 
> And the patch command will know what to do and patch it. 
> 
> Then I can run "make" and "make install" as per usual?
> 
> Thanks and Regards.
> 
Almost correct. Because the file was made comparing files in the
milrate and milrate.new directories, you will need to run

patch -p1 < mlrate.patch

to strip out the milrate and milrate.new part of the path to the
file. You will find that you use -p1 more often then you use -p0
because it tends to work out better to have the old version in one
directory, and the new version in another directory when making changes.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux