|GLEP 26: Handling kernels with portage|
|Author||Nathaniel McCallum <email@example.com>, Joshua Campbell <firstname.lastname@example.org>|
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.
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.
There would be 3 layers to kernel building: (place of implementation)
- Stage 1 - Configuring the kernel (optional) -- external utility
- Stage 2 - Building the kernel -- in an eclass
- Stage 3 - Building the initrd (optional) -- in an ebuild
Stages 1 and 3 are optional on most arches.
Stage 1 would be achieved through a separate 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 implemented 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:
- (as a dependency) download and install a tarball of "generic" kernel config files.
- Check to see if customized kernel config/settings have been set via Stage 1.
- Portage will use a custom config, if available. Otherwise, a "generic" config.
- 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).
- Build the kernel and modules and install them
- 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):
- default kernel, no initrd: "emerge gentoo-kernel"
- default kernel, initrd: "emerge aa-kernel initrd"
- default kernel, bootsplash initrd: "USE=bootsplash emerge mm-kernel initrd"
- non-default kernel, no initrd: "kernel-config gentoo-dev-kernel; emerge gentoo-dev-kernel"
- non-default kernel, initrd: "kernel-config alpha-kernel; emerge alpha-kernel initrd"
- JUST sources, no binary "USE=-buildkernel emerge grsec-kernel"
There are many advantages gained by this method:
- Full arch support (GentooInstaller really could use this)
- More consistent with the rest of portage (installs binaries by building from source)
- Better user experience
- More flexibility (genkernel forces building of initrd on x86)
- Don't have to store full kernel sources (each source tree is ~200MB unpacked)
- Creates the ability to make binary kernel packages for fast installs (think GRP kernel)
- A separate 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.
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 seamless transition.
not yet ..
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/.