Before continuing the series on Xbox-Linux, I want to write down how I currently manage my local kernel patches. While it is possible to use git and its rebase functionality for this purpose, it is not optimal. The way I currently work is to start with a vanilla Linux kernel tarball, extract it and apply the big Xbox-Linux patch. I then make changes to this tree, one change per commit/patch as a disciplined VCS user. Eventually I expect to want to update the Linux kernel by fetching a new tarball and applying all patches again. There is a tool which was created for exactly this workflow, and it's called quilt. It is commonly used in Debian to keep track of downstream changes to deb packages. Unlike git, it's been around forever so I can even use it on my ancient Debian 3.1 building VM.


quilt requires a slightly different workflow than a modern version control system. Instead of making changes first and committing them later, you must first declare a patch name and the files to patch before making changes. This is because by design there is no local repository. Patches are stored in the subdirectory patches/ along with a series file that declare the order the patches should be applied. quilt also stores some bookkeeping information in the .pc/ subdirectory.

To start a new patch while in the source tree top dir, do

$ quilt new change_name.patch

To declare a file to be included in the patch, do

$ quilt add path/to/file

Then make changes. To update the current patch with the change, do

$ quilt refresh

That's it! quilt refresh can be run multiple times to update the current patch. To make another change, just execute quilt new another_change.patch and start over.

To apply the patch set to a different tree, simply copy the patches directory to the tree. To apply the patches in order, one at a time, do

$ quilt push

repeatedly. Or quilt push -a to apply all patches listed in the series file. Likewise, patches can be unapplied by poping them.

Patches can have text headers which describe their functional changes. To edit the header of the latest patch, execute

$ quilt header -e

The old version of quilt that is packaged for Debian 3.1 doesn't have this option though, but it's easy enough to add a patch header by hand. There are more options to quilt, but these are enough for its basic functionality.