If you're building a system on a Linux platform, you can customize the Linux kernel as you need. This section assumes you have sufficient experience with Linux kernels to know how to use this information when packaging. If you are new to modifying a Linux kernel, consult other Linux resources to learn anything else you need to know.
First, start by shadowing the kernel:source from your platform. See Copying and Customizing Existing Conary Packages at docs.rpath.com/conary for more information about creating and maintaining shadows.
If you're using a platform other that rPath Linux, the kernel package is built from another package and not from the original Linux kernel source. If you want to modify the kernels from these other platforms you can do one of the following:
Modify the shadowed recipe to tweak and repackage the kernel RPMs or debs from the platform.
If you've already built RPMs or debs with your custom kernel, just replace the RPMs or debs in the kernel package's manifest file to point to your new packages.
If you want to use the package to build a custom kernel from the Linux kernel source, replace all the kernel recipe code to use the kernelpackage superclass from Conary. Use the rPath Linux kernel package recipe as a guide to using this superclass. A possible template would be as follows; be sure to replace the kernel version as appropriate:
loadSuperClass('kernelpackage=conary.rpath.com@rpl:devel')
class Kernel(KernelPackageRecipe):
name = 'kernel'
version = '2.6.15.3'
def unpack(r):
# Add all your patches here.
If you're using rPath Linux as your platform, your package is already built from kernel source code. You can modify the kernel.recipe in a couple of ways:
If kernel:recipe does not have an unpack() definition containing the customizations, create the unpack() definition for the recipe.
If kernel:recipe has an existing unpack() definition, modify it to add your customizations.
The following example shows how a custom patch should appear when added to unpack():
loadSuperClass('kernelpackage=conary.rpath.com@rpl:devel')
class Kernel(KernelPackageRecipe):
name = 'kernel'
version = '2.6.15.3'
def unpack(r):
r.addPatch('my-custom-feature.patch')
No matter what platform you're using, if you choose to package your custom kernel from the Linux kernel source, you need to be aware of the kernel flavor specifications and architectures you're building for. For more information about reading flavors, see Conary Versions and Flavors at docs.rpath.com/conary. To see what favor specifications are relevant to your kernel build, look at the flags throughout the (superclass) recipe code in kernelpackage:source=conary.rpath.com@rpl:devel. At the time of this writing, the following flags/flavor specifications were used in the superclass to affect the kernel build:
x86 and x86_64 -- these are the same architecture flavors you would use in building any other package or group
smp -- use kernel.smp or ~kernel.smp enable SMP support; use !kernel.smp or ~!kernel.smp to disable SMP support
pae -- use kernel.pae or ~kernel.pae enable PAE support; use !kernel.pae or ~!kernel.pae to disable PAE support
numa -- use kernel.numa or ~kernel.numa enable NUMA support; use !kernel.numa or ~!kernel.numa to disable NUMA support
Configure your build environment as appropriate so that when you run your build command, you can build your kernel for the flavors you need. If you're using rBuild for appliances in rBuilder, this means adjusting your product definition XML code to add relevant flavors, or using rMake or cvc instead while accounting for the needs of your product definition. If you're using rMake or cvc, this means making sure you use the appropriate flavor specifications in your .rmakerc or .conaryrc files and/or in the arguments of your rmake or cvc commands. See documentation for your selected build tools for more information about building with certain flavor specifications.
You can add drastically different options with extensive modifications to the config.base file in the shadow. However, for a more convenient solution, or to build a kernel specific to a single hardware platform, you could construct a new .config file, perhaps based on Conary.
To construct a custom .config file and add it to your kernel package, use the following process:
Shadow kernel:source from your platform, check out the package, and build it with cvc cook using the --prep option to simply prepare a build directory without completing the package build.
Change to the builddir directory, run make menuconfig (or xconfig or gconfig as appropriate), and configure the kernel.
Copy the custom .config file to the kernel package directory alongside the recipe, and rename it to dotconfig.
Replace all the methods ("def" sections) in your kernel's recipe with the unpack() and configure() definitions shown here:
def unpack(r):
# Add any patches here as needed.
#r.addPatch('')
# This is for your special build. Specify dotconfig to
# be your config, made with menuconfig and the arch you're
# building for (either x86.i686 or x86_64.x86_64).
r.addSource('dotconfig')
r.macros.cfgver = 'x86.i686'
def configure(r):
r.Copy('dotconfig', '.config')
Build and test your kernel package, making tweaks where necessary.
Remember to rebuild any groups that contain this kernel package after you build the kernel. Make sure the group pulls in your custom kernel from your label rather than kernel from your platform's label.