I have been dabbling with Apache Thrift the last couple of days, both on Windows and in Ubuntu Linux. If you are anything like me you will find the Thrift documentation lacking to say the least and that’s why I’m publishing this text and more will probably follow. I give you no guarantee that this will work for you as it did for me but it might give you a hint on how to solve your issues.
At the time of writing Thrift is not included in any of the standard Ubuntu package repositories and I was not able to find it in a launchpad ppa either. Finally I got the source from the Apache Subversion repository and started to look at the build instructions. Making a long story short, the prerequisites for compiling it are HUGE. This is actually a good thing since it comes from support in a big variety of programing languages. I just needed Python for my experiments and the Thrift compiler is built in C and CPP but I couldn’t get it to compile properly with just that no matter how I tried to disable the other features. So I had to take a Google moment and collect my thoughts…..
After some searching I came upon a issue in Thrifts bug tracker, https://issues.apache.org/jira/browse/THRIFT-71. What this says is that in December -10 someone committed the “debian” folder necessary to build proper .deb packages to the source code. One small issue though, you can find it inside the .contrib/ folder and not in the root folder as usual, otherwise I would have spotted it when trying to compile. It was also accompanied with a small shell script that linked this ./contrib/debian folder to the required ./debian path. This made life a lot easier since all dependencies and other stuff were given but… I really didn’t need or wanted all of those dependencies needed to build the packages installed on my system just to try it’s Python code out, what to do…?
On to the scene steps something called pbuilder which you can find the details about in https://wiki.ubuntu.com/PackagingGuide/. What it does is basically provide a chrooted environment on your computer where debian packages will be built without messing with your normal installation.
The following instructions will install the things necessary to get pbuilder and to build the thrift packages and later install them. Be warned though, it will take some time to do since pbuilder basically installs a minimal Ubuntu environment in a chroot.
First pbuilder, set up for building maverick compatible debs:
$ sudo apt-get install debhelper pbuilder $ cp /usr/share/doc/pbuilder/examples/pbuilder-distribution.sh ~/bin $ ln -s ~/bin/pbuilder-distribution.sh ~/bin/pbuilder-maverick $ mkdir ~/pbuilder $ ~/bin/pbuilder-maverick create
This will give you a pbuilder environment ready to do some work… but what work?
- Download Thrift from http://thrift.apache.org/download/ and put it in your home folder. At the time of writing it was version 0.6.0
Go back to the console once again and do... $ cd ~ $ mkdir thrift $ cd thrift $ tar -zxf ../thrift-0.6.0.tar.gz $ cd thrift-0.6.0 $ ln -s contrib/debian debian $ dpkg-buildpackage -S -us -uc $ cd .. $ ~/bin/pbuilder-maverick build *.dsc
- If all goes well you should now have a bunch of .deb files in ~/pbuilder/result. Install them as usual or with dpkg -i <the file you want>.deb
$ dpkg -i thrift-0.6.0-dev1.tar.gz
This worked for me to get up and running with Thrift on Ubuntu. Hopefully it will be good use for someone else as well.