Raulp
Raulp

Reputation: 8196

Applying patch folder to a linux kernel

I have folder of patches(patchfile1.patch,patchfile2.patch and patchfile3.patch).How can I patch linux kernel from the patches given in this folder via single command.Or do i have to apply the patch one at a time from the folder

cd /kernel-directory 
patch -p1 < patchfile1.patch
patch -p1 < patchfile2.patch
patch -p1 < patchfile3.patch

etc

Upvotes: 2

Views: 1694

Answers (2)

Steve
Steve

Reputation: 1

You could apply them all in a loop:

$ for p in `ls -v /path/to/patches/*.patch`; do patch -p1 < $p; done


Note that for many patch sets, the order in which they're applied matters. I used the -v switch to GNU ls above to get the natural sort. Otherwise, once you hit patchfile10.patch, the order from ls would look like:

patchfile1.patch
patchfile10.patch
patchfile2.patch
...

Which may be fine, but not always.

Upvotes: 0

CL.
CL.

Reputation: 180210

In theory, it would be possible to concatenate all the patch fiels and apply them at once. However, you should apply them one at a time so that it is possible to detect which one, if any, has an error or is outdated.

Upvotes: 2

Related Questions