$linuxjunkies
>

dpkg-buildpackage(1)

Build a Debian package from source code in a directory tree.

UbuntuDebianFedoraArch

Synopsis

dpkg-buildpackage [OPTION]... [--] [MAKE_OPTIONS]

Description

dpkg-buildpackage is a wrapper around the Debian package build process. It reads the debian/control file, installs build dependencies, runs the debian/rules file with appropriate targets, and creates binary and source packages ready for distribution.

The command automates the sequence of building, signing, and packaging, handling dependency resolution and version tracking automatically. It requires a proper debian/ directory with control, rules, and changelog files.

By default, it builds both binary and source packages; use -b, -B, or -A flags to build only specific package types.

Common options

FlagWhat it does
-bBuild binary packages only (architecture-dependent)
-BBuild binary packages only (architecture-independent)
-ABuild binary packages for all architectures
-SBuild source package only (no binary packages)
-ncDo not clean the source tree (skip clean target)
-dDo not check build dependencies and conflicts
-k<keyid>Use the specified GPG key to sign packages (default: maintainer key)
-usUnsigned source package (skip source signing)
-ucUnsigned changes file (skip changes file signing)
-j<jobs>Set the number of parallel jobs for make (default: CPU count)
-v<version>Include changelog entries for versions newer than <version>
--build=<type>Specify build type: full, binary, arch, source, or any

Examples

Build only binary packages for the current architecture

dpkg-buildpackage -b

Build only the source package (.dsc and .tar.gz)

dpkg-buildpackage -S

Build packages without signing (useful for testing builds)

dpkg-buildpackage -us -uc

Build binary packages using 4 parallel jobs

dpkg-buildpackage -b -j4

Build binary packages without checking build dependencies

dpkg-buildpackage -b -d

Build binary packages and sign with a specific GPG key ID

dpkg-buildpackage -b -k4096R/A1B2C3D4

Build binary packages without cleaning the source tree first

dpkg-buildpackage -nc -b

Build binary packages for all architectures

dpkg-buildpackage -A

Related commands