Outils pour utilisateurs

Outils du site


robotics:computing:script_to_build_xenomai_ubuntu_packages_kernel_libraries

Différences

Cette page vous affiche les différences entre la révision choisie et la version actuelle de la page.

Lien vers cette vue comparative

robotics:computing:script_to_build_xenomai_ubuntu_packages_kernel_libraries [2011/08/25 23:38]
gdo [Build Xenomai package]
— (Version actuelle)
Ligne 1: Ligne 1:
-====== Introduction ====== 
- 
-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 [[http://​www.xenomai.org/​index.php/​Howtos|Xenomai tutorials]]. I really recommend reading this tutorials to understand how Xenomai/​Adeos work. 
-\\ \\ 
-The first chapter contains a sub-chapter by script function. You can find the full script and its usage in the last chapter. Enjoy. ;) 
- 
-== Links == 
-  * [[http://​www.xenomai.org/​index.php/​Building_Debian_packages|Building Debian packages]] 
- 
-== Hardware used : == 
-  * Roboard RB-100 : [[http://​www.roboard.com/​RB-100.htm]] 
-  * USB Key or SD card with Ubuntu 10.04 for roboard 
-  * A desktop PC running Ubuntu >=10.04 
-  * An internet connection. 
- 
-== Downloads : == 
-  * {{:​robotics:​computing:​xenomai:​build_xeno_kernel.txt|Full script}} 
-  * {{:​robotics:​computing:​xenomai:​config-roboard-2.6.37.6.txt|Kernel 2.6.37.6 configuration file}} 
- 
-====== Script functions ====== 
- 
-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 : 
-<code bash>$ ./​build_xeno_kernel.sh -c config-2.6.37.6</​code>​ 
-The filesystem tree at the beginning just contains the script itself and the kernel configuration file : 
-<code bash>. 
-|-- build_xeno_kernel.sh 
-`-- config-2.6.37.6 
- 
-0 directories,​ 2 files 
-</​code>​ 
- 
-===== Get Xenomai ===== 
- 
-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 : 
-  * **xenomai_version** which is just the Xenomai version as its name implies. It will be used for debian package versioning. 
-  * **xenomai_directory** which contains the xenomai sources path. 
- 
-A the end of this function, xenomai sources are ready to be used. 
- 
-<code bash>​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} 
-}</​code>​ 
- 
-Resulting filesystem : 
-<code bash>. 
-|-- build_xeno_kernel.sh 
-|-- config-2.6.37.6 
-|-- LATEST-IS-v2.5.6.tar.bz2 
-`-- xenomai-2.5.6 
- 
-136 directories,​ 2074 files 
-</​code>​ 
- 
-===== Get Adeos patch ===== 
- 
-If you do not know what is Adeos for, read {{http://​home.gna.org/​adeos/​|this}}. If you do not see how it deals with Xenomai, read {{http://​www.xenomai.org/​documentation/​branches/​v2.3.x/​pdf/​Life-with-Adeos-rev-B.pdf|this one}}. 
- 
-As the kernel version can be specified on script command line, there are two possibilities : 
-  * The kernel version is specified in **kernel_version** variable. Then the script is looking for the last stable adeos patch that suits to this kernel and download it. If there is several patch available for a same kernel, it downloads the most recent. 
-  * The kernel version is not specified then **kernel_version** variable is empty. The script downloads the last available Adeos patch. From the patch name, it determines the needed kernel and downloads it. The kernel version is set in **kernel_version** variable. 
- 
-At the end of this function, Adeos patch is downloaded and kernel version is known through **kernel_version** variable. 
- 
-<code bash>​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 
-}</​code>​ 
- 
-Resulting filesystem : 
-<code bash>. 
-|-- 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 
-</​code>​ 
- 
-===== Get Linux kernel ===== 
- 
-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. 
- 
-<code bash>​get_kernel() 
-{ 
-        kernel_url="​http://​www.kernel.org/​pub/​linux/​kernel/​v2.6/​linux-${kernel_version}.tar.bz2"​ 
-        wget -c -nc $kernel_url 
-}</​code>​ 
- 
-Resulting filesystem : 
-<code bash>. 
-|-- 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 
-</​code>​ 
- 
-===== Build the Kernel ===== 
- 
-This function has 4 steps : 
-  * Untar the kernel archive the script has downloaded in **get_kernel** function. 
-  * Patch the kernel with the Xenomai script using the Adeos patch we download with **get_adeos_patch** function. 
-  * Configure the kernel. Here three cases are possible : 
-    * A kernel config file is specified and suits to the downloaded kernel version. The kernel config file is copied into the linux kernel source directory and the kernel is ready to be built. 
-    * A kernel config file is specified but its version is older than the downloaded kernel version. Some questions could be asked since it is an old configuration and some parameters could be missing. 
-    * No configuration file is specified then it just launch the kernel configuration menu to create one. 
-  * Once the kernel is configured, the build is launched. 
- 
-Build is done with debian tools so it will result in a set of debian kernel packages. 
- 
-<code bash>​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) 
-}</​code>​ 
- 
-Resulting filesystem : 
-<code bash>. 
-|-- 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 
-</​code>​ 
- 
-===== Build Xenomai package ===== 
- 
-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. 
- 
-<code bash>​build_xenomai_package() 
-{ 
-        (cd ${xenomai_directory} && debchange -v ${xenomai_version} Release ${xenomai_version}) 
-        (cd ${xenomai_directory} && debuild -uc -us) 
-}</​code>​ 
- 
-Resulting filesystem : 
-<code bash>. 
-|-- 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 
-</​code>​ 
  
robotics/computing/script_to_build_xenomai_ubuntu_packages_kernel_libraries.1314308305.txt.gz · Dernière modification: 2012/09/20 10:52 (modification externe)