The Debian build toolchain is a collection of software utilities used to create Debian source packages (.dsc
) and Debian binary packages (.deb
files) from upstream source tarballs.
These tools are used in the Debian project and also in Debian-based distributions such as Ubuntu.
Source code for free software is typically distributed in compressed tar archives called tarballs. Debian is a binary-oriented distribution, meaning that its deb
packages include precompiled binaries and data files arranged into a file system hierarchy that the software expects. The Debian build toolchain thus needs instructions on how to use the upstream build system to build correct deb
packages.
These instructions are stored in the debian
subdirectory, which is added to the source tree for the software being packaged by the package maintainer. While it is possible to build the package directly from the modified source tree, it is standard practice to create source packages, which contain the changes the maintainer made to the upstream sources in redistributable form.
A typical Debian source package consists of three files:
For example, a source package named foo
with upstream version 1.2.3 and Debian revision 4 can consist of the following files:
A source package is created using the dpkg-buildpackage
tool or its wrapper debuild
. When invoked to create a source package, dpkg-buildpackage
calls the maintainer's rules to clean the source tree of any intermediate files, does various sanity checks, and finally, signs the dsc
file with the packager's key using the debsign
utility.
The reverse process — producing the unpacked source tree from a source package — is accomplished using the dpkg-source
utility, which extracts the original tarball to a subdirectory, extracts the debian.tar
tarball inside it, and applies any quilt patches present. This is the first step that a build system does when building binary packages from a source package.