Compiling and packaging Kodi’s binary addons for Raspbian
As a follow up of this post, I’d like to write a bit about the process of compiling and packaging Kodi’s binary addons. This guide also assumes that you have Kodi installed and fully functional and all deb packages generated by the referred guide are installed in the system.
Binary addons provide extra functionality, such as PVR players, screensavers, enconders, etc..
In the scope of this guide, I’ll focus on compiling one addon and at the end I’ll generalise it for the others. As an example, I’ll explain how to compile pvr.iptvsimple
which is PVR a binary addon.
Note: I personally don’t think this is the best way to compile and package binary addons, I’d prefer the binary addons to use cpack as kodi’s build. This is something that can definitely be improved.
Step 1: Install dependencies
First thing we need to make install some libraries that we will need to be able to compile some of the addons:
sudo apt-get install libtinyxml2-dev libhdhomerun-dev libjsoncpp-dev libfluidsynth-dev
Step 2: Install libkodiplaform(-dev)
Binary addons depend on libkodiplatform-dev
and libkodiplatform
to be installed, so we’ll start with those. Please note that this step you’ll only need to do once. These libraries are a requirement to build binary addons, and once installed there’s no need to install it again, unless, of course, we need new functionality provided by newer versions of the libraries.
git clone https://github.com/xbmc/kodi-platform.git cd kodi-platform dpkg-buildpackage -us -uc -b sudo dpkg -i ../libkodiplatform*.deb
And that’s it 🙂 Let’s move on.
Alternative: As well as stated in the guide to compile Kodi, you can use this script with the option -a that will compile and package the binary addons for you. If this is just what you need, have a look at it and use it, all the work described below is done in that script.
Step 3: Bootstrap addons
Binary addons also use cmake, which make it quite easy to bootstrap. What I will be doing here, might not be easiest and cleaner way to do it, but since I wanted to package binary addons on .deb files, this is the way I found to do it properly. It’ also worth to have a look and read the documentation on kodi’s github.
I’m assuming that you’re inside Kodi’s build dir, so let’s create a new directory where we will build the addons.
Replace below $PATH_TO_KODI_REPO with the absolute path to the place where your kodi repo is located.
mkdir -p $PATH_TO_KODI_REPO/build/build_addons cd $PATH_TO_KODI_REPO/build/build_addons
At this point we can bootstrap our binary addons by
cmake -DOVERRIDE_PATHS=1 -DBUILD_DIR=`pwd` \ -DCORE_SOURCE_DIR=$PATH_TO_KODI_REPO -DADDONS_TO_BUILD="pvr.iptvsimple" \ -DADDON_DEPENDS_PATH="$PATH_TO_KODI_REPO/build/build/" \ -DCMAKE_INCLUDE_PATH=/opt/vc/include:/opt/vc/include/interface:/opt/vc/include/interface/vcos/pthreads:/opt/vc/include/interface/vmcs_host/linux \ -DCMAKE_LIBRARY_PATH=/opt/vc/lib \ $PATH_TO_KODI_REPO/project/cmake/addons/
Let’s have a closer look at the -DADDONS_TO_BUILD
setting. The build system allows several options here which are worth mentioning. It accepts wildcards, for instance pvr.*
which will bootstrap app pvr addons, it also supports all
(default) that will bootstrap all addons, and a space delimited options for a list of addons, i.e. pvr.* visualisation.waveform
. Feel free to experiment with those.
The command above will create the needed files in your current directory.
Note: If you’re idea is just to compile and install it in your Raspbian installation, once addons are boostrapped, you can simply run make sudo-install
which will compile and install everything that is needed – I didn’t personally test this approach, feel free to provide comments and feedback about it in the comments below.
Step 4: Create debian packages
At this point you should see a directory named pvr.iptvsimple
in our current path. That directory has inside a debian folder which you are already familiar with. We will need to change it a little bit, but with the help of this guide the steps are the same for every addon.
First we will need the information of the version we will be building, some addons have it in a addon.xml.in
some others in a addon.xml
file, so we can create a proper debian/changelog
file. We’ll need to find it out programatically, so it works on both scenarios.
cd pvr.iptvsimple VERSION_FILE="addon.xml.in" [[ ! -f "pvr.iptvsimple/addon.xml.in" ]] && VERSION_FILE="addon.xml" ADDONS_PACK_VER=$(grep -oP " version=\"(.*)\"" ./pvr.iptvsimple/${VERSION_FILE} | awk -F'\"' '{print $2}') sed -e "s/#PACKAGEVERSION#/${ADDONS_PACK_VER}/g" -e "s/#TAGREV#/1/g" -e "s/#DIST#/$(lsb_release -cs)/g" debian/changelog.in > debian/changelog
At this moment, the debian/changelog
file should contain the right version.
So now we have everything we need to compile and build the debian package. However, in some cases the install path where the addons will be installed are not he correct one, so we will need to fix them. This is the case of any pvr
, any audioencoder
and visualisation.waveform
also probably others. If you find that Kodi is not recognising the addon you’ve just compiled, please check if it is installed in the right place.
Let’s fix it quickly with the following:
for F in $(ls debian/*.install); do echo "usr/lib" > ${F}; echo "usr/share" >> ${F}; done;
The only thing left is to actually compile and package.
dpkg-buildpackage -us -uc -b
Once finished, you should have the packages and be able to install them by using:
sudo dpkg -i ../kodi-pvr-iptvsimple*.deb
If everything went ok, you can now run Kodi and your addon should be installed.
I hope this guide was useful as well, please post in the comments if you have feedback.
Acknowledgements: Once again I’d like to thanks Diogo Santos for helping out to figure out how to build addons.
Recent Comments