Build Ubuntu/Debian packages from source (and apply a patch)

Sometimes there is a bug in a package from ubuntu that is not yet fixed, or you just want to modify something in the source of a software. Here is an easy way to build your own package from the ubuntu sources.

First you need to install the required tools for building software from source

sudo apt-get install build-essential

Let's assume you want to build a package called foo and apply a patch bar.patch to it.

First you have to download the necessary build dependencies for foo

sudo apt-get build-dep foo

Now you are ready to download the actual sources of the package (Don't use sudo here!!)

apt-get source foo

This gives you a directory called foo-<version> you can now cd into it apply the patch and build the package

cd foo-<version>
patch -p1 < bar.patch
dpkg-buildpackage

Now you have a package called foo-<version>.deb in the same directory where you have run apt-get source. You can install it using dpkg.

sudo dpkg -i foo-<version>.deb

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">