Using diff and patch commands

To create a patch for a given source code, the diff command should be used. And to apply that patch, the patch command takes place. Both should be available on your Linux system.

$ diff -uNr linux-3.16.0 linux-3.16.0-mine > patch-3.16.0-myfeature

Let’s say someone wants to use the patch. This guy, basically, should download the desired source code first (in our case, linux-3.16.0). Then, to apply that patch to the whole directory tree, he/she needs to add ‘-p1’ option to the patch command:

$ cd linux-3.16.0
$ patch -p1 < patch-3.16.0-myfeature

The -p1 option means patchlevel 1.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s