How do I apply a patch?
The first step is to run man patch, to see a little bit
about the patch command itself. There's also a fine
(quick) summary of using patch to update kernel source in
the Kernel-HOWTO Here's an even quicker, more general summary.
Most patches apply changes to a directory tree; for kernel
patches, they're applied to ./linux which assumes this
directory is in /usr/src. You'll need to change the
current directory to the correct spot (for the kernel, for
instance, /usr/src).
If your patch is compressed (indicated by a .gz
extension), you want to feed the patch program the
uncompressed form. You can do this via a pipe:
I prefer to always use the -s flag. It suppresses the
normal output of patch and only displays anything if there
is an error or problem with the patch. It is a lot easier to
identify a problem if the amount of irrelevant noise is
reduced.
zcat patchfile.gz | patch -sp0
If your patch is not compressed, you can use
input/output redirection to accomplish the patch:
patch -sp0 < patchfile
If the whitespaces in the patch you have got reinterpreted or
modified in anyway, patch will complain. Using the
-l option gives patch more freedom in how it
matches up whitespace in a line.
Sometimes, the patch may have been created with different top
level directories. Alan Cox's "ac"
kernel patches are often in this category. One solution to
using these patches is to rename your directories to suit, but the
better solution is to descend one directory (ie, cd
/usr/src/linux and change the -p0 option to
-p1.
Please note that this is a very short summary. See the man page
for patch if anything looks strange.
|