dpkg-buildpackage(1)
๐ dpkg-buildpackage(1) ๐
from the dpkg suite, bestie โ this is the manual page for dpkg-buildpackage, and weโre gonna make it make sense ๐
โจ NAME โจ
dpkg-buildpackage โ build binary or source packages from sources. Slay, thatโs the whole job ๐
๐ธ SYNOPSIS ๐ธ
dpkg-buildpackage [option...] [--] [filename.dsc|directory]
๐ฆ DESCRIPTION ๐ฆ
dpkg-buildpackage is a program that automates the process of building a Debian package. iconic behavior, honestly ๐
Support for the filename.dsc and directory arguments since dpkg 1.22.7, with experimental semantics. yes bestie, experimental โ proceed with the vibe check ๐ซถ
It consists of the following steps:
- It runs the
preinithook before reading any source file. If a.dscfile has been specified it unpacks it anew and changes directory to it, if a directory has been specified it changes directory to it, otherwise it expects the current directory to contain the source tree. It prepares the build environment by setting various environment variables (see ENVIRONMENT), runs theinithook, and callsdpkg-source --before-build(unless-Tor--targethas been used). - It checks that the build-dependencies and build-conflicts are satisfied (unless
-dor--no-check-builddepsis specified). dependency drama check โ - If one or more specific targets have been selected with the
-Tor--targetoption, it calls those targets and stops here. Otherwise it runs theprecleanhook and callsfakeroot debian/rules cleanto clean the build-tree (unless-ncor--no-pre-cleanis specified). - It runs the
sourcehook and callsdpkg-source -bto generate the source package (if a source build has been requested with--buildor equivalent options, and if no.dschas been specified). - It runs the
buildhook and callsdebian/rules build-target, then runs thebinaryhook followed byfakeroot debian/rules binary-target(unless a source-only build has been requested with--build=sourceor equivalent options). Note thatbuild-targetandbinary-targetare eitherbuildandbinary(default case, or if ananyandallbuild has been requested with--buildor equivalent options), orbuild-archandbinary-arch(if ananyand notallbuild has been requested with--buildor equivalent options), orbuild-indepandbinary-indep(if analland notanybuild has been requested with--buildor equivalent options). okay thatโs a lot of targets but weโre keeping track ๐ฏ - It runs the
buildinfohook and callsdpkg-genbuildinfoto generate a.buildinfofile. Severaldpkg-buildpackageoptions are forwarded todpkg-genbuildinfo. If a.dschas been specified, then it will be referenced in the generated.buildinfofile, as we can ascertain the provenance of the source tree. - It runs the
changeshook and callsdpkg-genchangesto generate a.changesfile. The name of the.changesfile will depend on the type of build and will be as specific as necessary but not more; the name will be:source-name_binary-version_arch.changesโ for a build that includesanysource-name_binary-version_all.changesโ otherwise for a build that includesallsource-name_source-version_source.changes. โ otherwise for a build that includessource
Many dpkg-buildpackage options are forwarded to dpkg-genchanges.
- It runs the
postcleanhook and if-tcor--post-cleanis specified, it will callfakeroot debian/rules cleanagain. - It calls
dpkg-source --after-build. - It runs the
checkhook and calls a package checker for the.changesfile (if a command is specified inDEB_CHECK_COMMANDor with--check-command). - It runs the
signhook and signs using the OpenPGP backend (as long as it is not anUNRELEASEDbuild, or--no-signis specified) to sign the.dscfile (if any, unless-usor--unsigned-sourceis specified), the.buildinfofile (unless-ui,--unsigned-buildinfo,-ucor--unsigned-changesis specified) and the.changesfile (unless-ucor--unsigned-changesis specified). - If a
.dscfile has been specified, it removes the extracted source directory. - It runs the
donehook. and thatโs the pipeline, bestie โ no cap ๐ซก
๐ OPTIONS ๐
All long options can be specified both on the command line and in the dpkg-buildpackage system and user configuration files. Each line in the configuration file is either an option (exactly the same as the command line option but without leading hyphens) or a comment (if it starts with a โ#โ).
--build=typeโ Specifies the build type from a comma-separated list of components. All the specified components get combined to select the single build type to use, which implies a single build run with a single.changesfile generated. Passed todpkg-genchanges.
Supported since dpkg 1.18.5.
The allowed values are:
sourceโ Builds the source package.
Note: When using this value standalone and if what you want is to only (re-)build the source package from a clean source tree, using dpkg-source directly is always a better option as it does not require any build dependencies to be installed which are otherwise needed to be able to call the clean target.
anyโ Builds the architecture specific binary packages.allโ Builds the architecture independent binary packages.binaryโ Builds the architecture specific and independent binary packages. This is an alias forany,all.fullโ Builds everything. This is an alias forsource,any,all, and the same as the default case when no build option is specified.
-gโ Equivalent to--build=source,all.
Supported since dpkg 1.17.11.
-Gโ Equivalent to--build=source,any.
Supported since dpkg 1.17.11.
-bโ Equivalent to--build=binaryor--build=any,all.-Bโ Equivalent to--build=any.-Aโ Equivalent to--build=all.-Sโ Equivalent to--build=source.-Fโ Equivalent to--build=full,--build=source,binaryor--build=source,any,all.
Supported since dpkg 1.15.8.
--target=target[,...],--target target[,...],-T,--rules-target=target[,...]โ Callsdebian/rules targetonce per target specified, after having setup the build environment (except for callingdpkg-source --before-build), and stops the package build process here. If--as-rootis also given, then the command is executed as root (see--root-command). Note that known targets that are required to be run as root do not need this option (i.e. theclean,binary,binary-archandbinary-indeptargets).
Support for short option since dpkg 1.15.0. Support for long option since dpkg 1.18.8. Support for multiple targets since dpkg 1.18.16.
--as-rootโ Only meaningful together with--target. Requires that the target be run with root rights.
Supported since dpkg 1.15.0.
-siโ Passed unchanged todpkg-genchanges. See its manual page.-saโ Passed unchanged todpkg-genchanges. See its manual page.-sdโ Passed unchanged todpkg-genchanges. See its manual page.-vversionโ Passed unchanged todpkg-genchanges. See its manual page.-Cchanges-descriptionโ Passed unchanged todpkg-genchanges. See its manual page.-mmaintainer-addressโ Passed unchanged todpkg-genchanges. See its manual page.-emaintainer-addressโ Passed unchanged todpkg-genchanges. See its manual page.--build-by=maintainer-addressโ Pass as-mtodpkg-genchanges. See its manual page.
Support for --build-by since dpkg 1.18.8.
--source-by=maintainer-addressโ Pass as-mtodpkg-genchanges. See its manual page.
Support for --source-by since dpkg 1.21.10.
--release-by=maintainer-addressโ Pass as-etodpkg-genchanges. See its manual page.
Support for --release-by since dpkg 1.18.8.
--changed-by=maintainer-addressโ Pass as-etodpkg-genchanges. See its manual page.
Support for --changed-by since dpkg 1.21.10.
-a,--host-archarchitecture โ Specify the Debian architecture we build for. The architecture of the machine we build on is determined automatically, and is also the default for the host machine.
Support for long option since dpkg 1.17.17.
-t,--host-typegnu-system-type โ Specify the GNU system type we build for. It can be used in place of--host-archor as a complement to override the default GNU system type of the host Debian architecture.
Support for long option since dpkg 1.17.17.
--target-archarchitecture โ Specify the Debian architecture the binaries built will build for. The default value is the host machine.
Supported since dpkg 1.17.17.
--target-typegnu-system-type โ Specify the GNU system type the binaries built will build for.
It can be used in place of --target-arch or as a complement to override the default GNU system type of the target Debian architecture.
Supported since dpkg 1.17.17.
-P,--build-profiles=profile[,...]โ Specify the profile(s) we build, as a comma-separated list. The default behavior is to build for no specific profile. Also sets them (as a space separated list) as theDEB_BUILD_PROFILESenvironment variable which allows, for example,debian/rulesfiles to use this information for conditional builds.
The exclamation marks are not part of the build profile names, and thus not accepted in this option.
Support for short option since dpkg 1.17.2. Support for long option since dpkg 1.18.8.
-j,--jobs[=jobs|auto]โ Specifies the number of jobs allowed to be run simultaneously. The number of jobs matching the number of online processors ifautois specified (since dpkg 1.17.10), or unlimited number ifjobsis not specified. The default behavior isauto(since dpkg 1.18.11) in non-forced mode (since dpkg 1.21.10), and as such it is always safer to use with any package including those that are not parallel-build safe. Setting the number of jobs to1will restore serial execution.
Will add parallel=jobs or parallel to the DEB_BUILD_OPTIONS environment variable which allows debian/rules files to opt-in to use this information for their own purposes. The jobs value will override the parallel=jobs or parallel option in the DEB_BUILD_OPTIONS environment variable. Note that the auto value will get replaced by the actual number of currently active processors, and as such will not get propagated to any child process. If the number of online processors cannot be inferred then the code will fallback to using serial execution (since dpkg 1.18.15), although this should only happen on exotic and unsupported systems.
Support for short option since dpkg 1.14.7. Support for long option since dpkg 1.18.8.
-J,--jobs-try[=jobs|auto]โ This option is equivalent to the-jabove.
Since the behavior for -j changed in dpkg 1.21.10 to the opt-in mode, you can use this option instead if you need to guarantee semantics across dpkg release series.
Support for short option since dpkg 1.18.2. Support for long option since dpkg 1.18.8.
--jobs-force[=jobs|auto]โ basically--jobsbut with the volume cranked to eleven ๐ฅ it turns on forced parallel mode by stuffing themake -joption, with the computed number of parallel jobs, into theMAKEFLAGSenvironment variable.
Which means every make invocation after that inherits it, forcing the parallel setting onto the packaging (and possibly onto the upstream build system too, if that one uses make(1)) whether or not they actually support parallel builds. And yeah โ that can straight up cause build failures. ๐ญ
Note: anyMakefilethat isn't parallel-safe should be considered buggy. Make it parallel-safe, or mark it as not safe with themake(1).NOTPARALLELtarget. No exceptions, bestie.
Supported since dpkg 1.21.10.
-D,--check-builddepsโ check build dependencies and conflicts, and abort if they're not satisfied. This is the default behaviour, so it's already doing this for you, queen ๐ซถ
Support for long option since dpkg 1.18.8.
-d,--no-check-builddepsโ do not check build dependencies and conflicts. Living dangerously, love that for you.
Support for long option since dpkg 1.18.8.
--ignore-builtin-builddepsโ don't check built-in build dependencies and conflicts. These are the distribution-specific implicit build dependencies that a build environment usually requires, aka the so-called Build-Essential package set.
Supported since dpkg 1.18.2.
--rules-requires-rootโ do not honour theRules-Requires-Rootfield, falling back to its legacy default valuebinary-targets.
Supported since dpkg 1.19.1.
-nc,--no-pre-cleanโ don't clean the source tree before building. Implies-bif nothing else has been selected among-F,-g,-G,-B,-Aor-S. Implies-dwith-S(since dpkg 1.18.0).
Support for long option since dpkg 1.18.8.
--pre-cleanโ clean the source tree before building. This is the default behaviour, so things stay tidy โจ
Supported since dpkg 1.18.8.
-tc,--post-cleanโ clean the source tree after the package has been built (using gain-root-commanddebian/rules clean).
Support for long option since dpkg 1.18.8.
--no-post-cleanโ don't clean the source tree after the package has been built. This is the default behaviour.
Supported since dpkg 1.19.1.
--sanitize-envโ sanitize the build environment. It resets or removes environment variables, umask, and any other process attributes that might otherwise mess with the build of packages ๐ค Because the official entry point for building packages isdebian/rules, packages can't rely on these settings being in place, and should work even when they're not. What gets sanitized is vendor specific.
Supported since dpkg 1.20.0.
-r,--root-command=gain-root-commandโ whendpkg-buildpackageneeds to run part of the build process as root, it prefixes the command it executes with gain-root-command, if one has been specified. If none has been specified,fakerootgets used by default, if the command is present. gain-root-command should start with the name of a program on thePATH, and it receives as arguments the name of the real command to run plus the arguments it should take. gain-root-command can include parameters (they must be space-separated) but no shell metacharacters. Typically gain-root-command might befakeroot,sudo,superorreally.suis not suitable, because it can only invoke the user's shell with-cinstead of passing arguments individually to the command to be run. ๐
Support for long option since dpkg 1.18.8.
-R,--rules-file=rules-fileโ building a Debian package usually means invokingdebian/rulesas a command with several standard parameters. With this option you can use a different program invocation to build the package instead (it can include space-separated parameters). Or you can use it to execute the standard rules file with another make program โ for example by using/usr/local/bin/make -f debian/rulesas rules-file. Iconic flexibility behaviour ๐
Support for short option since dpkg 1.14.17. Support for long option since dpkg 1.18.8.
--check-command=check-commandโ the command used to check the.changesfile itself and any artifact built that's referenced in the file. The command should take the.changespathname as an argument. This command will usually belintian.
Supported since dpkg 1.17.6.
--check-option=optโ pass option opt to the check-command specified withDEB_CHECK_COMMANDor--check-command. Can be used multiple times, stack 'em up ๐
Supported since dpkg 1.17.6.
--hook-hook-name=hook-commandโ set the specified shell code hook-command as the hook hook-name, which runs at the times specified in the run steps. The hooks always get executed even if the following action isn't performed (except for thebinaryhook). All the hooks run in the unpacked source directory.
Some hooks can receive additional information through environment variables (since dpkg 1.22.0). All hooks get the hook name in the DPKG_BUILDPACKAGE_HOOK_NAME environment variable (since dpkg 1.22.0).
Note: hooks can affect the build process, and cause build failures if their commands fail, so watch out for unintended consequences. Fr fr, be careful.
The current *hook-name*s supported are:
preinitinitprecleansourceโ getsDPKG_BUILDPACKAGE_HOOK_SOURCE_OPTIONSwith the space-separated lists of options that will be passed to thedpkg-sourcecall.buildโ getsDPKG_BUILDPACKAGE_HOOK_BUILD_TARGETwith the name of thedebian/rulesbuildtarget called. Before dpkg 1.22.7 the variable was only set if the target was called.binaryโ getsDPKG_BUILDPACKAGE_HOOK_BINARY_TARGETwith the name of thedebian/rulesbinarytarget called, but only if called.buildinfoโ getsDPKG_BUILDPACKAGE_HOOK_BUILDINFO_OPTIONSwith the space-separated lists of options that will be passed to thedpkg-genbuildinfocall.changesโ getsDPKG_BUILDPACKAGE_HOOK_CHANGES_OPTIONSwith the space-separated lists of options that will be passed to thedpkg-genchangescall.postcleancheckโ getsDPKG_BUILDPACKAGE_HOOK_CHECK_OPTIONSwith the space-separated lists of options that will be passed to the check command call.signdone
The hook-command supports the following substitution format string, which gets applied to it before execution:
%%โ a single%character.%aโ a boolean value (0or1), representing whether the following action is being performed.%pโ the source package name.%vโ the source package version.%sโ the source package version (without the epoch).%uโ the upstream version.
Supported since dpkg 1.17.6.
--buildinfo-file=filenameโ set the filename for the generated.buildinfofile.
Supported since dpkg 1.21.0.
--buildinfo-option=optโ pass option opt todpkg-genbuildinfo. Can be used multiple times.
Supported since dpkg 1.18.11.
--sign-backend=sign-backendโ specify an OpenPGP backend interface to use when invoking the sign-command.
The default is auto, where the best current backend available gets used. The specific OpenPGP backends supported, in order of preference, are:
sopโ any conforming Stateless OpenPGP (SOP) implementation, such assqop,rsop,gosop,hoporpgpainless-cli.sqโ from Sequoia-PGP.gpgโ from GnuPG.
Supported since dpkg 1.21.10.
-p,--sign-command=sign-commandโ whendpkg-buildpackageneeds to execute an OpenPGP backend command to sign a source control (.dsc) file, a.buildinfofile or a.changesfile, it runs sign-command (searching thePATHif necessary) instead of the default or auto-detected backend command. sign-command gets all the backend specific arguments according to the--sign-backendselected. sign-command should not contain spaces or any other shell metacharacters.
Support for long option since dpkg 1.18.8.
-k,--sign-keyid=key-idโ specify an OpenPGP key-ID (either a fingerprint or a user-ID) for the secret key to use when signing packages ๐
Support for long option since dpkg 1.21.10.
--sign-key=key-idโ deprecated since dpkg 1.23.8, replaced by--sign-keyid. Supported since dpkg 1.18.8.--sign-keyfile=key-fileโ specify an OpenPGP key-file containing the secret key to use when signing packages.
Note: for security reasons the key-file is best kept locked with a password. Please bestie ๐
Supported since dpkg 1.21.10.
-us,--unsigned-sourceโ do not sign the source package.
Support for long option since dpkg 1.18.8.
-ui,--unsigned-buildinfoโ do not sign the.buildinfofile.
Supported since dpkg 1.18.19.
-uc,--unsigned-changesโ do not sign the.buildinfoand.changesfiles.
Support for long option since dpkg 1.18.8.
--no-signโ do not sign any file โ this includes the source package, the.buildinfofile and the.changesfile. Nothing gets a signature, we're going fully anonymous ๐ซฅ
Supported since dpkg 1.18.20.
--force-signโ force the signing of the resulting files, regardless of-us,--unsigned-source,-ui,--unsigned-buildinfo,-uc,--unsigned-changesor other internal heuristics. It overrides the overrides โจ
Supported since dpkg 1.17.0.
-sn,-ss,-sA,-sk,-su,-sr,-sK,-sU,-sRโ passed unchanged todpkg-source. See its manual page.-i,--diff-ignore[=regex],-I,--tar-ignore[=pattern],-z,--compression-level=level,-Z,--compression=compressorโ passed unchanged todpkg-source. See its manual page.
Support for long options since dpkg 1.18.8.
--source-option=optโ pass option opt todpkg-source. Can be used multiple times.
Supported since dpkg 1.15.6.
--changes-file=filenameโ set the filename for the generated.changesfile.
Supported since dpkg 1.21.0.
--changes-option=optโ pass option opt todpkg-genchanges. Can be used multiple times.
Supported since dpkg 1.15.6.
--admindir=dir,--admindir dirโ change the location of the dpkg database. The default location is/var/lib/dpkg.
Supported since dpkg 1.14.0.
-?,--helpโ show the usage message and exit.--versionโ show the version and exit.
๐ ENVIRONMENT ๐
okay bestie, this is where dpkg-buildpackage reads the vibes from the world around it. There are two whole layers: the external env vars you can set yourself, and the internal ones the tool exports for the build. Letโs get into it. ๐ซถ
๐ External environment ๐
These are the ones you can set in your shell, CI, whatever โ the main character env vars. โจ
DEB_CHECK_COMMANDโ if itโs set, itโs the command used to check the.changesfile. The--check-commandoption overrides it. Supported since dpkg1.17.6. ๐DEB_SIGN_KEYIDโ if set, it signs the.changes,.buildinfoand.dscfiles. The--sign-keyidoption overrides it. Supported since dpkg1.17.2.DEB_SIGN_KEYFILEโ if set, it signs the.changes,.buildinfoand.dscfiles. The--sign-keyfileoption overrides it. Supported since dpkg1.21.10. ๐DEB_BUILD_OPTIONSโ this one is the big group-chat of build options, fr fr. If set, it holds a space-separated list of options that affect how some dpkg tools behave during package building, and might affect the package build process if the code indebian/ruleshonors them. Options can have parameters right after an equal sign (=). For options that support multiple parameters, those parameters are not separated by spaces โ spaces are reserved for separating options. The following are the options known and supported by dpkg tools; other options honored bydebian/rulesmight be defined by distribution-specific policies.parallel=Nโ thedebian/rulesin the packaging might use this option to set up the build process withNparallel jobs. Itโs overridden by the--jobsand--jobs-forceoptions. ๐ฅnocheckโdpkg-buildpackagewill ignore theDEB_CHECK_COMMANDvariable. Thedebian/rulesin the packaging is not expected to run test suites during the build.nooptโ ifdebian/rulescallsdpkg-buildflagsto set up the build flags, those flags will be set to not enable any optimizations.nostripโ thedebian/rulesin the packaging should ensure that objects do not get their debugging information stripped. Ifdebian/rulesincludes themk/buildtools.mkmake fragment, theSTRIPmake variable will respect this option. ๐terseโdpkg-buildpackagewill append the--no-print-directorymake(1)flag to theMAKEFLAGSenvironment variable. Thedebian/rulesin the packaging should reduce verbosity, while not being completely quiet. ๐คซhardening=feature-spec,reproducible=feature-spec,abi=feature-spec,future=feature-spec,qa=feature-spec,optimize=feature-spec,sanitize=feature-specโ these are feature areas that control build flag features. Seedpkg-buildflags(1)for further details. โญ
DEB_BUILD_PROFILESโ if set, itโs used as the active build profile(s) for the package being built. Itโs a space separated list of profile names, without any exclamation marks. The-Poption overrides it. Supported since dpkg1.17.2. ๐ธDPKG_COLORSโ sets the color mode. The currently accepted values are:auto(default),alwaysandnever. Supported since dpkg1.18.5. ๐DPKG_NLSโ if set, it decides whether to activate Native Language Support, also known as internationalization (or i18n) support. The accepted values are:0and1(default). Supported since dpkg1.19.0. โจ
๐ฆ Internal environment ๐ฆ
Now for the backstage variables. Even though dpkg-buildpackage exports some variables, debian/rules should not rely on their presence, and should instead use the respective interface to retrieve the needed values โ because that file is the main entry point to build packages, and running it standalone should be supported. iykyk. ๐
DEB_BUILD_*,DEB_HOST_*,DEB_TARGET_*โdpkg-architectureis called with the-aand-tparameters forwarded. Any variable that is output by its-soption is integrated in the build environment.DEB_RULES_REQUIRES_ROOTโ this variable is set to the value obtained from theRules-Requires-Rootfield, thedpkg-build-apilevel or from the command-line. When set, it will be a valid value for theRules-Requires-Rootfield. It is used to notifydebian/ruleswhether therootless-builds.txtspecification is supported.DEB_GAIN_ROOT_CMDโ this variable is set togain-root-commandwhen the fieldRules-Requires-Rootis set to a value different tonoandbinary-targets.SOURCE_DATE_EPOCHโ this variable is set to the Unix timestamp since the epoch of the latest entry indebian/changelog, if it is not already defined. โณ
๐ FILES ๐
/etc/dpkg/buildpackage.confโ system wide configuration file. ๐๏ธ$XDG_CONFIG_HOME/dpkg/buildpackage.conf,$HOME/.config/dpkg/buildpackage.confโ user configuration file.
๐ฅ NOTES ๐ฅ
A couple of glow-ups and receipts you should know about. ๐
๐ Compiler flags are no longer exported ๐
Between dpkg 1.14.17 and 1.16.1, dpkg-buildpackage exported compiler flags (CFLAGS, CXXFLAGS, FFLAGS, CPPFLAGS and LDFLAGS) with values as returned by dpkg-buildflags. That is no longer the case. Not me finding out the old way. ๐ญ
๐ฏ Default build targets ๐ฏ
dpkg-buildpackage is using the build-arch and build-indep targets since dpkg 1.16.2. Before dpkg 1.22.7, there was code to try to detect the missing targets and fall back on the build target. Those targets are thus mandatory. No cap. ๐ซถ
๐ SECURITY ๐
Building binary or source packages should only be performed over trusted source data. Thatโs the whole vibe check: trust the source, bestie. ๐
๐ BUGS ๐
It should be possible to specify spaces and shell metacharacters and initial arguments for gain-root-command and sign-command. Thatโs the bug note โ act accordingly. ๐
๐ SEE ALSO ๐
/usr/share/doc/dpkg/spec/rootless-builds.txtdpkg-source(1)dpkg-architecture(1)dpkg-buildflags(1)dpkg-genbuildinfo(1)dpkg-genchanges(1)fakeroot(1)lintian(1)SOP <https://datatracker.ietf.org/doc/draft-dkg-openpgp-stateless-cli/>sq(1)gpg(1)
Thatโs the whole page, bestie โ source: dpkg-buildpackage(1), version 1.23.11-dirty, dated 2026-09-09. Slay. ๐โจ
๐ฆ where this page comes from
- arch rolling: dpkg 1.23.11-1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms