Building debian .deb packages from source

‹ quilt cheat sheet / quick reference | Booting Ubuntu from a network filesystem ›

These are my notes on building debian packages from source.

The steps in preparing a binary debian packages are roughly:

  1. Start with the upstream source code (e.g. .tar.gz)
  2. Unpack it
  3. Add a debian/ subdirectory inside of the unpacked source code
  4. Create a debian prepared source code (.orig.tar.gz) containing the debian/ directory
  5. Create source package (.dsc)
  6. Create binary package (.deb)

Steps without using ubuntu bzr:

  1. Start with an unpacked source tree
  2. To get the debian/ directory, create it with dh_make
  3. To get the debian prepared .tar.gz, run debuild -S -us -uc
    1. ... which calls dpkg-buildpackage to create a new .tar.gz containing debian/ directory.
    2. Note: if you just use debuild by itself without -S, it would also build the binary package, compiling the code using the packages/libraries you have installed currently.
  4. To get the binary package, use pbuilder-dist trusty build *.dsc
    1. pbuilder-dist will call sudo when necessary to run pbuilder
    2. pbuilder will create an isolated chroot environment with stock trusty filesystem
    3. pbuilder will install build dependency packages (like compilers) specified in your source package
    4. pbuilder will then build the binary package inside the chroot

Signing a source package:

debsign filename.changes

Ubuntu, upload to launchpad

dput ppa:yourusername/ppa *_source.changes


Subscribe to All Posts - Wesley Tanaka