Whole document tree Packaging Linux kernel patches for DebianYann DirsonDebian $Revision: 1.14 $
FeaturesCurrent features
Features to come with version 1.0
The dh_installkpatches debhelper add-ondh_installkpatchesDescriptiondh_installkpatches is a debhelper script that reads debian/package.kpatches or debian/package.kpatches.something files describing one or several revisions of a single kernel patch, and installs them into the package build directory with customized apply and unpatch scripts. It also sets the kpatch:Depends substitution variable, that you should use in your control file to ensure that generated material in your package get all their dependencies. The use of kpatch:Depends requires a build-dependency on version 0.99.3 or later of the dh-kpatches package. Using this variable is now required, since 0.99.16 (mostly because too many people forgot to set it). OptionsThis program does not take any particular option in addition to the standard debhelper(1) ones. See alsodebhelper(1), make-kpkg(1). /usr/share/doc/dh-kpatches/dh-kpatches.html or /usr/share/doc/dh-kpatches/dh-kpatches.pdf.gz. AuthorThis tool and manual page were written by Yann Dirson
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license can be found under /usr/share/common-licenses/FDL. Description of the kpatches file formatThe syntax of kpatches files is inspired by the syntax of Debian control-files. A kpatches file contains sections, which are separated by one or more empty lines. Each section is made of Key: value lines. Revision 0 kpatches filesThis is the currently supported format for kpatches files. It is to be superceded shortly with a new revision, more general, described later in this document. The file starts with a section for generic patch information, and then has one for each patchfile, allowing versions of the patch for many kernel versions to be specified in one file. The generic partMandatory fields
Optional fields
The patchfile-specific partsMandatory fields
Optional fieldsThe optional fields, when not provided, all take hopefully reasonable default values
Examples of revision 0 kpatches fileskdbThese are the 2 kpatches files for the kernel-debugger patch. This patch was monolithic for 2.2 kernels, and has been split for recent 2.4 kernels into an architecture-independant part and one architecture-dependant part per supported architecture. Example 3. The architecture-independant kdb patch Patch-name: Kernel debugger architecture-independant core
Patch-id: kdbcore
Path-strip-level: 1
Patch-file: kdb-v2.1-2.4.17-common-1
Architecture: all
Kernel-version: 2.4.17 Example 4. The architecture-dependant kdb patches Patch-name: Kernel debugger
Patch-id: kdb
Path-strip-level: 1
Patch-file: kdb-v1.5-2.2.18
Architecture: i386
Kernel-version: 2.2.18
Patch-file: kdb-v2.1-2.4.17-i386-1
Architecture: i386
Kernel-version: 2.4.17
Depends: kdbcore
Patch-file: kdb-v2.1-2.4.17-ia64-011226-1
Architecture: ia64
Kernel-version: 2.4.17
Depends: kdbcore Revision 1 kpatches filesThis will be the next supported format for kpatches files. It has not been implemented yet. It is described here for public review. There are 3 levels of information in this file. A kernel-patch (1st level) is a set of patch alternatives (2nd level), each of which is made of a sequence of patch operations (3rd level). The file starts with a section for generic patch information, and then, for each alternative, has an alternative-specific section followed by one section for each patch operation. An alternative section is syntactically distinguished from an operation section by their mandatory constituent fields. The generic partMandatory fields.
Optional fieldsFor various fields in the alternative-specific and operation-specific parts it can be useful to provide default values. These are defined using fields named by prepending Default- to those fields names. Examples include Default-Path-strip-level and Default-Architecture. The alternative-specific partsA number of alternative-specific fields are used as conditions for this alternative to be considered. This allows not only to specify in the same file versions of the patch for many kernel versions, but also to specify versions of the patch for different kernel flavours. For example, the LTT patch comes for 2 kernel flavours: plain kernel, and RTAI-patched kernel. The order of alternative sections is significant: the 1st alternative for which all conditions are fullfilled is selected, and all further alternatives are ignored. Mandatory fields
Optional fieldsThe optional fields, when not provided, all take hopefully reasonable default values
The operation-specific partsMandatory fields
Types of operation
Per-operation-type fieldsFields for the diff operation
Fields for the unpack operation
Fields for the copy operation
Examples of revision 1 kpatches fileslttThe Linux trace toolkit provides kernel patches both for vanilla kernels and for RTAI kernels. Although there's not yet a packaged version of the RTAI patch, here is what it would look like. Example 7. The LTT patch Patch-name: Linux Trace Toolkit
OS-kernel: linux
Patch-id: ltt
Kernel-version: 2.4.16 - 2.4.17
Architecture: all
Operation: diff
File: Patches/patch-ltt-linux-2.4.16-vanilla-020415-1.14
Kernel-version: 2.5.7
Architecture: all
Operation: diff
File: Patches/patch-ltt-linux-2.5.7-vanilla-020415-1.14
Kernel-version: 2.4.16
Kernel-flavour: rtai
Architecture: all
Operation: diff
File: Patches/patch-ltt-rtai-24.1.8-020317-1.14 lkcdThe kernel crash dump patch requires that a script be copied into the debian part of the kernel tree. Currently this is done by a creating a new patch (named kerntypes) with hand-written apply script, not taking advantage of the dh-kpatches mechanism. Here is how it would look like in revision 1: Example 8. The LKCD patch Patch-name: Linux Kernel Crash Dump
Patch-id: lkcd
Default-Path-strip-level: 1
Default-Architecture: all
Kernel-version: 2.4.17
Operation: copy
From: debian/image.d/kerntypes
To: debian/image.d/
Operation: diff
File: lkcd-4.1-1.patch
Kernel-version: 2.4.18
Operation: copy
From: debian/image.d/kerntypes
To: debian/image.d/
Operation: diff
File: lkcd-4.1-1-2.4.18.patch Baruch Even Example 9. The LKCD patch (alternate version) Patch-name: Linux Kernel Crash Dump
Patch-id: lkcd
Default-Path-strip-level: 1
Default-Architecture: all
Kernel-version: 2.4.17
cp: debian/image.d/kerntypes debian/image.d/
patch: lkcd-4.1-1.patch
Kernel-version: 2.4.18
cp: debian/image.d/kerntypes debian/image.d/
patch: lkcd-4.1-1-2.4.18.patch The description is more concise, but I fear it would be too losely structured (much more of the information gets stored in left-hand parts of statement), possibly leading to strange-looking stanzas, and possibly impairing extensibility. Here is what the expanded version of the last sample (without default fields) would look like: Example 10. The LKCD patch (second alternate version) Patch-name: Linux Kernel Crash Dump
Patch-id: lkcd
Kernel-version: 2.4.17
Architecture: all
cp: debian/image.d/kerntypes debian/image.d/
patch: lkcd-4.1-1.patch
Path-strip-level: 1
Kernel-version: 2.4.18
Architecture: all
cp: debian/image.d/kerntypes debian/image.d/
patch: lkcd-4.1-1-2.4.18.patch
Path-strip-level: 1 In the same spirit, but datatype-driven instead of operation-driven. This one lies somewhere in between Baruch's proposal and my original one. Example 11. The LKCD patch (third alternate version) Patch-name: Linux Kernel Crash Dump
Patch-id: lkcd
Default-Path-strip-level: 1
Default-Architecture: all
Kernel-version: 2.4.17
File: debian/image.d/kerntypes
Target-dir: debian/image.d/
Diff: lkcd-4.1-1.patch
Kernel-version: 2.4.18
File: debian/image.d/kerntypes
Target-dir: debian/image.d/
Diff: lkcd-4.1-1-2.4.18.patch |