Pbuilder
   HOME

TheInfoList



OR:

The Debian build
toolchain In software, a toolchain is a set of programming tools that is used to perform a complex software development task or to create a software product, which is typically another computer program or a set of related programs. In general, the tools form ...
is a collection of software utilities used to create
Debian Debian (), also known as Debian GNU/Linux, is a Linux distribution composed of free and open-source software, developed by the community-supported Debian Project, which was established by Ian Murdock on August 16, 1993. The first version of D ...
source packages (.dsc) and Debian binary packages (.deb files) from
upstream Upstream may refer to: * Upstream (bioprocess) * ''Upstream'' (film), a 1927 film by John Ford * Upstream (networking) * ''Upstream'' (newspaper), a newspaper covering the oil and gas industry * Upstream (petroleum industry) * Upstream (software ...
source tarballs. These tools are used in the Debian project and also in Debian-based distributions such as
Ubuntu Ubuntu ( ) is a Linux distribution based on Debian and composed mostly of free and open-source software. Ubuntu is officially released in three editions: ''Desktop'', ''Server'', and ''Core'' for Internet of things devices and robots. All the ...
.


Overview

Source code for
free software Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any adapted versions. Free software is a matter of liberty, no ...
is typically distributed in compressed
tar Tar is a dark brown or black viscous liquid of hydrocarbons and free carbon, obtained from a wide variety of organic materials through destructive distillation. Tar can be produced from coal, wood, petroleum, or peat. "a dark brown or black bit ...
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 Maintenance may refer to: Biological science * Maintenance of an organism * Maintenance respiration Non-technical maintenance * Alimony, also called ''maintenance'' in British English * Champerty and maintenance, two related legal doctr ...
. 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.


Source packages

A typical Debian source package consists of three files: * The original tarball (orig.tar) — a mere copy of the upstream source tarball if it is in tar format and no changes are necessary, or a repacked tarball. The latter can happen if it contains a snapshot from a
version control system In software engineering, version control (also known as revision control, source control, or source code management) is a class of systems responsible for managing changes to computer programs, documents, large web sites, or other collections o ...
that was never released in tarball form, or if the maintainer needs to remove files not compatible with the
Debian Free Software Guidelines The Debian Free Software Guidelines (DFSG) is a set of guidelines that the Debian Project uses to determine whether a software license is a free software license, which in turn is used to determine whether a piece of software can be included in Deb ...
. * The debian.tar file, which contains changes to the upstream source made by the package maintainer. This includes the entire debian directory. Any modified files outside it are aggregated into patch files inside the debian/patches directory, that are automatically applied before building. * The dsc file, which is a text file with
metadata Metadata is "data that provides information about other data", but not the content of the data, such as the text of a message or the image itself. There are many distinct types of metadata, including: * Descriptive metadata – the descriptive ...
, such as the names of all files constituting the source package and their
SHA256 SHA-2 (Secure Hash Algorithm 2) is a set of cryptographic hash functions designed by the United States National Security Agency (NSA) and first published in 2001. They are built using the Merkle–Damgård construction, from a one-way compression ...
checksums. It also contains the signature of the creator of the source package. For example, a source package named foo with upstream version 1.2.3 and Debian revision 4 can consist of the following files: * foo_1.2.3.orig.tar.gz * foo_1.2.3-4.debian.tar.gz * foo_1.2.3-4.dsc 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 A quilt is a multi-layered textile, traditionally composed of two or more layers of fabric or fiber. Commonly three layers are used with a filler material. These layers traditionally include a woven cloth top, a layer of batting or wadding, a ...
patches present. This is the first step that a build system does when building binary packages from a source package. Older source packages (using Source Format 1) have a .diff.gz file instead of the debian.tar. This is a unified
diff In computing, the utility diff is a data comparison tool that computes and displays the differences between the contents of files. Unlike edit distance notions used for other purposes, diff is line-oriented rather than character-oriented, but it ...
that contains the debian directory and any changes to the upstream source that aren't managed by a patch system.


The debian directory

The debian directory contains files used by dpkg-buildpackage to create both binary and source packages. Unlike
RPM Revolutions per minute (abbreviated rpm, RPM, rev/min, r/min, or with the notation min−1) is a unit of rotational speed or rotational frequency for rotating machines. Standards ISO 80000-3:2019 defines a unit of rotation as the dimensionl ...
, which uses a single spec file for instructions, the Debian tools use an entire subdirectory with multiple files. Three files are required at minimum to correctly build a package — changelog, control and rules. A fourth file, copyright, is mandated by the Debian policy, but is a legal requirement rather than a technical one. By design, all files in the debian directory are text files, most of which are human-readable and edited with a simple text editor.


debian/changelog

This file contains information about all versions of the package since it was created. The build tools only process the top entry, which is used to determine the package version, urgency (which is only of relevance to Debian itself), and bugs in the distribution that this release fixes. For example, for a package named foo, an example debian/changelog entry can read like this: foo (1.2.3-1) unstable; urgency=low * New upstream release. * Dropped 02_manpage_hyphens.dpatch, fixed upstream. * Added 04_edit_button_crash.dpatch: fix a crash after pressing the edit button. (Closes: #654321) * debian/control: foo should conflict with libbar. (Closes: #987654) -- John Doe Fri, 30 Nov 2007 15:29:42 +0100 Debian provides two main utilities for manipulating the debian/changelog file: * dch is used to add new entries to the changelog or modify existing ones. * dpkg-parsechangelog parses the most recent entry and extracts data from it in a Key: value format similar to debian/control. It is primarily used in scripts.


debian/control

This file contains information about the source package and all binary packages it builds (there can be more than one; for example, the source package libbar can serve as the source for binary packages libbar0, which contains just the shared library, and libbar-dev, which contains a static version of the library and header files). It lists (among others) such things as the package name, maintainer, target architectures (for binary packages), build dependencies (packages that must be installed for the package to successfully build) and dependencies (packages that must be installed for the package to function properly when installed).


debian/rules

This file is a script that is invoked by dpkg-buildpackage with a single argument that specifies the action to take (clean, build, install, binary). Although it can technically be any kind of script, it is always implemented as a
makefile In software development, Make is a build automation tool that automatically builds executable programs and libraries from source code by reading files called ''Makefiles'' which specify how to derive the target program. Though integrated develo ...
. Apart from invoking the upstream build system, most instructions in debian/rules are highly repetitive and ubiquitous, and thus, virtually all debian/rules files wrap this functionality in debhelper scripts. For example, automatically determining the dependencies based on shared libraries used is a very common action, and thus, instead of including the code necessary to do it, the debian/rules file simply calls dh_shlibdeps. Other examples of debhelper scripts include dh_installdocs, which installs stock documentation files such as debian/copyright into their appropriate locations, or dh_fixperms, which ensures that files in the package have correct access rights (for example, executables in /usr/bin have the "executable" bit set, but are only writable by the superuser). Since sequences of debhelper scripts are themselves repetitive, some packages simplify debian/rules files directly by using dh or CDBS instead of running each debhelper command directly.


Patch systems

Sometimes, a maintainer needs to modify the original source. While, in the past, this was often done simply by editing the files in place and including the changes in the diff.gz, this could make maintenance difficult when new upstream versions were released, because all the changes had to be examined and merged when necessary. The newer source format, 3.0 (quilt), uses the quilt patch system, to allow the modifications to be broken into groups of logically separated patches, each of which deals with one change and can be sent upstream as is. These patches live in debian/patches. There are also packages using other patch systems, such as dpatch. It generates and executes
shell scripts A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manip ...
that are non-standard
unified diff In computing, the utility diff is a data comparison tool that computes and displays the differences between the contents of files. Unlike edit distance notions used for other purposes, diff is line-oriented rather than character-oriented, but it ...
files with a header, which nevertheless are compatible with the standard diff utility. The debian/rules file is modified to call dpatch apply-all before building the binary package and dpatch deapply-all before building the source package (and cleaning up any build byproducts). quilt and certain other patch systems eliminate the need for special headers and use standard diff files.


Tracking changes in source packages: debdiff and interdiff

Sometimes a user may want to look at differences between two source packages — for example, to generate a proposed patch against the version currently in the repository for inclusion in the distribution's
bug tracking system A bug tracking system or defect tracking system is a software application that keeps track of reported software bugs in software development projects. It may be regarded as a type of issue tracking system. Many bug tracking systems, such as those ...
. If both packages use the same upstream version, this can done using the debdiff tool, which produces differences between two source trees with packaging changes included. If the upstream tarballs for the two versions are different, such a naive comparison cannot be used. Instead, the interdiff utility can be used to produce a diff ''between two diff files'' (in this case, between two diff.gz files). A drawback is that an interdiff output requires more effort to apply, and the one applying the changes must also find and download the newer upstream tarball, which is typically done using the get-orig-source rule in debian/rules.


Sanity checks with lintian

This tool provides automated checks for common packaging mistakes in both binary and source packages, including Debian policy violations and potential compatibility problems. While a maintainer typically aims to correct all issues pointed out by lintian, different distributions can have different policies regarding them. For example,
Ubuntu Ubuntu ( ) is a Linux distribution based on Debian and composed mostly of free and open-source software. Ubuntu is officially released in three editions: ''Desktop'', ''Server'', and ''Core'' for Internet of things devices and robots. All the ...
requires all packages originating in Ubuntu to be clean, but for a package merged into Ubuntu from Debian, there is no such requirement: new changes should simply not introduce any warnings in addition to existing ones. This is done to minimize the divergence between Debian and Ubuntu packages. Here are example lintian outputs:


Isolated build environments

Source packages are intended to be buildable on any installation of the target distribution version, provided that build dependencies are met. In addition, builds can be affected by packages already present in the system. To verify that a package builds on any system, and to exclude any external factors, tools to create isolated build environments are used. These are pbuilder (Personal Builder) and sbuild. These tools maintain minimal working systems in
chroot A chroot on Unix and Unix-like operating systems is an operation that changes the apparent root directory for the current running process and its children. A program that is run in such a modified environment cannot name (and therefore normally ...
, install only the necessary build dependencies listed in debian/control, and remove them when the build is finished. Therefore, using pbuilder, a package maintainer can detect if some build dependencies were not specified in debian/control. Also, pbuilder makes it possible to test-build for distributions other than the one the maintainer is running: for example, for the development version, while actually running the stable version. sbuild is designed for integration with automated build daemons (buildd). It is used by Debian build servers, which automatically build binary packages for every supported architecture. The
Launchpad A launch pad is an above-ground platform from which rocket- missiles or space launch vehicles take off vertically. Launch pad may also refer to: Computing * Launchpad (macOS), an application launcher introduced in Mac OS X Lion * Launch Pad (s ...
service provides similar build daemons for Ubuntu, both the official distribution and personal package archives (PPAs).


See also

*
Deb (file format) deb is the format, as well as extension of the software package format for the Debian Linux distribution and its derivatives. Design Debian packages are standard Unix ar archives that include two tar archives. One archive holds the contro ...
*
dpkg dpkg is the software at the base of the package management system in the free operating system Debian and its numerous derivatives. dpkg is used to install, remove, and provide information about .deb packages. dpkg (Debian Package) itself is a ...
*
lintian Lintian is a helper tool used in conjunction with dpkg, the Debian package management system. It checks Debian software packages for common inconsistencies and errors. As of Nov 10th 2022, the latest version complies to Debian standards version ...


References

{{Reflist


External links


Debian New Maintainer's Guide

Ubuntu Packaging Guide
Dpkg