NovellKernelModulePackages
From KernelDrivers
←Older revision | Newer revision→
Contents |
SUSE Kernel Module Packages
Novell provide support for Kernel Module Packages in their CODE10 releases (SLES10 and OpenSuSE 10.1), and in a precursory version in SLES9. The following information is based upon material at http://en.opensuse.org/Kernel_Module_Packages and discussion with Andreas Gruenbacher (agruen@suse.de) and other SuSE community members about their KMP work. Empirical testing has also taken place.
Note: To test this out, you'll need to have an up-to-date installation of OpenSuSE (or SLES10). It is recommended that you use the "Factory" development Distribution - http://en.opensuse.org/Factory.
Overview
Novell KMPs rely upon two key pieces of information:
- Symbolic reference data for the current kernel in /boot/sym*
- RPM "provides" and "requires" dependencies referencing these.
The internal build process is somewhat complex, but the end goal is to provide RPM packages with dependencies against a set of symbol exports that are provided dependencies of a kernel package. Thus, it's possible for automated resolution to occur[0].
For example, the "ivtv" kernel (ivtv-kmp-default) module might include the following RPM dependencies:
- Provides:
- ivtv-kmp = 0.7.0_2.6.16.12_3
- ksym(ivtv_api) = 3370d1f8
- ksym(ivtv_cards) = 86757ef5
- ksym(ivtv_cards_active) = 70196ffb
- ksym(ivtv_clear_irq_mask) = 65dce529
- ksym(ivtv_debug) = 14f67530
- ksym(ivtv_reset_ir_gpio) = c20c986f
- ksym(ivtv_set_irq_mask) = b26f3794
- ksym(ivtv_vapi) = 8737f753
- ivtv-kmp-default = 0.7.0_2.6.16.12_3-12
- Requires:
- rpmlib(VersionedDependencies) <= 3.0.3-1
- kernel-default
- /bin/sh
- /bin/sh
- /bin/sh
- rpmlib(PayloadFilesHavePrefix) <= 4.0-1
- rpmlib(CompressedFileNames) <= 3.0.4-1
- kernel(drivers) = 0fe6383185b77d3c
- kernel(drivers_pci) = f982906dcfcc9ba3
- kernel(mm) = 3d6b445a058e7d3f
- kernel(drivers_media_video) = c5f862783e632d21
- kernel(kernel) = 3e632392437173c4
- kernel(vmlinux) = 73b8cba1c47dd165
- kernel(kernel_irq) = dd1d73732d05a591
- kernel(arch_i386_kernel) = 74a0933fa6e553b6
- kernel(arch_i386_kernel_cpu) = 7e943412451173b6
- kernel(arch_i386_kernel_cpu_mtrr) = badf815515a4fe72
- kernel(drivers_base) = 0d991d69743e5e95
- kernel(arch_i386_mm) = d424f52befea78dc
- kernel(drivers_i2c) = 60530549d9f89642
- kernel(drivers_video) = d22ead68a52a9411
- rpmlib(PayloadIsBzip2) <= 3.0.5-1
The kernel() and ksym() dependencies encapsulate the versions of kernel symbols. Since RPM doesn't well handle 8000+ dependencies, these are grouped into a version per directory (for example) of the kernel source - e.g. arch_i386_kernel for arch/i386/kernel. KMPs are installed by default into the usual /lib/modules location, except that they are located under "updates" - "weak-updates" are created for kernels that meet kABI requirements but aren't of the same verison.
Kernels and Kernel Module Packages employ the weak-modules script (from module-init-tools) in their %post and %postun scripts to create symlinks to compatible modules from other kernel versions: When installing a Kernel Module Package, the script creates weak-updates symlinks in all weak-updates directories of compatible kernels (unless such symlinks from more recent kernel versions exist already). During kernel upgrades, the script goes through all update modules in /lib/modules/*/updates of all other kernels, and symlinks compatible modules into the new kernel's /lib/modules/*/weak-updates directory. (If multiple compatible modules are available, those with the highest kernel release number win.)
Novell KMP Example
Novell provide an example KMP in /usr/share/doc/packages/kernel-source/novell-kmp, along with a reference to the build instructions for building a SuSE kernel - see Documentation below.
The spec file begins in the normal fashion:
Name: novell-example
BuildRequires: kernel-source kernel-syms
License: GPL
Group: System/Kernel
Summary: Example Kernel Module Package
Version: 1.1
Release: 0
Source0: %name-%version.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Then comes the magic macro:
%suse_kernel_module_package kdump um
Then a description:
%description This is an example Kernel Module Package.
Then we create a sub-package "template" for different kernel flavors which defines the summary, group, and description of the various sub-packages for the different kernel flavors:
%package KMP Summary: Example Kernel Module Group: System/Kernel %description KMP This is one of the sub-packages for a specific kernel. All the sub-packages will share the same summary, group, and description.
The prep and build process is fairly standard for 2.6 kernel modules:
%prep
%setup
set -- *
mkdir source
mv "$@" source/
mkdir obj
%build
export EXTRA_CFLAGS='-DVERSION=\"%version\"'
for flavor in %flavors_to_build; do
rm -rf obj/$flavor
cp -r source obj/$flavor
make -C /usr/src/linux-obj/%_target_cpu/$flavor modules \
M=$PWD/obj/$flavor
done
%install
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
export INSTALL_MOD_DIR=updates
for flavor in %flavors_to_build; do
make -C /usr/src/linux-obj/%_target_cpu/$flavor modules_install \
M=$PWD/obj/$flavor
done
So, the real magic happens in the %suse_kernel_module_package macro. This RPM macro automatically determines the set of RPM dependencies that will be produced for this module.
Notes
[0] Matching against kernel flavor is something that needs to be looked at in more detail - right now, it's one package per flavor.
Documentation
- Building 2.6 Linux kernels on SuSE: http://www.suse.de/~agruen/kernel-doc/
- Building 2.6 Linux kernel driver disks ("Update Media"): ftp://ftp.suse.com/pub/people/hvogel/Update-Media-HOWTO/
- Kernel Module Packages Manual: http://www.suse.de/~agruen/KMPM/

