Ubuntu Kernel CI

The ubuntu-kernel-ci git repository contains scripts and configuration files for building and testing packaged kernels both standalone and on ci.linaro.org.

The package_kernel script is a bash script that does most of the work of packaging and test building of kernels. The configuration files are included in the repository instead of inline in CI jobs to have the advantages of version control. Also having the configs in one place allows the CI job description html headers to be auto generated so that info does not have to be maintained manually.

Basic Standalone Usage

Create a source package for an already supported platform

e.g. Build a source package for Versatile Express using a configuration file already part of the repository.

   1 mkdir builddir
   2 cd builddir
   4 # Set up the reference git tree
   5 git clone git://git.linaro.org/kernel/linux-linaro-tracking.git reference-git
   6 export nearby_git=$PWD/reference-git/.git
   8 # Checkout the ubuntu-kernel-ci repository
   9 git clone git://git.linaro.org/people/jcrigby/ubuntu-kernel-ci.git ubuntu-kernel-ci
  11 # Run the build
  12 ./ubuntu-kernel-ci/scripts/package_kernel \
  13   --cfg vexpress-3.7.cfg \
  14   nearby_git=$nearby_git"

When running standalone:

  • package_kernel creates a source package by merging a template ubuntu debian source tree into a kernel tree and modifying the template packaging files to match the platform for which the kernel is targeted.
  • Next, a kernel config is generated from config fragments in the configuration file.
  • Finally, dpkg-buildpackage is called to create the source package.

To also build a binary .deb files from the resulting source package one must add do_test_build_source_pkg="true" to the command line.

   1 ...
   2 # same as above
   3 ...
   5 ./ubuntu-kernel-ci/scripts/package_kernel \
   6   --cfg vexpress-3.7.cfg \
   7   nearby_git=$nearby_git" \
   8   do_test_build_source_pkg="true"

Sample package-kernel configuration file

Here is a sample configuration file for Versatile Express, coming from the ubuntu-kernel-ci repository. It consists entirely of exporting variables used by package kernel. Comments have been added to document the variables.

   1 #!/bin/bash
   2 # Kernel source tree git repo and branch
   3 export kernel_repo=git://git.linaro.org/kernel/linux-linaro-tracking.git
   4 export kernel_branch=linux-linaro
   5 # Board config repo, branch and fragments
   6 export board_config_repo=$kernel_repo
   7 export board_config_branch=$kernel_branch
   8 export board_config_frags="linaro/configs/big-LITTLE-MP.conf \
   9         linaro/configs/vexpress.conf"
  10 # Target distro (would series be a better name?)
  11 export distribution=quantal
  12 # Suffix used in the debian.linaro/configs/... for board config
  13 export linaroconfigsboardflavour=vexpress
  14 # Packaging template repo and branch
  15 export linaro_ubuntu_packaging_repo=git://git.linaro.org/ubuntu/linux-linaro-raring.git
  16 export linaro_ubuntu_packaging_branch=linaro-ubuntu-packaging-3.7
  17 # Local reverence git repo for use with git-clone --reference
  18 export nearby_git=~/reference-git
  19 # Names to use to instantiate debian/control and other files
  20 export SAMPLEBOARDS=vexpress
  22 export SOCFLAVOUR=vexpress
  23 export SOCVENDOR=ARM
  24 # Ubuntu config repo, branch and fragments 
  25 export ubuntu_and_base_config_repo=$kernel_repo
  26 export ubuntu_and_base_config_branch=$kernel_branch
  27 export ubuntu_config_frag=linaro/configs/ubuntu-minimal.conf
  28 # Don't use kernel version from packaging template use info
  29 # in kernel Makefile instead
  30 export auto_kernel_version="true"

The config file passed via the -cfg argument is "sourced" at the point the -cfg is parsed in the command line so it needs to be in the current PATH or a complete pathname should be provided. The path to the configs directory of the ubuntu-kernel-ci repository is added to PATH so configs in the repository do not need a full path.

Overriding Settings

In addition of passing settings via a config file or in exported environment variables, one may also add them to the command line. Any variable can be set this way.

   1 ...
   3 ./ubuntu-kernel-ci/scripts/package_kernel \
   4   --cfg vexpress-3.7.cfg \
   5   nearby_git=$nearby_git" \
   6   do_test_build_source_pkg="true" \
   7   kernel_repo="git://path_to_a_different_kernel_repo.git"

The do_blah_blah Variables

When debugging package-kernel, it is sometimes useful to be able to designate which of the stages are to be run. Also the appropriate default stages are different when running standalone vs when running on ci.linaro.org. This is where the do_blah variables come in. Here is an excerpt from package-kernel that shows which do_* variables are set by default.

   1 # default actions are different if running under
   2 # jenkins vs standalone
   4 running_standalone="true"
   5 unset running_in_jenkins
   7 test "$JENKINS_URL" && {
   8         running_in_jenkins="true"
   9         unset running_standalone
  10         do_merge="true"
  11         do_create_source_pkg="true"
  12         do_publish_release_tag="true"
  13         do_test_build_source_pkg="true"
  14         do_publish_source_pkg="true"
  15         do_create_artifact_dir="true"
  16         do_create_hwpack="true"
  17 }
  19 test "$running_standalone" == "true" && {
  20         do_merge="true"
  21         do_create_source_pkg="true"
  22         BUILD_NUMBER=$$
  23 }

Here are brief descriptions of what each stage does


Clone the kernel repository add packaging including configs.


Create a source package using dpkg-buildpackage from the output of the merge.


Push merged packaged kernel tree to repository on github. This is so we have source archive of every published kernel.


Do a test cross-build of the source package created above. Since this is a cross-build, certain targets are disabled that do not cross-build safely.


Publish source package to a host. The default host is ppa:linaro-maintainers/staging-overlay which can be overridden with HOST_PPA=whatever on command line or in a target config.


Once used for book keeping to keep track of the relationship between file on snapshots.linaro.org and ci.linaro.org and lava. Now defunct (I think -- jcrigby).


Grab an existing hardware pack from snapshots.linaro.org and replace the kernel with the output of do_test_build_source_pkg. The resulting hardware pack is left on the job workspace to be passed to a job that does lava submission.

Usage on ci.linaro.org (aka Jenkins)

Creating a new CI job

  • First create a new config in the configs directory of the ubuntu-kernel-ci repository. Just copy an existing one and go from there.
  • Next run package-kernel locally to test out the new config.

After package-kernel works locally you are ready to create a new CI job. Again, this usually just means copying an existing job:

  • Go to ci.linaro.org, click on the ubuntu-packaged-kernel-jobs tab.
  • Click on new job and type the new job name and choose an existing job to copy.
  • Then just save it.

It is that simple.

Just One Rule

It is not magic so you do need to follow a simple convention. All settings come from the configuration file in the git repository and the configuration file name is derived from the job name. So you must name the new job appropriately.

Here is the code from a CI job that maps job name to configuration file name:

   1 # jenkins has set up reference-git here we checkout ci scripts
   2 rm -rf ubuntu-kernel-ci; git clone git://git.linaro.org/people/jcrigby/ubuntu-kernel-ci.git ubuntu-kernel-ci
   4 # use pwd which has jobname in it to derive which kernel is being built
   5 kcfg=$(pwd | sed s/.*linux-linaro-//).cfg
   6 ./ubuntu-kernel-ci/scripts/package_kernel --cfg $kcfg nearby_git=$PWD/reference-git/.git -k B86C70FE

(It will become obsolete when we switch to multi-configuration job type -- fabo)

HTML Job Description

If you just copy an existing job you won't need to do anything to the description. The existing job description uses an iframe to include an html file from elsewhere: https://ci.linaro.org/jenkins/job/ubuntu-packaged-kernel-helper/lastSuccessfulBuild/artifact/jobinfo.html

The jobinfo.html file is generated by the ubuntu-packaged-kernel-helper job which uses all the config files in the ubuntu-kernel-ci repository to create header info for all possible jobs.

The jobinfo.html file contains javascript that uses the parent window name to determine what the jobname is and thus what info to print out.

Isn't this iframe stuff a bit too clever?

Maybe but it allows for all configuration info to be in one place and under version control. For the non admin user there is not an easy way to look at CI job script history so when you change something you have no way of going back or remembering what you changed later. With all configuration elsewhere, you have complete history and all jobs are identical so creating a new job is extremely simple.

What is that -k xxxxxxx stuff?

When running standalone dpkg-buildpackage is called with -us -uc to turn off signing. On ci.linaro.org, we will use dput to push the package to an archive so the package needs to be signed. Use -k NNNNNNN to have package-kernel call dpkg-buildpackage with -kNNNNNN instead of -us -uc.


Platform/DevPlatform/KernelCi (last modified 2013-08-29 17:33:49)