This method is good for one-off kernel packages. It takes only a few minutes to setup the compile, including downloads.
This recipe was developed on Ubuntu Precise, but may work for other versions of Debian-like distros. It is known to work for x86 architecture. Other architectures will require small changes to work. Please fix these instructions if you succeed in building for other architectures!
The most difficult part of building kernel packages is finding a working kernel config. This recipe uses stock kernel configs from the Ubuntu kernel package, and adds a minimal and well-documented set of changes to configure the Xenomai system. The intent is to leverage the expertise of the Ubuntu and Debian folks, whose kernels run on an enormous variety of hardware, while keeping the Xenomai-specific changes separate and documented to simplify updates. The kernel configs can be found in the author's github repo: https://github.com/zultron/kernel-tools
The following may not be enough; if something is missing, git-buildpackage will print a list.
# Package build prereqs: sudo apt-get install devscripts debhelper dh-kpatches findutils build-essential
# Kernel build prereqs: sudo apt-get install kernel-package libncurses-dev fakeroot zlib1g-dev sudo apt-get install crash kexec-tools makedumpfile kernel-wedge
Adjust the following values according to your needs.
These defaults specify this kernel tarball as a starting point: http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.5.7.tar.bz2
The ipipe patch will be taken from here, installed from the xenomai package: /usr/src/kernel-patches/diffs/xenomai/ipipe-core-3.5.7-x86-3.patch.gz
# Ubuntu kernel package version to use; must match the ipipe-core # patch's kernel version; see /usr/src/kernel-patches/diffs/xenomai KVERSION=3.5.7 IPIPE_VERSION=3.5.7-x86-3
# Kernel package release; this should be bumped with each new package release, # and reset with each new upstream kernel version KERNEL_PKG_RELEASE=0
# The Ubuntu release for the kernel package UBUNTU_RELEASE=precise
# The CPU arch; either amd64 or i386 DEB_ARCH=i386
# Version of installed xenomai package; try # dpkg -l linux-patch-xenomai XENO_VERSION=220.127.116.11
The rest should be cut and paste, at least until bit rot sets in.
# The arch that Debian calls amd64, everyone else calls x86_64 test $DEB_ARCH = amd64 && CPU_ARCH=x86_64 || CPU_ARCH=i686
# Download and unpack kernel tarball wget http://www.kernel.org/pub/linux/kernel/v3.x/linux-$KVERSION.tar.bz2 tar -jxf linux-$KVERSION.tar.bz2 && cd linux-$KVERSION
# Apply the xenomai ipipe patch gzip -cd \ /usr/src/kernel-patches/diffs/xenomai/ipipe-core-$IPIPE_VERSION.patch.gz | \ patch -p1
# Copy the kernel config wget https://raw.github.com/zultron/kernel-tools/master/configs/$UBUNTU_RELEASE-$KVERSION/config.$DEB_ARCH wget https://raw.github.com/zultron/kernel-tools/master/configs/config-$KVERSION-xenomai-$CPU_ARCH cat config.$DEB_ARCH config-$KVERSION-xenomai-$CPU_ARCH > .config
# Clean up .config. This may issue some warnings, but if it prompts for any unset variables, # bit rot has begun to set in. make ARCH=$CPU_ARCH oldconfig
# Build the kernel packages with the kernel_image and # kernel_headers build targets make-kpkg clean CONCURRENCY_LEVEL=`getconf _NPROCESSORS_ONLN` fakeroot \ make-kpkg --initrd --append-to-version=-xenomai-$XENO_VERSION \ --revision $KERNEL_PKG_RELEASE kernel_image kernel_headers
Other targets that may be used with make-kpkg:
Other arguments for make-kpkg:
If the build was successful, the packages will be in the parent directory.
cd .. sudo dpkg -i *.deb