User Tools

  • (equal to forum credentials)

Site Tools


buildingpack

Building XBian Packages

XBian actually only contains a small set of applications and tools presented to the user under the form of deb packages, installable on top of a Debian-based GNU/Linux distribution:

  • Raspbian (stable version, named Wheezy), the leading Debian-based GNU/Linux distribution optimized for the Raspberry Pi;
  • Debian (testing version, named Jessie) for SolidRun's CuBox-i.

All of the CuBox-i devices are supported: Solo, Dual Lite, Dual, Quad and even the HummingBoard.

Until decided otherwise, as you may have noticed the 2 platforms use different Debian versions.

Fortunately both use ARM architectures, ARMv6 for the Raspberry Pi and ARMv7 (i.MX6) for CuBox-i, are binary-compatible, so there's no need to compile each binary twice. It's only needed in case the target systems use different libraries so the binary would be linked wrong.

Repositories

All of XBian's packages have their own repository. Each repository contains all the necessary build configuration, patches, and scripts to allow easy building and deployment. All packages follow the same structure and all can be processed automatically by XBian's build scripts located at xbianonpi/xbian.

I wanna be a developer or create my own package

If you want to participate in the development of XBian (we'd be more than happy!) or just want to build a package for your own private use, that's easy:

  • you need a build system: any GNU/Linux is fine. CPU architecture is not relevant: x86_64, Sparc or even ARM).\\Only requirements are a connection to the Internet, Git, QEMU and build tools for the ARM architecture
  • create a build environment (chroot) for Raspbian Wheezy and/or Debian Jessie (see above)
  • clone the appropriate repository from GitHub
  • in the directory where the repository was cloned, execute the build.package script, e.g. sh build.package

The behaviour of the scripts can be set in many ways through config files which are part of build package (nit the scripts), but by default they come preconfigured for following actions: a) original sources are cloned locally b) XBian patches and changes are applied c) sources are preconfigured & configured with XBian's settings d) sources are build e) binaries are installed into package template folder f) package is build and compressed into single .deb file

We can prepare Wheezy & Jessie environments with help of debootstrap tool available for Debian and Ubuntu systems.

apt-get install debootstrap qemu-user-static schroot

Wheezy

mkdir -p /home/xbian/build
cd /home/xbian/build
debootstrap --arch armhf --foreign wheezy ./armhfwheezy http://mirrordirector.raspbian.org/raspbian/

After packages are downloaded and command finishes, we have to finalize the install by unpacking and configuring all the packages. this is again handled automatically by debootstrap. just we need it to run in target arch environment via chroot.

cp /usr/bin/qemu-arm-static ./armhfwheezy/usr/bin
chroot ./armhfwheezy debootstrap/debootstrap --second-stage
This will install ~150-200mb of packages. We just need few more packages to install to be able later to compile any of XBian's packages. this we will install from upstream repositories and from XBian repository. To access the upstream repositories (in that first case raspberian/armhf/wheezy) we have to edit the /etc/apt/sources.list in the chroot ./armhfwheezy directory again. In there, we put

chroot armhfwheezy
echo "deb http://mirrordirector.raspbian.org/raspbian/ wheezy main rpi" >> /etc/apt/sources.list
echo "none /proc proc defaults 0 0" >> /etc/fstab
echo "devtmpfs /dev devtmpfs mode=0755,nosuid 0 0" >> /etc/fstab
echo "devpts /dev/pts devpts gid=5,mode=620 0 0" >> /etc/fstab
mount -a

Then we download and install xbian-package-repo (still in the chroot)

wget http://xbian.brantje.com/pool/stable/main/x/xbian-package-repo/xbian-package-repo_1.0.0_armhf.deb
dpkg -i xbian-package-repo_1.0.0_armhf.deb
rm xbian-package-repo_1.0.0_armhf.deb
apt-get update

Now we are ready to install the other development packages needed for development and compilation later.

apt-get install xbian-package-cec xbian-package-libtag xbian-package-shairplay libafpclient-dev xbian-package-firmware autoconf  automake  autopoint  autoconf  automake  autopoint  autotools-dev  cmake curl debhelper default-jre gawk gperf libao-dev libasound2-dev libass-dev libavahi-client-dev libavahi-common-dev libavcodec-dev libavfilter-dev libavformat-dev  libavutil-dev libbluetooth-dev libbluray-dev libboost-dev libboost-thread-dev libbz2-dev  libcap-dev libcdio-dev libgpg-error-dev libcurl4-gnutls-dev libcwiid-dev libdbus-1-dev  libenca-dev libflac-dev libfontconfig-dev libfreetype6-dev libfribidi-dev libiso9660-dev  libjasper-dev libjpeg-dev libltdl-dev liblzo2-dev libmad0-dev liblockdev1-dev libmicrohttpd-dev libmodplug-dev libmpcdec-dev libmpeg2-4-dev libmysqlclient-dev libnfs-dev libogg-dev  libpcre3-dev libplist-dev libpng12-dev libpng-dev libpostproc-dev libpulse-dev librtmp-dev  libsamplerate-dev libafpclient-dev libsmbclient-dev libsqlite3-dev libssh-dev libssl-dev  libswscale-dev libtiff-dev libtinyxml-dev libtool libudev-dev libusb-dev libvorbis-dev  libxinerama-dev libxml2-dev libxmu-dev libxrandr-dev libxslt1-dev libxt-dev libyajl-dev lsb-release nasm python-dev python-imaging python-support swig unzip yasm zip zlib1g-dev libmp3lame-dev libfuse2 doxygen openjdk-7-jre-headless libsdl1.2-dev libsdl-image1.2-dev libltdl7 libavahi-compat-libdnssd1 libao4 locales

Jessie

mmkdir -p /home/xbian/build
cd /home/xbian/build
debootstrap --arch armhf --foreign jessie ./armhfjessie http://ftp.us.debian.org/debian

After packages are downloaded and command finishes, we have to finalise the install by unpacking and configuring all the packages. this is again handled automatically by debootstrap. just we need it to run in target arch environment via chroot.

cp /usr/bin/qemu-arm-static ./armhfjessie
chroot ./armhfjessie debootstrap/debootstrap --second-stage

chroot armhfwheezy
echo "deb http://ftp.us.debian.org/debian wheezy main" >> /etc/apt/sources.list

echo "none /proc proc defaults 0 0" >> /etc/fstab
echo "devtmpfs /dev devtmpfs mode=0755,nosuid 0 0" >> /etc/fstab
echo "devpts /dev/pts devpts gid=5,mode=620 0 0" >> /etc/fstab
mount -a

wget http://xbian.brantje.com/pool/stable/main/x/xbian-package-repo/xbian-package-repo_1.0.0_armhf.deb
dpkg -i xbian-package-repo_1.0.0_armhf.deb
rm xbian-package-repo_1.0.0_armhf.deb
apt-get update
apt-get install xbian-package-cec xbian-package-libtag xbian-package-shairplay libafpclient-dev xbian-package-firmware autoconf automake autopoint autoconf automake autopoint autotools-dev cmake curl debhelper default-jre gawk gperf libao-dev libasound2-dev libass-dev libavahi-client-dev libavahi-common-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev  libbluetooth-dev libbluray-dev libboost-dev libboost-thread-dev libbz2-dev libcap-dev  libcdio-dev libgpg-error-dev libcurl4-gnutls-dev libcwiid-dev libdbus-1-dev libenca-dev  libflac-dev libfontconfig-dev libfreetype6-dev libfribidi-dev libiso9660-dev libjasper-dev  libjpeg-dev libltdl-dev liblzo2-dev libmad0-dev liblockdev1-dev libmicrohttpd-dev  libmodplug-dev libmpcdec-dev libmpeg2-4-dev libmysqlclient-dev libnfs-dev libogg-dev  libpcre3-dev libplist-dev libpng12-dev libpng-dev libpostproc-dev libpulse-dev librtmp-dev  libsamplerate-dev libafpclient-devv libsmbclient-dev libsqlite3-dev libssh-dev libssl-dev  libswscale-dev libtiff-dev libtinyxml-dev libtool libudev-dev libusb-dev libvorbis-dev  libxinerama-dev libxml2-dev libxmu-dev libxrandr-dev libxslt1-dev libxt-dev libyajl-dev  lsb-release nasm python-dev python-imaging python-support swig unzip yasm zip zlib1g-dev libmp3lame-dev libfuse2 doxygen openjdk-7-jre-headless libsdl1.2-dev libsdl-image1.2-dev libltdl7 libavahi-compat-libdnssd1 libao4 locales

Exit either your wheezy or jessie chroot environment by typing exit.

Depending on what our interest is in regards to target system, we don't need to deploy both buildsystems. For the Raspberry Pi just armhfwheezy is enough.

Last step is to make the armhfwheezy and armhfjessie we created visible for schroot. This is done by editing /etc/schroot/schroot.conf and adding those sections:

[armhfjessie]
type=directory
users=root
root-users=root
directory=/home/xbian/build/armhfjessie

[armhfwheezy]
type=directory
users=root
root-users=root
directory=/home/xbian/build/armhfwheezy

You can add any user (even not root) as needed and for sure change directory= to reflect actual directories you debootstrapped our buildroots into. For simple test we can now try:

schroot -c armhfwheezy (or armhfjessie)

If you get output like this and no error, all is fine

mk@debian:~$ schroot -c armhfjessie
(armhfjessie)mk@debian:~$ 

Now we only have to clone the repos we want to build into one directory, copy build.package and gen.package from xbianonpi into that directory as well. Then just descent into package directory you want to build and run ./run.me. by default this would try to compile .deb packages for all supported architectures. This can be specific by calling ./run.me -m rpi. only for Raspberry Pi will be prepared.

Build scripts are able to utilize all available CPUs in the system for parallel building. To allow that, export MAKEFLAGS='-jX' where X the degree of parallel processes allowed. Usually this is set to match number of CPUs so general approach would be for instance putting following line into ~/.profile

export MAKEFLAGS="-j$(grep -c processor /proc/cpuinfo )"

Troubleshoot

If you get the perl error about locales, run the apt-get install step again after you did this:

localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 

buildingpack.txt · Last modified: 2014/07/03 16:50 by rabeeh