Cross-compiling TVHeadend for Raspberry Pi

This guide details how to set up a chroot environment to enable you to build TVHeadend for Raspberry Pi (which uses the arm architecture) on an x86_64 Debian distribution.

Setting up the chroot

A chroot is essentially an installation of the linux operating system that exists within the host version but is (or can be) completely isolated from the outside host. This means that it’s possible to build packages for completely different versions of linux than the one running the chroot and indeed even different architectures. This guide specifically details setting up a chroot which runs the armhf version of Debian (as used by the Raspberry Pi) to enable you to build and optionally package a version of TVHeadend for distribution and use on the Raspberry Pi.

Installing the required tools

sudo apt-get install qemu-user-static dchroot schroot debootstrap wget


sudo aptitude install qemu-user-static dchroot schroot debootstrap wget
cd /tmp
sudo dpkg -i raspbian-archive-keyring_20120528.2_all.deb

Creating your chroot

sudo mkdir -p /var/chroot/raspbian-armhf/
sudo qemu-debootstrap --keyring /usr/share/keyrings/raspbian-archive-keyring.gpg --arch armhf jessie /var/chroot/raspbian-armhf

If you want to use a different version of Debian other than jessie – substitute jessie for your preferred version (i.e. wheezy) in the command above

sudo echo raspbian-armhf | sudo tee /var/chroot/raspbian-armhf/etc/debian_chroot
sudo ln -s ../proc/mounts /var/chroot/raspbian-armhf/etc/mtab
sudo cp /etc/passwd /etc/group /etc/shadow /var/chroot/raspbian-armhf/etc
sudo nano /etc/dchroot.conf

Enter the following in the newly created file;

raspbian-armhf /var/chroot/raspbian-armhf
sudo nano /etc/schroot/schroot.conf

Enter (or add to the end of the file) the following. Again substitute jessie for your preferred debian variant (i.e. wheezy)

description=raspbian jessie armhf

Entering the chroot

sudo dchroot -d -c raspbian-armhf

The following commands all happen inside of the chroot – ensure that your bash prompt says ‘raspbian-armhf’ before continuing as this confirms you are inside of your chroot environment.

Installing the required tools

sudo apt-get install git build-essential pkg-config libssl-dev bzip2 wget libavahi-client-dev zlib1g-dev libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavresample-dev python gettext cmake libdvbcsa-dev liburiparser-dev debhelper libcurl4-gnutls-dev curl

If you get an error whilst trying to install these packages, check your sources.list to ensure it has not been replaced by another mirror other than the raspbian one;

sudo nano /etc/apt/sources.list

It should look like this;

deb jessie main
deb-src jessie main

If it doesn’t, delete any lines in the file (CTRL+K) then replace them with the above lines and try installing the packages again.

Downloading the TVHeadend source code

Change to the root directory;

cd /root

To download the latest stable (4.0) source code then running

git clone -b release/4.0

If you want to get the very latest (4.1) source code (which is considered unstable) then running

git clone

Packaging the source code into a redistributable .deb package

As the intention of this guide is to install the package on a different machine, we have skipped the ‘build’ step as it is incorporated into the packaging instructions below.

From the TVHeadend source directory, run;

AUTOBUILD_CONFIGURE_EXTRA='--prefix=/usr --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libexecdir=${prefix}/lib/tvheadend --disable-maintainer-mode --disable-dependency-tracking --enable-libffmpeg_static --enable-hdhomerun_static --enable-dvbcsa --enable-bundle' ./ -t debian

Installing packaged version of TVHeadend

The autobuild command will produce a .deb file (named something like tvheadend_v4.1-2141~g01c26fc_amd64.deb) in the directory above the source directory. Copy the debian package (either by using a USB disk or using scp to copy it to your target host) and run the following to install it;

sudo dpkg -i YourPackageName.deb

You will more than likely hit failed dependencies here so after running the above, run the following to fix the missing dependencies;

sudo apt-get install -f

That’s it! You should be able to view the TVHeadend web interface at http://RaspberryPiIPAddress:9981/

Posted in TVHeadend Tagged with: , , , , ,