I’ve been getting back into Vagrant and Ansible lately, as I decided I needed a platform to do some Continuous Integration testing of Arduino and packaging of arduino-mk; and also building Kodi on a faster platform than my Atom HTPC.

As luck would have it, the Debian package for Ansible 1.9.2 just hit Sid, so I don’t have to build my own from git with “make deb”, which is a bit Ubuntu-centric and doesn’t work too well on Debian.

So I’ve made a Fedora 22 VM that I can make arduino-mk packages on, an Ubuntu 12.04 VM that I’m building Kodi 15 packages on, and an Ubuntu 14.04 VM that I’m using for both. I also made a Debian Jessie and another Ubuntu Trusty VM along the way.

As I am using the new VirtualBox 5.0rc2, Vagrant 1.7.2 needs this patch.

The Precise VM (with 8 cores and 4Gb RAM assigned) builds Kodi in 35mins – about half the time it takes the Atom, which isn’t that impressive, but its an improvement.

Setting up an Ubuntu 12.04 build environment for Kodi again was a right PITA though, mainly as “apt-get build-dep” doesn’t actually fetch half the dependencies, and you need newer versions of libyajl2, libyajl-dev, taglib and JsonSchemaBuilder, as well as now having to install gcc 4.9 as they’ve just switched to C++11 today!

So that’s basically this lot wrapped in an Ansible playbook:

add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get update
apt-get build-deps xbmc
apt-get install libssh-dev libxslt1-dev git libmp3lame-dev swig libcec-dev openjdk-7-jdk gcc-4.9 g++-4.9
dpkg -i libyajl2_2.0.4-4_amd64.deb libyajl-dev_2.0.4-4_amd64.deb libtag1x8_1.8-0precise17_amd64.deb
cp /home/vagrant/kodi/packaging/deps/JsonSchemaBuilder /usr/local/bin/JsonSchemaBuilder
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 40
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 60
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 40
update-alternatives --install /usr/bin/x86_64-linux-gnu-gcc x86_64-linux-gnu-gcc /usr/bin/gcc-4.9 60
update-alternatives --install /usr/bin/x86_64-linux-gnu-gcc x86_64-linux-gnu-gcc /usr/bin/gcc-4.6 40
update-alternatives --install /usr/bin/x86_64-linux-gnu-g++ x86_64-linux-gnu-g++ /usr/bin/g++-4.9 60
update-alternatives --install /usr/bin/x86_64-linux-gnu-g++ x86_64-linux-gnu-g++ /usr/bin/g++-4.6 40

Ubuntu 14.04 is much easier, and you just need some basic tasks in your Playbook.yml

- name: install dependencies
  apt: name=xbmc state=build-dep

- name: install libxslt
  apt: name=libxslt1-dev state=present

- name: install git
  apt: name=git state=present

- name: install libcec-dev
  apt: name=libcec-dev state=present