This page contains instructions and tips for those who want to compile their own kernel. This includes obtaining sources, unpacking, patching, configuring, compiling, installing, and packaging a kernel. To this end, there are two main work-flows:
These work-flows tend to be completely different... but both are covered in this document. A few other typical cases (debug symbols, out-of-tree modules) are also covered.
Note that all the examples here will use the (now obsolete) `kernel-netbook` package as an example. Please substitute the name of the kernel package you're working with. To figure out which one you're currently running, this command will tell you:
$ rpm -qf /boot/vmlinuz-$(uname -r)
If you simply want debugging symbols, you need only install the `debuginfo` package. You will typically have to enable the `debug` repository, first. For example:
$ sudo zypper mr --enable core-debuginfo $ sudo zypper install kernel-netbook-debuginfo
If you have an out-of-tree kernel module that you need to build, you need to install the `devel` package for that kernel, as well as any compiler tools:
$ sudo zypper install rpmdevtools pattern:development-tools $ sudo zypper install kernel-netbook-devel
$ sudo zypper install pattern:meego-development-tools
This installs the kernel headers that you need in order to build your module. Now refer to the instructions that came with the module.
These instructions are for those who simply wish to compile a kernel and install it (without concern for package management, MeeGo compliance, etc.). These instructions aren't particular to MeeGo, except for obtaining the sources.
First, make sure that you have the source repositories enabled.
$ sudo zypper mr --enable core-source
Next, grab the source RPM from the repository. We're also installing the `quilt` utility. Note that this shows the `kernel-netbook` package. You will need to substitute the name of the kernel you wish to use as a starting point.
$ sudo zypper install quilt ncurses-devel $ sudo zypper si kernel-netbook
Now create a `sandbox` folder for unpacking the source RPM.
$ mkdir sandbox/ $ cd sandbox/ $ rpm2cpio ~/rpmbuild/SRPMS/kernel-netbook-188.8.131.52-12.1.src.rpm | cpio -id --no-absolute-filenames
Inside this folder, you now have all the sources that were used to compile the kernel. This includes the original tarball released at kernel.org, all patches, rpm spec files, etc. Unpacking the kernel is done like this:
$ tar xjf linux-2.6.35.tar.bz2
To patch the kernel, note that there is a file called `series` in the current directory. This can be used by a program called `quilt` to patch (and un-patch) a series of patches to a source tree. To use it, you need to set the environment variable "QUILT_PATCHES" to point to the location of the `series` file.
$ cd ../linux-2.6.35 $ export QUILT_PATCHES=.. $ quilt push -a
Now, compile and configure the kernel like normal (in this case, copying the config from the current kernel):
$ cp /boot/config-184.108.40.206-12.1-netbook .config $ make menuconfig $ make -j3 $ sudo make modules_install && sudo make install
Note that `make install` understands how to manipulate the extlinux boot loader, so there's no extra steps to configure the boot loader.
Now reboot to try the new kernel:
$ sudo shutdown -r now
If you wish to work on your own kernel patch set, you will probably want to learn to use git or quilt for this sort of work. Both are available within MeeGo.
The instructions above are simple and productive for development. When you wish to package a custom version of the kernel, you must be more careful to consider MeeGo Compliance. Also, it's best to match the current work-flow of the core kernel developer team. Since this workflow is constantly being adjusted to the needs of that team, your best resource is:
The kernel is configured by making overrides to config-generic. E.g. for an x86 target, config-generic is first read. Then config-x86 is read. Where there's a conflict with config-generic, the values in config-x86 are used. Likewise, the rpm spec files are created as override/adaptations of the kernel.spec file.
Adding patches requires that you add them to both `series` and your adaptation spec file (e.g. kernel-netbook.spec). You then use rpmbuild to package the kernel as you would any other package: copy all sources to ~/rpmbuild/SOURCES and the spec file to ~/rpmbuild/SPECS.