GLEP:26
Title:Handling kernels with portage
Version:1.2
Last-Modified:2004/11/11 21:32:21
Author:Nathaniel McCallum <npmccallum at gentoo.org>, Joshua Campbell <warpzero at gentoo.org>
Status:deferred
Type:Standards Track
Content-Type:text/x-rst
Created:2-May-2004
Post-History:2-May-2004, 11-Nov-2004

Contents

Abstract

This GLEP proposes to create a more consistent handling of kernels and kernel building. Currently "emerge kernel-name" only installs the sources and does not build anything. "emerge kernel-name" should install only sources OR only a binary kernel, its modules, and a tarballed package of kernel-headers, depending on USE flag.

Status

Timed out

Motivation

Currently, the only automated kernel build proceedure that we have is genkernel. While genkernel is a great tool, its main weakness is that it does not port well to other arches because of the initrd and the lack of good "generic" settings for other arches. This GLEP hopes to overcome this by abstracting the various layers of genkernel and implementing the most common aspect (the build proceedure) into a portage eclass.

Specification

There would be 3 layers to kernel building: (place of implementation)

Stages 1 and 3 are optional on most arches.

Stage 1 would be achieved through a seperate utility (perhaps like the current genkernel). This utility would help the user configure the kernel and any kernel/build related settings. This stage is optional and would only be used if a person wanted a customized kernel settings. One optional thought is to have this utility a part of the base Gentoo system. That way there are less steps to make a custom kernel.

Stage 2 would be implimented through an eclass. This stage is not optional. One would perform this step by typing "emerge kernel-name", where "kernel-name" is the name of the kernel package you want to use (ie. "gentoo-dev"). This package would have a "buildkernel" USE flag. If the flag was not set, it would simply download and install sources like we do currently. However, if the "buildkernel" flag is set, portage will perform the following steps:

  1. (as a dependency) download and install a tarball of "generic" kernel config files.
  2. Check to see if customized kernel config/settings have been set via Stage 1.
  3. Portage will use a custom config, if available. Otherwise, a "generic" config.
  4. If neither a custom config or a "generic" config is available, die (with message). This is needed as some arches don't/can't have "generic" configs, so they will simply be presented a message telling them to run the utility from Stage 1 (which they obviously skipped).
  5. Build the kernel and modules and install them
  6. Remove unnecessary files from the sources and tarball it as "kernel-headers". This tarball provides the appropriate files to build external modules against, like nvidia-kernel, etc... The external modules (when built) will determine the running kernel and unpack the appropriate tarball, to build against, then remove the files.

Stage 3 would merely be an ebuild that constructs an initrd image for either the running kernel or, lacking a running kernel, the newest kernel installed (by version/date installed?). Initrd's can't be used on all arches, so this ebuild can be keyword masked as appropriate. The initrd package would also have a "bootsplash" USE flag (on x86, maybe others) that would build in bootsplash support. Any non-default actions desired by the user can be handled with the utility from Stage 1.

This would lead us to several case scenarios (assuming kernel-config is part of the base system):

  1. default kernel, no initrd: "emerge gentoo-kernel"

  2. default kernel, initrd: "emerge aa-kernel initrd"

  3. default kernel, bootsplash initrd: "USE=bootsplash emerge mm-kernel initrd"

  4. non-default kernel, no initrd: "kernel-config gentoo-dev-kernel"

    "emerge gentoo-dev-kernel"

  5. non-default kernel, initrd: "kernel-config alpha-kernel"

    "emerge alpha-kernel initrd"

  6. JUST sources, no binary "USE=-buildkernel emerge grsec-kernel"

Rationale

There are many advantages gained by this method:

  1. Full arch support (GentooInstaller really could use this)
  2. More consistent with the rest of portage (installs binaries by building from source)
  3. Better user experience
  4. More flexability (genkernel forces building of initrd on x86)
  5. Don't have to store full kernel sources (each source tree is ~200MB unpacked)
  6. Creates the ability to make binary kernel packages for fast installs (think GRP kernel)
  7. A seperate package for "generic" kernel config files gives us better version tracking

The major problem is, however, that we currently have two different build systems, portage and genkernel. Having competing build systems is not a GoodThing TM. Therefore, we can either make portage build kernels or we can make genkernel build everything else.

Backwards Compatibility

If you want to emerge kernel sources the old way, just do: USE="-buildkernel" emerge kernel-name

Perhaps we could also name the new kernel-config program (from Stage 1) "genkernel" so that users can have a seemless transition.

Reference Implementation

not yet ..

Copyright

This document has been placed in the public domain.