Re: How to apply patches?

Eric S. Mountain (eric@minouche.demon.co.uk)
Sun, 18 Feb 1996 14:12:55 GMT


Hi,

In message <9602162045.AA26437@dns1.state.mi.us> chitturi@dns1.state.mi.us writes:
> I am a newbie to applying patches to the source. How do you apply
> patches to the source code? How do you create a patch file to apply
> to the source code?
[..]

OK, I'm no guru on the subject, but here goes: First off, start with a
recent kernel source tree (around 1.3.57+). This will include a
script ../linux/scripts/patch-kernel you can run that will do all the
patching for you. Read the first few lines of the script for usage
info. (Basically, you tell it where to find the patch files (which
are supposed to be named patch-1.3.??.gz) and where your kernel source
is (/usr/src/linux = default) and it figures out the current kernel
version in the source tree, and applies all patches more recent than
that - it also takes care of checking for rejects, and cleaning out
.orig files).

If you really want to do it by hand, use gzcat and patch as follows:
gzcat patch-1.3.whatever | patch -p1 -E
... assuming you are in the toplevel dir. of your kernel source
(typically /usr/src/linux).

Creating patch files: this is a little trickier: the easiest way is to
have two kernel source trees (one patched with your own stuff, the
other "clean"). You will also need to get rid of any .o files,
executables etc. as you don't want them included in the patch! (->
make clean, or make distclean should do the trick).

Now, suppose the original source tree is in /usr/src/linux-1.3.64 and
your patched source tree is in /usr/src/linux-patched.

cd /usr/src
diff -u --recursive --new-file linux-1.3.64 linux-patched > patch-file

... will produce a patch for going from linux-1.3.64 to linux-patched.

To use apply this patch you will have to use the "patching by hand"
method I described above.

[ I've been working on a script to build patches even when the kernel
source trees contain binary files, but I'm not sure it's quite up to
scratch yet - if anyone has done something along these lines already,
I'm interested! Alternatively, if anyone wants a copy of what I've
done send email... ]

> If you know of an FAQ or document on creating and appling patch files
> please let me know.
[..]

Kernel-HOWTO on sunsite in the usual place (something like
.../Linux/docs/HOWTO I think)

Hope this helps, Eric

-- 
Eric S. Mountain  -  eric@minouche.demon.co.uk

I'm a Hollywood writer; so I put on a sports jacket and take off my brain.