kernel patch management with stgit

Distributions don't necessarily have up-to-date versions of git yet, so you need to install it yourself. Thankfully that's fairly easy.

First, download the latest snapshot from
Unpack and cd into the git directory, and do
make PYTHON_PATH=/usr/bin/python2.4 prefix=/usr/local all doc
sudo make prefix=/usr/local install install-doc

(I need PYTHON_PATH because git wants python 2.4 but /usr/bin/python on my machine is 2.3. You may not need it. The "prefix" arguments are also optional if you're happy with the default of "/usr". If you set the prefix, you'll also need to put a "export GIT_EXEC_PATH=/usr/local/bin/" in your .bashrc (or adjust for your favorite shell).)

If the compile fails, check to see whether it's finding all the libraries and headers it needs. The mostly likely culprits are libcurl and asciidoc, so you may need to install those before getting a successful compile.

Next, get stgit and install it

git clone stgit
cd stgit
python install --prefix=/usr/local

and get the latest kernel tree:

stg clone git:// linux-2.6
cd linux-2.6

If you'd like to revert the working tree to a particular well-known version, you can do something like

git reset --hard v2.6.15

Next, set up stgit and create your first patch:

stg init
stg new my-first-patch

Modify whatever files you'd like, then

stg refresh

or, if you also want to look at the resulting patch, and perhaps modify the description while you're there,

stg refresh -es

You can create more patches that apply on top of the first patch with stg new and stg refresh. Repeat this process, and the result will be a series of patches that apply one on top of the other. You can revisit an earlier patch at any time using

stg goto name_of_earlier_patch

and then reapply all your patches with

stg push -a

If a modification to an earlier patch creates conflicts that prevents a later patch from applying, then "stg push" will stop at the problematic patch and ask you to fix up the conflicts before continuing.

At any time you can see the list of currently applied patches with

stg applied

When it comes time to update to a new upstream, you can

stg pull

which will pop off all your patches, fetch the latest upstream kernel, then attempt to push all your patches back on again, stopping to let you sort out any conflicts.

The rest of stgit is mostly pretty easy to figure out on your own. You can get help about any stgit command with

stg commandname -h

and get the list of stgit commands with

stg -h