Ceci est une ancienne révision du document !
This article describes how to integrate Xenomai debian package build steps in a bash script. It is just an automatisation/scripting work. All commands are derivated from excellent Xenomai tutorials. I really recommend reading this tutorials to understand how Xenomai/Adeos work.
You can find script usage in the first chapter. The second chapter contains a sub-chapter by script function to give a more intrusive description of the script. Enjoy. ;)
Running build_xeno_kernel.sh without any option, will retrieve the last stable Xenomai version, the last stable Adeos patch and the kernel corresponding to this patch. As there is no kernel configuration file specified in options, the kernel configuration menu will be displayed.
./build_xeno_kernel.sh
Adding ”-c <kernel_config_file>” will do the same steps than previous but it will not display kernel configuration menu. If the kernel configuration file provided is for an older kernel version, some questions could be asked due to new options not present in previous kernel :
./build_xeno_kernel.sh -c config-2.6.37.6.txt
You can also force the kernel version with option ”-k <kernel_version>”. The corresponding Adeos patch will then be downloaded :
./build_xeno_kernel.sh -k 2.6.37.6
And you can also mix options like apply a kernel configuration file to a choosen kernel :
./build_xeno_kernel.sh -k 2.6.37.6 -c config-2.6.37.6.txt
You can use the development version of Xenomai, directly cloned from Xenomai git repository, with option ”-d” :
./build_xeno_kernel.sh -d
Here is the usage for less important options :
$ ./build_xeno_kernel.sh -h This script build xenomai packages for debian/ubuntu distros. ./build_xeno_kernel [-a <arch>] [-h] [-c <kernel_config_file>] [-d] [-k <kernel_version>] Options: -a <arch> Wanted architecture -h Display this help message -c <kernel_config_file> Use this kernel configuration file to apply -d Download development version of Xenomai -k <kernel_version> Use this kernel version
Each sub chapter describes important functions from the script. For each function, you will find its source code and new files created.
For new files created, consider we run the script with a valid configuration file for kernel 2.6.37.6. The command line is :
$ ./build_xeno_kernel.sh -k 2.6.37.6 -c config-2.6.37.6
The filesystem tree at the beginning just contains the script itself and the kernel configuration file :
. |-- build_xeno_kernel.sh `-- config-2.6.37.6 0 directories, 2 files
The start point is to get Xenomai. I decided to download the last stable release by default. But if the flag dev_version is set then the script download the development version from git. Choosing the stable version is in TODOs for now.
Two important variables are set here and will be used further :
A the end of this function, xenomai sources are ready to be used.
get_xenomai() { if [ "1" = "${dev_version}" ]; then git clone http://git.xenomai.org/xenomai-head.git xenomai_version="head" else wget -q -nd -c -r -np -nc -A "LATEST-IS-v*.tar.bz2" http://download.gna.org/xenomai/stable/ # Untar xenomai xenomai_file=$(ls LATEST-IS-v*.tar.bz2 | sort | tail -1) xenomai_version=$(echo ${xenomai_file:11} | sed s/.tar.bz2//) tar xjpf LATEST-IS-v${xenomai_version}.tar.bz2 fi xenomai_directory=xenomai-${xenomai_version} }
Resulting filesystem :
. |-- build_xeno_kernel.sh |-- config-2.6.37.6 |-- LATEST-IS-v2.5.6.tar.bz2 `-- xenomai-2.5.6 136 directories, 2074 files
If you do not know what is Adeos for, read this. If you do not see how it deals with Xenomai, read this one.
As the kernel version can be specified on script command line, there are two possibilities :
At the end of this function, Adeos patch is downloaded and kernel version is known through kernel_version variable.
get_adeos_patch() { if [ "" != "${kernel_version}" ]; then wget -nv -nd -c -r -np -nc -A "adeos-ipipe-${kernel_version}-${arch}-*.patch" http://download.gna.org/adeos/patches/v2.6/${arch}/ mv adeos-ipipe-*-${arch}-*.patch ${xenomai_directory}/ksrc/arch/${arch}/patches/ adeos_patch=$(ls -1 xenomai-${xenomai_directory}/ksrc/arch/${arch}/patches/ | grep "adeos-ipipe-${kernel_version}-${arch}-.*\.patch" | sort | tail -1) else wget -nv -nd -c -r -np -nc -A "adeos-ipipe-*-${arch}-*.patch" http://download.gna.org/adeos/patches/v2.6/${arch}/ mv adeos-ipipe-*-${arch}-*.patch ${xenomai_directory}/ksrc/arch/${arch}/patches/ adeos_patch=$(ls -1 ${xenomai_directory}/ksrc/arch/${arch}/patches/ | grep "adeos-ipipe-.*-${arch}-.*\.patch" | sort | tail -1) # Extract kernel version from patch file name if not specified kernel_version=$(echo ${adeos_patch} | cut -d'-' -f3) fi }
Resulting filesystem :
. |-- build_xeno_kernel.sh |-- config-2.6.37.6 |-- LATEST-IS-v2.5.6.tar.bz2 |-- tree.txt `-- xenomai-2.5.6 |-- ksrc | |-- arch | | `-- x86 | | |-- patches | | | |-- adeos-ipipe-2.6.37.6-x86-2.9-01.patch | | | |-- adeos-ipipe-2.6.37.6-x86-2.9-02.patch 136 directories, 2076 files
It is the simpliest function from the script. With the variable kernel_version from the previous function get_adeos_patch, the script downloads the kernel from the official kernel repository.
get_kernel() { kernel_url="http://www.kernel.org/pub/linux/kernel/v2.6/linux-${kernel_version}.tar.bz2" wget -c -nc $kernel_url }
Resulting filesystem :
. |-- build_xeno_kernel.sh |-- config-2.6.37.6 |-- LATEST-IS-v2.5.6.tar.bz2 |-- linux-2.6.37.6.tar.bz2 |-- tree.txt `-- xenomai-2.5.6 |-- ksrc | |-- arch | | `-- x86 | | |-- patches | | | |-- adeos-ipipe-2.6.37.6-x86-2.9-01.patch | | | |-- adeos-ipipe-2.6.37.6-x86-2.9-02.patch 136 directories, 2077 files
This function has 4 steps :
Build is done with debian tools so it will result in a set of debian kernel packages.
build_kernel_package() { # Untar the kernel if [[ -d linux-${kernel_version} ]]; then echo "linux-${kernel_version} directory already exists, delete it." rm -Rf linux-${kernel_version} fi tar -xjpf linux-${kernel_version}.tar.bz2 # Patch the kernel (cd ${xenomai_directory} && scripts/prepare-kernel.sh --linux=../linux-${kernel_version}/ --adeos=ksrc/arch/${arch}/patches/${adeos_patch} --arch=${target}) # Configure kernel if [ "" != "${config_file}" ]; then cp -v ${config_file} linux-${kernel_version}/.config (cd linux-${kernel_version} && make silentoldconfig) else (cd linux-${kernel_version} && make menuconfig) fi # Build (cd linux-${kernel_version} && fakeroot make-kpkg --initrd --uc --us kernel_image kernel_headers) }
Resulting filesystem :
. |-- build_xeno_kernel.sh |-- config-2.6.37.6 |-- LATEST-IS-v2.5.6.tar.bz2 |-- linux-2.6.37.6 |-- linux-2.6.37.6.tar.bz2 |-- linux-headers-2.6.37.6_2.6.37.6-10.00.Custom_i386.deb |-- linux-image-2.6.37.6_2.6.37.6-10.00.Custom_i386.deb |-- tree.txt `-- xenomai-2.5.6 |-- ksrc | |-- arch | | `-- x86 | | |-- patches | | | |-- adeos-ipipe-2.6.37.6-x86-2.9-01.patch | | | |-- adeos-ipipe-2.6.37.6-x86-2.9-02.patch 4765 directories, 46682 files
After preparing the package build by specifiying Xenomai versions, we launch the build with debian command debuild. It will build and package Xenomai libraries, kernel patches and more.
build_xenomai_package() { (cd ${xenomai_directory} && debchange -v ${xenomai_version} Release ${xenomai_version}) (cd ${xenomai_directory} && debuild -uc -us) }
Resulting filesystem :
. |-- build_xeno_kernel.sh |-- config-2.6.37.6 |-- LATEST-IS-v2.5.6.tar.bz2 |-- libxenomai1_2.5.6_i386.deb |-- libxenomai-dev_2.5.6_i386.deb |-- linux-2.6.37.6 |-- linux-2.6.37.6.tar.bz2 |-- linux-headers-2.6.37.6_2.6.37.6-10.00.Custom_i386.deb |-- linux-image-2.6.37.6_2.6.37.6-10.00.Custom_i386.deb |-- linux-patch-xenomai_2.5.6_all.deb |-- tree.txt `-- xenomai-2.5.6 |-- ksrc | |-- arch | | `-- x86 | | |-- patches | | | |-- adeos-ipipe-2.6.37.6-x86-2.9-01.patch | | | |-- adeos-ipipe-2.6.37.6-x86-2.9-02.patch |-- xenomai_2.5.6.dsc |-- xenomai_2.5.6_i386.build |-- xenomai_2.5.6_i386.changes |-- xenomai_2.5.6.tar.gz |-- xenomai-doc_2.5.6_all.deb `-- xenomai-runtime_2.5.6_i386.deb 5035 directories, 50457 files