dh
Automate Debian package building
SYNOPSIS
dh [sequence] [command options ...]
PARAMETERS
sequence
Specifies the particular sequence of dh_* helper commands to execute. If omitted, dh defaults to a standard, context-dependent sequence based on the invoked make target (e.g., build, clean, binary).
--with <addon>[,<addon>...]
Enables one or more build system addons. Addons extend dh's capabilities to support specific technologies or build systems (e.g., autotools, cmake, python3). Multiple addons can be specified comma-separated.
--without <addon>[,<addon>...]
Disables one or more build system addons. This can be useful to override default addon detection or exclude specific functionalities.
--list-addons
Lists all available build system addons that dh can utilize.
--builddirectory <dir>
Specifies an alternative directory (<dir>) to be used for performing the package build. Defaults to a standard build directory within the source tree.
--sourcedirectory <dir>
Specifies the directory (<dir>) containing the package source code. Defaults to the current directory.
--autoclean
Ensures that dh_clean is called after a successful build process. This helps in maintaining a clean source tree.
--no-act
Performs a 'dry run'. dh will show what commands it *would* execute without actually running them. Useful for debugging packaging rules.
--fail-missing
Causes dh to exit with an error if any expected files are missing after a command, instead of proceeding.
--until <command>
Executes the sequence of helper commands up to, but not including, the specified <command>. Useful for debugging or manual intervention.
--after <command>
Executes the sequence of helper commands starting from the command immediately after the specified <command>. Useful for resuming a build or skipping initial steps.
--parallel[=<N>]
Allows commands to be run in parallel, potentially speeding up the build process. An optional number <N> can specify the maximum number of parallel jobs.
--no-parallel
Disables parallel execution of commands, ensuring they run sequentially.
--verbose
Increases the verbosity of the output, showing more details about the commands being executed.
--quiet
Suppresses non-error output, making the build process quieter.
DESCRIPTION
dh, or Debian Helper, is a program that streamlines and automates the process of building Debian packages. It acts as a wrapper around a series of individual helper commands, typically prefixed with dh_ (e.g., dh_make, dh_auto_configure, dh_install). Instead of manually calling each helper, dh orchestrates their execution in a logical sequence based on the specified build target (like building, cleaning, or installing). This significantly simplifies the debian/rules file, making it more concise and maintainable by abstracting common packaging tasks. It supports various build systems through 'addons' and provides options to customize the build process.
CAVEATS
dh is primarily designed for use within the debian/rules file of a Debian source package. It is not typically executed directly by users from the command line in the same way as common utilities like ls or grep. Its effectiveness relies heavily on a correctly structured Debian package source tree and the implicit understanding of packaging conventions. While it greatly simplifies packaging, complex or non-standard build processes might still require manual override or custom helper scripts.
COMMON USAGE IN <I>DEBIAN/RULES</I>
The most common way to invoke dh is within the debian/rules file of a Debian source package using dh $@. The $@ is a special make variable that expands to the name of the current target being built (e.g., build, clean, binary). This allows dh to automatically execute the appropriate sequence of helper commands for that specific make target, making the debian/rules file very concise, often just a single line per target or even just a single override_dh_* block for customization.
UNDERSTANDING ADDONS
Addons are extensions that teach dh how to interact with different build systems or handle specific types of packages. For instance, the autotools addon provides support for packages using GNU Autoconf/Automake, while python3 handles Python 3 packages. When dh is invoked, it attempts to detect the build system automatically and enable relevant addons. Users can explicitly enable or disable addons using the --with and --without options, offering fine-grained control over the build process.
HISTORY
The dh command is part of the debhelper suite, which was created to simplify the creation of Debian packages. Before debhelper, debian/rules files were often very long and complex, requiring detailed knowledge of dpkg internals. debhelper, and subsequently the dh command, introduced a more declarative and modular approach, abstracting away much of the boilerplate. Over time, dh evolved to support various build systems through its addon mechanism, becoming the standard and recommended way to build most Debian packages, reducing maintenance effort and improving consistency across packages.
SEE ALSO
debian/rules(5), dh_make(1), dpkg-buildpackage(1), dh_auto_build(1), dh_auto_clean(1), dh_auto_configure(1), dh_auto_install(1), dh_install(1), debhelper(7)


