Lines Matching refs:patch
11 This document is obsolete. In most cases, rather than using ``patch``
15 a patch to the kernel or, more specifically, what base kernel a patch for
24 What is a patch?
27 A patch is a small text document containing a delta of changes between two
31 To correctly apply a patch you need to know what base it was generated from
32 and what new version the patch will change the source tree into. These
33 should both be present in the patch file metadata or be possible to deduce
37 How do I apply or revert a patch?
40 You apply a patch with the ``patch`` program. The patch program reads a diff
41 (or patch) file and makes the changes to the source tree described in it.
46 This means that paths to files inside the patch file contain the name of the
52 unlabeled patch was generated against) you should change into your kernel
54 in the patch file when applying it (the ``-p1`` argument to ``patch`` does
57 To revert a previously applied patch, use the -R argument to patch.
58 So, if you applied a patch like this::
60 patch -p1 < ../patch-x.y.z
64 patch -R -p1 < ../patch-x.y.z
67 How do I feed a patch/diff file to ``patch``?
73 In all the examples below I feed the file (in uncompressed form) to patch
76 patch -p1 < path/to/patch-x.y.z
79 know of more than one way to use patch, then you can stop reading this
85 patch -p1 -i path/to/patch-x.y.z
87 If your patch file is compressed with gzip or xz and you don't want to
88 uncompress it before applying it, then you can feed it to patch like this
91 xzcat path/to/patch-x.y.z.xz | patch -p1
92 bzcat path/to/patch-x.y.z.gz | patch -p1
94 If you wish to uncompress the patch file by hand first before applying it
98 gunzip patch-x.y.z.gz
99 xz -d patch-x.y.z.xz
101 Which will leave you with a plain text patch-x.y.z file that you can feed to
102 patch via stdin or the ``-i`` argument, as you prefer.
104 A few other nice arguments for patch are ``-s`` which causes patch to be silent
106 screen too fast, and ``--dry-run`` which causes patch to just print a listing of
108 tells patch to print more information about the work being done.
114 When patch applies a patch file it attempts to verify the sanity of the
117 Checking that the file looks like a valid patch file and checking the code
118 around the bits being modified matches the context provided in the patch are
119 just two of the basic sanity checks patch does.
121 If patch encounters something that doesn't look quite right it has two
123 to find a way to make the patch apply with a few minor changes.
125 One example of something that's not 'quite right' that patch will attempt to
127 line numbers are different. This can happen, for example, if the patch makes
130 everything looks good it has just moved up or down a bit, and patch will
131 usually adjust the line numbers and apply the patch.
133 Whenever patch applies a patch that it had to modify a bit to make it fit
134 it'll tell you about it by saying the patch applied with **fuzz**.
135 You should be wary of such changes since even though patch probably got it
139 When patch encounters a change that it can't fix up with fuzz it rejects it
147 never see a fuzz or reject message from patch. If you do see such messages
149 patch file is corrupted in some way. In that case you should probably try
150 re-downloading the patch and if things are still not OK then you'd be advised
153 Let's look a bit more at some of the messages patch can produce.
155 If patch stops and presents a ``File to patch:`` prompt, then patch could not
158 applied with ``-p0`` instead of ``-p1`` (reading the patch file should reveal if
160 the patch but is not fatal).
163 message similar to that, then it means that patch had to adjust the location
170 This often happens if you try to apply a patch that was generated against a
171 different kernel version than the one you are trying to patch.
174 patch could not be applied correctly and the patch program was unable to
176 caused the patch to fail and also a ``.orig`` file showing you the original
179 If you get ``Reversed (or previously applied) patch detected! Assume -R? [n]``
180 then patch detected that the change contained in the patch seems to have
183 If you actually did apply this patch previously and you just re-applied it
184 in error, then just say [n]o and abort this patch. If you applied this patch
186 then you can say [**y**]es here to make patch revert it for you.
188 This can also happen if the creator of the patch reversed the source and
189 destination directories when creating the patch, and in that case reverting
190 the patch will in fact apply it.
192 A message similar to ``patch: **** unexpected end of file in patch`` or
193 ``patch unexpectedly ends in middle of line`` means that patch could make no
195 feed patch a compressed patch file without uncompressing it first, or the patch
202 a patch from kernel.org to the correct version of an unmodified source tree.
204 assume that either your patch file or your tree is broken and I'd advise you
205 to start over with a fresh download of a full kernel tree and the patch you
209 Are there any alternatives to ``patch``?
216 generate a patch representing the differences between two patches and then
226 interdiff -z ../patch-5.7.2.gz ../patch-5.7.3.gz | patch -p1
235 patch; lsdiff, which displays a short listing of affected files in a patch
236 file, along with (optionally) the line numbers of the start of each patch;
237 and grepdiff, which displays a list of the files modified by a patch where
238 the patch contains a given regular expression.
268 If regressions or other serious flaws are found, then a -stable fix patch
270 kernel is released, a patch is made available that is a delta between the
273 To apply a patch moving from 5.6 to 5.7, you'd do the following (note
276 first revert the 5.x.y patch).
283 $ patch -p1 < ../patch-5.7 # apply the 5.7 patch
290 $ patch -p1 -R < ../patch-5.6.1 # revert the 5.6.1 patch
292 $ patch -p1 < ../patch-5.7 # apply new 5.7 patch
319 patch does not apply on top of the 5.7.2 kernel source, but rather on top
322 So, in order to apply the 5.7.3 patch to your existing 5.7.2 kernel
323 source you have to first back out the 5.7.2 patch (so you are left with a
324 base 5.7 kernel source) and then apply the new 5.7.3 patch.
329 $ patch -p1 -R < ../patch-5.7.2 # revert the 5.7.2 patch
330 $ patch -p1 < ../patch-5.7.3 # apply the new 5.7.3 patch
357 kernel and the patch should be applied on top of the 5.7 kernel source.
364 $ patch -p1 < ../patch-5.8-rc3 # apply the 5.8-rc3 patch
371 $ patch -p1 -R < ../patch-5.8-rc3 # revert the 5.8-rc3 patch
372 $ patch -p1 < ../patch-5.8-rc5 # apply the new 5.8-rc5 patch
379 $ patch -p1 -R < ../patch-5.7.3 # revert the 5.7.3 patch
380 $ patch -p1 < ../patch-5.8-rc5 # apply new 5.8-rc5 patch