build environment


In my previous post, I have published a little how-to to rebuild the whole image using yocto.
Some readers managed to follow the guide and to build the whole thing but a few others reported issues which seem mostly related to their build host.
Of course, yocto should behave the same (and it strives to do so by rebuilding almost all native requirements) whatever the development environment is. However it is not always the case especially for my XBMC recipe (So blame me for it : I am mostly the culprit here)
As I have not been able to understand all the reported issues, I have just decided to publish this new article to describe how to create a build environment which is known to work.

RFS generation

Of course, I could distribute a whole virtual machine image but I will describe a more lightweight way to generate a root filesystem ready to run yocto.
The plan is simply to use debootstrap to fetch a basic Ubuntu 12.04 (precise pangolin) file system and to chroot in this new environment to install the few additional requirements to be able to build my image.

Install debootstrap

If you don’t already have this utility in your distro, just install it. Most Linux distro (even RPM based distro) package it.
Of course the ubuntu/debian (and derivative) users will issue a command like :

apt-get install debootstrap

OpenSuse users will try

zypper install debootstrap

And I will be flamed by Fedora fans if I do not allude to :

yum install debootstrap

Install and configure precise

OK, let’s start :

USER=$(id -n -u)

# if your native install is 64bits
sudo debootstrap --variant=buildd --arch amd64 precise $CHROOT_PATH
# if your native install is 32bits, you will use instead 
# sudo debootstrap --variant=buildd --arch i386 precise $CHROOT_PATH

# copy a few file from native host to be able to use the same user in chroot
sudo cp /etc/passwd $CHROOT_PATH/etc/
sudo cp /etc/shadow $CHROOT_PATH/etc/
sudo cp /etc/resolv.conf $CHROOT_PATH/etc/
sudo cp /etc/group $CHROOT_PATH/etc/
sudo mkdir $CHROOT_PATH/home/$USER
sudo chown $USER  $CHROOT_PATH/home/$USER

# give access to sys, proc and dev in chroot 
# Not permanent (has to be redone after reboot)
 sudo mount --bind /proc $CHROOT_PATH/proc
 sudo mount --bind /sys  $CHROOT_PATH/sys
 sudo mount --bind /dev  $CHROOT_PATH/dev
 sudo mount --bind /dev/pts  $CHROOT_PATH/dev/pts

Then we have to finalize the installation in the chroot itself by entering into the fresh system :

sudo chroot ./precise/ /bin/bash -i

In the new system, let’s finish the install :

mkdir /run/shm
mount -t tmpfs none /run/shm/

apt-get update
apt-get install wget curl python-m2crypto git diffstat  gawk chrpath texi2html texinfo openjdk-6-jre zip


You should have exited the chroot, now reenter as normal user :

ID_NUM=$(id -u)
GID_NUM=$(id -g)
sudo chroot --userspec=${ID_NUM}:${GID_NUM} ./precise/ /bin/bash -i

In the chroot, you can issue the commands from the other post to launch the build.
I copy them for convenience :

#Install repo
mkdir ~/bin
curl > ~/bin/repo
chmod a+x ~/bin/repo
#Create BSP folder
mkdir xbmc-bsp
cd xbmc-bsp
#Download layers
repo init -u -b dora
repo sync
#Initialize build environement
#Valid MACHINE values are wandboard-quad wandboard-dual and utilite
TEMPLATECONF=`pwd`/sources/meta-stef/conf MACHINE=wandboard-quad source setup-environment build
#Let's build the whole thing
bitbake xbmc-image

And you are done… 😉