How to properly compile a kernel?

Josef Wolf jw at raven.inka.de
Thu Jan 17 23:36:41 UTC 2008


On Thu, Jan 17, 2008 at 10:54:27PM +0100, Wolf Canis wrote:
> Josef Wolf wrote:
> > Wolf Canis wrote:
> >> You have to know the complete Ubuntu kernel build system and a lot
> >> space left on your hard disk.
> >> I am not exactly sure about that.  The files I mentioned on the top of
> >> this mail were produced by
> >>
> >>    apt-get source linux-source-2.6.22
> >>    cd linux-source-2.6.22-2.6.22
> >>    AUTOBUILD=1 fakeroot debian/rules binary-debs
> >>
> >> Looks pretty easy once you figured out the correct commands.
> I assume you don't need any restricted module, then you are right.

I have not come to the modules yet.  I definitely will need something
from linux-ubuntu-modules.  Yes, I expect problems when I come to the
modules.  But first, I want to get a clear understanding about how to
properly build the kernel.  Currently, I am trying to figure out a way
to both, have my cake and eat it.  That is, I want to:

 - automatically notice which original ubuntu kernel is installed and
   automatically download+configure+compile+install its source.

 - track whether new version (e.g. security patches) of the stock
   kernel is available (best would be to receive new version with
   "apt-get upgrade".

 - automatically notice the upgrade and download+config+compile+install
   the new source again.

I want to do all this automatically because I have set up a distributed
configuration mechanism (in spirit similar to cfengine).  Therefore, I
need to know the exact names of versions/packages/files/directories.

The first hurdle seems to be to figure out all the version information.
First two steps seem to be easy:

   $ uname -r                              # version of running kernel
   2.6.22-14-generic
   $ dpkg -S /boot/vmlinuz-`uname -r` | cut -d: -f1  # name of package
   linux-image-2.6.22-14-generic

But then it gets interesting: how do I (automatically) know that

   $ apt-get source linux-image-2.6.22-14-generic

creates

   linux-source-2.6.22-2.6.22

and when this is built, 

   linux-image-2.6.22-14-generic_2.6.22-14.47_i386.deb

is created.

Of course, I could opendir/readdir and do some regex matches to find
out which directory/file is actually created.  But I don't like this
idea very much because it is a kludge and far from a proper solution.

Anyone already done that?  Any hints?




More information about the ubuntu-users mailing list