KernelMaintenanceStarter
ContentsBRTableOfContents |
This document is based on the KernelMaintenance page and meant to be a more elaborate version for people (like me) that are not familiar with the Debian build system.
Basic system setup
For doing kernel maintenance there are a few packages required:
- git-core
- debhelper
- build-essential
- fakeroot
- kernel-wedge
Those can be installed by calling
sudo apt-get install git-core debhelper build-essential fakeroot kernel-wedge
Build system breakdown
Building is done by calling debian/rules [<target>] (which is a executable makefile). The call should be given a target name (though for the kernel the default seems to be something like make all). The debian defined targets are:
- clean
- binary
- binary-arch
- binary-indep
- build
- build-arch
- build-indep
There are others for the kernel, LUM (linux user modules), LRM (linux restricted modules) and LBM (linux backport modules) which are Ubuntu specific and will be explained later on.
Building the kernel
First, the kernel sources are fetched like described in the KernelGitGuide. In the top-level kernel directory
fakeroot debian/rules binary-arch
will build the binary packages for all kernel [https://wiki.ubuntu.com/KernelMaintenance#head-2568e78ff098da48bf1dac0dcb64c5263833e7cb flavours]. The packages itself will go, by Debian convention, to the directory one level above the current directory. Other files created during the process are located in the debian directory.
In order to compile only a specific flavour, the name of that can be used instead of arch, like in the following example:
fakeroot debian/rules binary-generic
Another special target is binary-headers which creates an architecture independent package which contains just the kernel headers. This has to be installed before compiling any modules packages.
fakeroot debian/rules binary-headers
Note: When using dpkg to install the package created by the binary-headers package, I had to create /lib/modules/<version> directory and the softlink called build from that directory to /usr/src/linux-headers-<version>, manually.
Building linux-user-modules
First get the source
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-hardy-lum ubuntu-hardy-lum
Then check for the ABI version (debian/changelog) and install the linux-headers package that matches that and the flavour of modules that are to be build.
After that the modules can be build by
fakeroot debian/rules binary-modules-<flavour>
where flavour is one generic, rt, ume, xen, etc.
Building in a chroot environment
This is useful to do builds for other architectures that are supported by the CPU (like LPIA (low power intel architecture) on i386 or i386 on x86_64) or to do builds for newer release without upgrading the whole machine.
There is an utility called debootstrap that will simplify this task a lot. First install it with apt-get, then call (as root)
debootstrap --arch <arch> <suite> <target>
This will create the directory target and then download and install a basic system in that directory. The suite is for example hardy and arch might be i386 or lpia.
Note: To be able to use hardy as a suite from a system install with gutsy, I had to enable gutsy-backports in the installation sources.
After debootstrap finishes successfully the chroot environment also has to be prepared for building.
sudo chroot <target> apt-get-install git-core debhelper build-essential fakeroot kernel-wedge
I personally liked to work with my normal user within that environment. So I did the following optional steps _before_ the chroot:
sudo cp /etc/passwd /etc/shadow /etc/group /etc/sudoers <target>/etc sudo mount --bind /home <target>/home
Note: The bind mount, as far as I know, has to be done after each reboot.