Skip to main content

How to: Compile packages on Debian/Ubuntu by hand

·240 words·2 mins· ·
Blog Ubuntu Debian Source Code Src Package Packages Deb
Ariejan de Vroom
Author
Ariejan de Vroom
Jack of all Trades, Professional Software Craftsman

In some very rare situations you may find yourself in the need to recompile a Debian (or Ubuntu) package. Luckily for all of use, the great Debian packaging system makes this a piece of cake.

Let’s say we want to recompile mod_python for apache 2 to hook in to python 2.5, instead of the default 2.4.

First, get every thing installed you may need to build the libapache2-mod-python package.

$ apt-get build-dep libapache2-mod-python

Okay, next let’s grab the source for the package. The source will be unpacked to your current working directory, so it may be a good idea to create a seperate directory for this.

$ mkdir src
$ cd src
$ apt-get source libapache2-mod-python

In the case of this example, you don’t need to do anything special to get python 2.5 linked. Just install the python2.5 and python2.5-dev packages.

If you need to apply patches to the source or need to make any other modifications, this is the time!

Okay, now go to the source directory and build the package. This is the tricky command here:

$ cd libapache2-mod-python
$ dpkg-buildpackage -rfakeroot -b

This will build the package. You will get some warnings and errors about missing GPG keys. This is okay. You are not the package maintainer, so your packages should not be marked as ‘original’.

You’re now ready to install your compiled package.

dpkg -i ../libapache2-mod-python-3.3.1-3-i386.deb

That’s all! You compiled and installed a package from source!

Related

How to install MySQL on Ubuntu/Debian
·272 words·2 mins
Ubuntu MySQL Debian
Coming up: Ubuntu Development Server Guide
·93 words·1 min
General Blog Web Development Linux Ubuntu Subversion
Ubuntu 6.10 Live DVD on the Apple MacBook
·599 words·3 mins
General Everything Blog Linux Ubuntu