A.1. patch and diffThis section is based on an article originally published in Linux Journal. One of the most common methods of doing kernel work is to use the patch and diff programs. To use these tools, two different directory trees: a "clean" one and a "working" one must be used. The clean tree is a released kernel version, while the working one is based on the same version but contains your modifications. Then you can use patch and diff to extract your changes and port them forward to a new kernel release. For an example, create two directories containing the latest kernel version as described in Chapter 3: $ tar -zxf linux-2.6.19.tar.gz $ mv linux-2.6.19 linux-2.6.19-dirty $ tar -zxf linux-2.6.19.tar.gz $ ls linux-2.6.19/ linux-2.6.19-dirty/ Now make all of the different changes you wish to do in the -dirty directory and leave the clean, original kernel directory alone. After finishing making changes, you should create a patch to send it to other people: $ diff -Naur -X linux-2.6.19/Documentation/dontdiff linux-2.6.19/ \ linux-2.6.19-dirty/ > my_patch This will create a file called my_patch that contains the difference between your work and a clean 2.6.19 kernel tree. This patch then can be sent to other people via email. A.1.1. New Kernel VersionsIf a new kernel version is released, and you wish to port your changes to the new version, you need to try to apply your generated patch onto a clean kernel version. This can be done in the following steps:
If you use this development process, I highly recommend getting the excellent patchutils set of programs (found at http://cyberelk.net/tim/patchutils). These programs enable you to manipulate text patches easily in all sorts of useful ways, and have saved kernel developers many hours of tedious work. |