openSUSE:Create a patch file

Jump to: navigation, search

Ideally, we can build packages without modifying upstream source code. However, to solve some build issues, patching source code is sometimes necessary. Follow these steps to create your patch!

Extract source code

Usually your will get source code in format of *.zip or *.tar.gz archive files. Let's say it is named "foobar-1.2.0.tar.gz". Extract it in your working directory, which you can do with context menu in most file managers. All extracted content should be in one sub-directory, like "foobar-1.2.0".

Make a copy

Copy and paste the directory "foobar-1.2.0" to the same directory with a different name "foobar-1.2.0-patched". The name doesn't really matter.

Modify source code

Go to "foobar-1.2.0-patched", and modify anything you want to change.

Generate the patch file

Go to the parent directory of "foobar-1.2.0" and "foobar-1.2.0-patched". Run:

diff -rub foobar-1.2.0 foobar-1.2.0-patched > you-name-it.patch