Compiling and patching debian packages from source

A quick reference on how to compile Debian packages from source, and possibly patching them along the way.

Getting and preparing the source

First, get the essentials:

apt-get install build-essential

Grab the package with:

apt-get source <package>

Install everything required to compile it:

apt-get build-dep <package>

Next, make a copy of the prepared source directory and apply your own patches and modifications.

Making a patch from what you’ve done

diff -dupr <original source directory> <modified source directory> > mypatch.diff

Compiling and making packages

Enter the program’s main directory and then issue this command:

dpkg-buildpackage -rfakeroot

This will do everything for you. It will:

  • clean the source tree (debian/rules clean), using fakeroot
  • build the source package (dpkg-source -b)
  • build the program (debian/rules build)
  • build the binary package (debian/rules binary), using fakeroot
  • sign the source .dsc file, using gnupg
  • create and sign the upload .changes file, using dpkg-genchanges and gnupg

Leave a Reply

Your email address will not be published. Required fields are marked *