dh
Automate Debian package building
SYNOPSIS
dh [options] [--] [buildsystem] [override-targets...]
PARAMETERS
-v, --verbose
Verbose output mode.
--no-act, -n
Dry run; show commands without executing.
-i, --indep
Act only on architecture-independent ('Indep') packages.
-a, --arch
Act only on architecture-dependent ('Arch') packages.
-s, --source
Act on source package (rarely used).
-pPKG, --package=PKG
Act only on specified package PKG.
-N PKG, --no-package=PKG
Exclude specified package PKG.
--with MODULE[,...]
Add debhelper modules to sequence (e.g., python3,sp).
--without MODULE
Remove debhelper module from sequence.
-O DIR, --output-dir=DIR
Use DIR as output directory (default debian/pkg).
-D DIR, --destdir=DIR
Set top-level DESTDIR for installation.
-U DIR, --sourcedir=DIR
Set top-level source directory.
-X ITEM, --exclude=ITEM
Exclude ITEM from processing (shell glob).
--list, --list-excluded
List packages or exclusions.
--buildsystem=SYSTEM
Use specific buildsystem (e.g., cmake, meson).
-jN, -j
Run up to N jobs in parallel.
--parallel
Enable parallel building.
DESCRIPTION
dh is the primary command of the debhelper suite, a collection of tools for simplifying Debian package creation. It automatically runs a predefined sequence of debhelper commands (like dh_testdir, dh_auto_configure, dh_auto_build, etc.) based on the package's debian/control file, debian/compat level, and any overrides in debian/rules.
This allows maintainers to use a simple #!/usr/bin/make -f shebang in debian/rules instead of manually calling dozens of commands. The sequence adapts to the declared binary packages and architecture. For example, it installs files, generates manpages, strips binaries, and creates Debian diffs.
dh supports multiple buildsystems (autotools, cmake, meson, etc.) via --buildsystem or auto-detection. It respects parallel builds with DEB_BUILD_OPTIONS and handles multi-binary/multiarch packages. Compatibility levels (v1-v13+) control defaults and features, with v10+ assuming parallel=8.
Key benefits: reduces boilerplate in debian/rules, minimizes errors, and scales to complex packages. Always run via dpkg-buildpackage or debuild.
CAVEATS
Requires debhelper in Build-Depends. Sequence order is fixed; use overrides for custom logic. High compat levels (v13) enable new defaults—test thoroughly. Not for non-Debian packaging.
DEBIAN/COMPAT
File sets compatibility level (e.g., 13). Higher levels add features like parallel builds, systemd units.
DEBIAN/RULES OVERRIDES
Use override_dh_auto_test: for custom targets in debian/
EXAMPLE USAGE
debian/rules:
#!/usr/bin/make -f
%:
dh $@
Build with: dpkg-buildpackage -us -uc
HISTORY
Developed by Joey Hess starting 1997. dh introduced in debhelper v5 (2006) as %dh macro replacement. v7 (2009) made it default sequence runner. v9+ added multiarch; v10+ parallel by default. v13 (2020) supports newer tools like meson.
SEE ALSO
debhelper(7), dh_installdirs(1), dh_install(1), dh_auto_configure(1), dh_strip_nondeterminism(1), dpkg-buildpackage(1)


