How to setup a cross-builder (to build linaro-nano)
Overview
- Configure your machine to use updated tools from PPA
- Create build chroot containing tools
- Configure the build
- Run the build
- Create the image
Setting up for building
There are two ways you can do this.
1) Make a cross-build chroot to do your work in.
2) You can do everything in your main machine if it's already natty. (In which case see the section below 'Using a local setup' instead of 'Creating build Chroot'.) However I don't recommend this if you ever build anything else there, and it's not what I've tested. The main reason is that the rootfs used for building will fill up with a lot of build-dependencies.
Creating Build Chroot
You need multistrap 2.6.3ubuntu6 for a smooth experience (you'll have to update the config files otherwise)
So add the tools PPA (with add-apt-repository):
sudo apt-add-repository ppa:linaro-foundations/cross-build-tools
Or manually:
deb http://ppa.launchpad.net/linaro-foundations/cross-build-tools/ubuntu natty main
preferably to /etc/apt/source.list.d/crosstoolsPPA.list
Then do
sudo apt-get install multistrap
to get 2.6.3ubuntu6
Now you can do
sudo multistrap -f /usr/share/multistrap/xbuilder.conf -d chroots/natty-build
Which should make a new local-architecture chroot, install the cross-tools into it, and set up apt sources.
You can do this by hand using debootstrap and then installing the sources, packages and config you need, but this is a lot easier.
In order to use the chroot you have made conveniently it is best to use schroot, which manages your chroot and makes your home dir and system mounts/services available.
apt-get install schroot
if you don't have it already then add a config like this to your /etc/schroot/schroot.conf
[natty-build] description=Ubuntu Natty (11.04) directory=/home/USER/chroots/natty-build type=directory users=USER root-groups=USER
Changing USER to be your username.
Change into the chroot using
schroot -c natty-build
Configure the build
All you need to do is make a file which is a list of the packages you want building. Ideally it's a list of source packages, but a list of binary packages will work too (but if you list several binaries from the same source package then that package will get built more than once). The format is one package per line and the file is called buildlist. A sample buildlist for linaro-nano is in the xbuilder package, so:
cp /usr/share/xbuilder/examples/buildlist-nano-pruned buildlist
The pruning there is because it lists binary packages, but has had the duplicates weeded out to avoid unnecessary builds.
To build a single package just make buildlist one line with the package name on.
To avoid the build stalling at password prompts generated by sudo, increase the timeout to several hours in the sudo config:
In /etc/sudoers Change the line
Defaults env_reset
to
Defaults env_reset, timestamp_timeout=600
600 is 10 hours, which is enough for almost all builds to complete.
Run the Build
Update apt cache:
sudo apt-get update
And simply set the cross-builder running:
xbuilder-simple
It runs through the packages in buildlist one by one, downloading sources to build/xdeb and putting build logs in logs/xdeb, running xdeb in only-explicit mode (i.e building against the archive).
xbuilder can be set to use pdebuild-cross instead of xdeb (by editing /usr/bin/xbuilder-simple) if preferred, but that's not been tested on this version.
Not all packages in the PPA will successfully cross-build right now. 81 out of 117 binaries should build successfully (2011-09-28). See LinaroNanoStatus or https://wiki.linaro.org/Platform/DevPlatform/CrossCompile/CurrentPackageCrossBuildStatus?action=AttachFile&do=view&target=packagecomparison.gnumeric for full current nano/ALIP status
Create the Image
Once the build is complete you can generate a bootable image by running multistrap with the linaro-nano config. This can equally be done inside or outside the natty-build chroot, but you already have the package installed outside, so easiest to do it there, so exit the chroot if you haven't already.
cp /usr/share/multistrap/linaro-nano.conf linao-nano.conf
You'll need to change the config to point at your local .deb collection so the [nano] section should look something like this
source=file:///home/USER/PATH-TO-BUILDLIST-DIR/build/xdeb/ ./ packages=apt apt-utils base-files base-passwd bsdutils console-setup coreutils dash debianutils debconf diffutils dpkg e2fsprogs findutils gnupg ifupdown initramfs-tools initscripts ipr$ keyring= omitsource=true
touch /home/USER/PATH-TO-BUILDLIST-DIR/build/xdeb/Sources multistrap --no-auth -f linaro-nano.conf
Currently this will fail because not all packages are available.
Adding an http source to fill in the gaps should allow a test image to be generated (not yet tested).
======================
Manual Details
If you have trouble with any of the above stages then you'll need more details about how it works to fix things. This section provides such details.
Installing the PPA key
If the linaro-foundation-keyring package is not doing the trick for you then:
Run this command to install the key sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 099F4315
should enabled authenticated downloads from the PPA.
Creating a Crossbuilder Chroot
You need a basic natty image, as provided by debootstrap/cdebootstrap/multistrap etc with these extra packages:
From the Cross-tools-PPA:xdeb dpkg-cross xbuilder
From the normal repo: g++-arm-linux-gnueabi libc-dev-armel-cross linux-libc-dev-armel-cross dpkg-dev build-essential fakeroot binutils-multiarch ubuntu-keyring gnupg realpath
Configuring the chroot for building
You need somewhere to get armel packages from for crossing: deb [arch=armel] http://ports.ubuntu.com/ natty main universe
Platform/DevPlatform/CrossCompile/CrossBuildNano (last modified 2011-10-11 14:10:02)