Compiling mongodb 'stable' as a debian lenny package January 14th, 2010

Today I had the pleasure of having to install MongoDb on one of our production servers. Pleasure because MongoDb is an awesome document database, and I also like new things.

Most of our production servers run Debian, and we try to keep all installed packages up to date with apt. Since Debian Lenny didn’t have a mongodb package (it does have a lot of other packages Mongolian language packs) I had to make my own. Luckily the mongodb git repository comes with a ‘debian’ folder, so making a .deb package should be easy as pie.

There are quite a few gotchas to get it to build, though. This is what you’ll need to do:

Get last mongodb ‘stable’ source

git clone git://github.com/mongodb/mongo.git
cd mongo
git checkout r1.2.1

The debian/control file lists all deps including one we can’t fulfill on Lenny, xulrunner-1.9-dev. We only have xulrunner-dev. So change the debian/control file:

# the Build-Depends line
-Build-Depends: debhelper (>= 7), libboost-dev, libpcre3, libpcre3-dev, scons, xulrunner-1.9-dev, libboost-thread-dev, libboost-filesystem-dev, libboost-program-options-dev, libboost-date-time-dev
+Build-Depends: debhelper (>= 7), libboost-dev, libpcre3, libpcre3-dev, scons, xulrunner-dev, libboost-thread-dev, libboost-filesystem-dev, libboost-program-options-dev, libboost-date-time-dev

# the Depends line
-Depends: ${shlibs:Depends}, ${misc:Depends}, xulrunner-1.9-dev
+Depends: ${shlibs:Depends}, ${misc:Depends}, xulrunner-dev

Also, be sure to install all these build-deps

apt-get install debhelper libboost-dev libpcre3 libpcre3-dev scons xulrunner-dev libboost-thread-dev libboost-filesystem-dev libboost-program-options-dev libboost-date-time-dev

Next up, we’ll need to change a script (buildscripts/hacks_ubuntu.py) which sets old-xulrunner-compatibility. Apparently the bug I encountered was already fixed but didn’t work on my system. I just deleted the condition since I was sure I needed the old-compatability mode.

diff --git a/buildscripts/hacks_ubuntu.py b/buildscripts/hacks_ubuntu.py
index 67c5d78..baebfe6 100644
--- a/buildscripts/hacks_ubuntu.py
+++ b/buildscripts/hacks_ubuntu.py
@@ -42,6 +42,5 @@ def foundxulrunner( env , options ):
                            incroot + "unstable/" ] )

     env.Append( CPPDEFINES=[ "XULRUNNER" , "OLDJS" ] )
-    if best.find( "1.9.0" ) >= 0:
-        env.Append( CPPDEFINES=[ "XULRUNNER190" ] )
+    env.Append( CPPDEFINES=[ "XULRUNNER190" ] )
     return True

That’s all changes needed to get it to compile. Next step is running dpkg-buildpackage and installing the package!

dpkg-buildpackage -rfakeroot -b
# <it builds..>
dpkg -i ../mongodb_1.2.1*.deb
tags: , , , l

4 Responses to “Compiling mongodb 'stable' as a debian lenny package”

  • over 2 years ago Frank said

    You’ll need a chmod +x debian/rules as well, as git doesn’t set the executable bit on the script.

  • over 2 years ago Tero Tilus said

    There are deb repositories for Debian and Ubuntu by 10gen. See http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages

  • about 1 year ago Bolden said

    where is system? Debian or Ubuntu

  • about 1 year ago George said

    This is great and very helpful,thanks

Sorry, comments are closed for this article.