Linux "dpkg-buildpackage" Command Line Options and Examples
build binary or source packages from sources

dpkg-buildpackage is a program that automates the process of building a Debian package. It consists of the following steps: 1. It prepares the build environment by setting various environment variables (see ENVIRONMENT), runs the init hook, and calls dpkg-source --before-build (unless -T or --target has been used).


Usage:

dpkg-buildpackage [option...]






Command Line Options:

--build
Specifies the build type from a comma-separated list of components (since dpkg 1.18.5). Passed to dpkg-genchanges.The allowed values are:source Builds the source package. Note: when using this value standalone and if what you want is simply to (re-)build thesource package, using dpkg-source is always better as it does not require any build dependencies to be installed to beable 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 for any,all.full Builds everything. This is an alias for source,any,all, and the same as the default case when no build option isspecified.
dpkg-buildpackage --build ...
-g
Equivalent to --build=source,all (since dpkg 1.17.11).
dpkg-buildpackage -g ...
-G
Equivalent to --build=source,any (since dpkg 1.17.11).
dpkg-buildpackage -G ...
-b
Equivalent to --build=binary or --build=any,all.
dpkg-buildpackage -b ...
-B
Equivalent to --build=any.
dpkg-buildpackage -B ...
-A
Equivalent to --build=all.
dpkg-buildpackage -A ...
-S
Equivalent to --build=source.
dpkg-buildpackage -S ...
-F
Equivalent to --build=full, --build=source,binary or --build=source,any,all (since dpkg 1.15.8).
dpkg-buildpackage -F ...
-T
Calls debian/rules target once per target specified, after having setup the build environment (except for calling dpkg-source
dpkg-buildpackage -T ...
--as-root
Only meaningful together with --target (since dpkg 1.15.0). Requires that the target be run with root rights.
dpkg-buildpackage --as-root ...
-m
--release-by=maintainer-address
dpkg-buildpackage -m ...
-e
Passed unchanged to dpkg-genchanges. See its manual page.
dpkg-buildpackage -e ...
-a
Specify the Debian architecture we build for (long option since dpkg 1.17.17). The architecture of the machine we build on isdetermined automatically, and is also the default for the host machine.
dpkg-buildpackage -a ...
-t
Specify the GNU system type we build for (long option since dpkg 1.17.17). It can be used in place of --host-arch or as acomplement to override the default GNU system type of the host Debian architecture.
dpkg-buildpackage -t ...
--target-arch
Specify the Debian architecture the binaries built will build for (since dpkg 1.17.17). The default value is the hostmachine.
dpkg-buildpackage --target-arch ...
--target-type
Specify the GNU system type the binaries built will build for (since dpkg 1.17.17). It can be used in place of --target-archor as a complement to override the default GNU system type of the target Debian architecture.
dpkg-buildpackage --target-type ...
-P
Specify the profile(s) we build, as a comma-separated list (since dpkg 1.17.2, long option since dpkg 1.18.8). The defaultbehavior is to build for no specific profile. Also sets them (as a space separated list) as the DEB_BUILD_PROFILES environmentvariable which allows, for example, debian/rules files to use this information for conditional builds.
dpkg-buildpackage -P ...
-j
Number of jobs allowed to be run simultaneously, number of jobs matching the number of online processors if auto is specified(since dpkg 1.17.10), or unlimited number if jobs is not specified, equivalent to the make(1) option of the same name (sincedpkg 1.14.7, long option since dpkg 1.18.8). Will add itself to the MAKEFLAGS environment variable, which should cause allsubsequent make invocations to inherit the option, thus forcing the parallel setting on the packaging (and possibly theupstream build system if that uses make) regardless of their support for parallel builds, which might cause build failures.Also adds parallel=jobs or parallel to the DEB_BUILD_OPTIONS environment variable which allows debian/rules files to use thisinformation for their own purposes. The -j value will override the parallel=jobs or parallel option in the DEB_BUILD_OPTIONSenvironment variable. Note that the auto value will get replaced by the actual number of currently active processors, and assuch will not get propagated to any child process. If the number of online processors cannot be inferred then the code willfallback to using serial execution (since dpkg 1.18.15), although this should only happen on exotic and unsupported systems.
dpkg-buildpackage -j ...
-J
This option (since dpkg 1.18.2, long option since dpkg 1.18.8) is equivalent to the -j option except that it does not set theMAKEFLAGS environment variable, and as such it is safer to use with any package including those that are not parallel-buildsafe.auto is the default behavior (since dpkg 1.18.11). Setting the number of jobs to 1 will restore a serial behavior.
dpkg-buildpackage -J ...
-D
Check build dependencies and conflicts; abort if unsatisfied (long option since dpkg 1.18.8). This is the default behavior.
dpkg-buildpackage -D ...
-d
Do not check build dependencies and conflicts (long option since dpkg 1.18.8).
dpkg-buildpackage -d ...
--ignore-builtin-builddeps
Do not check built-in build dependencies and conflicts (since dpkg 1.18.2). These are the distribution specific implicitbuild dependencies usually required in a build environment, the so called Build-Essential package set.
dpkg-buildpackage --ignore-builtin-builddeps ...
-nc
Do not clean the source tree (long option since dpkg 1.18.8). Implies -b if nothing else has been selected among -F, -g, -G,
dpkg-buildpackage -nc ...
--pre-clean
Clean the source tree before building (since dpkg 1.18.8).
dpkg-buildpackage --pre-clean ...
-tc
Clean the source tree (using gain-root-command debian/rules clean) after the package has been built (long option since dpkg1.18.8).
dpkg-buildpackage -tc ...
-r
When dpkg-buildpackage needs to execute part of the build process as root, it prefixes the command it executes with gain-root-command if one has been specified (long option since dpkg 1.18.8). Otherwise, if none has been specified, fakeroot will beused by default, if the command is present. gain-root-command should start with the name of a program on the PATH and willget as arguments the name of the real command to run and the arguments it should take. gain-root-command can includeparameters (they must be space-separated) but no shell metacharacters. gain-root-command might typically be fakeroot, sudo,super or really. su is not suitable, since it can only invoke the user's shell with -c instead of passing argumentsindividually to the command to be run.
dpkg-buildpackage -r ...
-R
Building a Debian package usually involves invoking debian/rules as a command with several standard parameters (since dpkg1.14.17, long option since dpkg 1.18.8). With this option it's possible to use another program invocation to build thepackage (it can include space separated parameters). Alternatively it can be used to execute the standard rules file withanother make program (for example by using /usr/local/bin/make -f debian/rules as rules-file).
dpkg-buildpackage -R ...
--check-command
Command used to check the .changes file itself and any artifact built referenced in the file (since dpkg 1.17.6). The commandshould take the .changes pathname as an argument. This command will usually be lintian.
dpkg-buildpackage --check-command ...
--check-option
Pass option opt to the check-command specified with DEB_CHECK_COMMAND or --check-command (since dpkg 1.17.6). Can be usedmultiple times.
dpkg-buildpackage --check-option ...
--hook-hook-name
Set the specified shell code hook-command as the hook hook-name, which will run at the times specified in the run steps (sincedpkg 1.17.6). The hooks will always be executed even if the following action is not performed (except for the binary hook).All the hooks will run in the unpacked source directory.Note: Hooks can affect the build process, and cause build failures if their commands fail, so watch out for unintendedconsequences.The current hook-name supported are:init preclean source build binary buildinfo changes postclean check sign doneThe hook-command supports the following substitution format string, which will get applied to it before execution:%% A single % character.%a A boolean value (0 or 1), 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.
dpkg-buildpackage --hook-hook-name ...
--buildinfo-option
Pass option opt to dpkg-genbuildinfo (since dpkg 1.18.11). Can be used multiple times.
dpkg-buildpackage --buildinfo-option ...
-p
When dpkg-buildpackage needs to execute GPG to sign a source control (.dsc) file or a .changes file it will run sign-command(searching the PATH if necessary) instead of gpg2 or gpg (long option since dpkg 1.18.8). sign-command will get all thearguments that gpg2 or gpg would have gotten. sign-command should not contain spaces or any other shell metacharacters.
dpkg-buildpackage -p ...
-k
Specify a key-ID to use when signing packages (long option since dpkg 1.18.8).
dpkg-buildpackage -k ...
-us
Do not sign the source package (long option since dpkg 1.18.8).
dpkg-buildpackage -us ...
-ui
Do not sign the .buildinfo file (since dpkg 1.18.19).
dpkg-buildpackage -ui ...
-uc
Do not sign the .buildinfo and .changes files (long option since dpkg 1.18.8).
dpkg-buildpackage -uc ...
--no-sign
Do not sign any file, this includes the source package, the .buildinfo file and the .changes file (since dpkg 1.18.20).
dpkg-buildpackage --no-sign ...
--force-sign
Force the signing of the resulting files (since dpkg 1.17.0), regardless of -us, --unsigned-source, -ui, --unsigned-buildinfo,
dpkg-buildpackage --force-sign ...
-i
--diff-ignore[=regex]
dpkg-buildpackage -i ...
-I
--tar-ignore[=pattern]
dpkg-buildpackage -I ...
-z
--compression-level=level
dpkg-buildpackage -z ...
-Z
Passed unchanged to dpkg-source. See its manual page.
dpkg-buildpackage -Z ...
--source-option
Pass option opt to dpkg-source (since dpkg 1.15.6). Can be used multiple times.
dpkg-buildpackage --source-option ...
--changes-option
Pass option opt to dpkg-genchanges (since dpkg 1.15.6). Can be used multiple times.
dpkg-buildpackage --changes-option ...
--admindir
Change the location of the dpkg database (since dpkg 1.14.0). The default location is /var/lib/dpkg.
dpkg-buildpackage --admindir ...
-?
Show the usage message and exit.
dpkg-buildpackage -? ...
--version
Show the version and exit.ENVIRONMENTExternal environmentDEB_CHECK_COMMANDIf set, it will be used as the command to check the .changes file (since dpkg 1.17.6). Overridden by the --check-commandoption.DEB_SIGN_KEYIDIf set, it will be used to sign the .changes and .dsc files (since dpkg 1.17.2). Overridden by the --sign-key option.DEB_BUILD_OPTIONSIf set, it will contain a space-separated list of options that might affect the build process in debian/rules, and thebehavior of some dpkg commands.With nocheck the DEB_CHECK_COMMAND variable will be ignored. With parallel=N the parallel jobs will be set to N, overriddenby the --jobs-try option.DEB_BUILD_PROFILESIf set, it will be used as the active build profile(s) for the package being built (since dpkg 1.17.2). It is a spaceseparated list of profile names. Overridden by the -P option.DPKG_COLORSSets the color mode (since dpkg 1.18.5). The currently accepted values are: auto (default), always and never.Internal environmentEven if dpkg-buildpackage exports some variables, debian/rules should not rely on their presence and should instead use therespective interface to retrieve the needed values, because that file is the main entry point to build packages and running itstandalone should be supported.DEB_BUILD_*DEB_HOST_*DEB_TARGET_*dpkg-architecture is called with the -a and -t parameters forwarded. Any variable that is output by its -s option isintegrated in the build environment.DEB_RULES_REQUIRES_ROOTThis variable is set to the value obtained from the Rules-Requires-Root field or from the command-line. When set, it will bea valid value for the Rules-Requires-Root field. It is used to notify debian/rules whether the rootless-builds.txtspecification is supported.DEB_GAIN_ROOT_CMDThis variable is set to gain-root-command when the field Rules-Requires-Root is set to a value different to no and binary-targets.SOURCE_DATE_EPOCHThis variable is set to the Unix timestamp since the epoch of the latest entry in debian/changelog, if it is not alreadydefined.FILES/etc/dpkg/buildpackage.confSystem wide configuration file$XDG_CONFIG_HOME/dpkg/buildpackage.conf or$HOME/.config/dpkg/buildpackage.confUser configuration file.NOTESCompiler flags are no longer exportedBetween dpkg 1.14.17 and 1.16.1, dpkg-buildpackage exported compiler flags (CFLAGS, CXXFLAGS, FFLAGS, CPPFLAGS and LDFLAGS) withvalues as returned by dpkg-buildflags. This is no longer the case.Default build targetsdpkg-buildpackage is using the build-arch and build-indep targets since dpkg 1.16.2. Those targets are thus mandatory. But to avoidbreakages of existing packages, and ease the transition, if the source package does not build both architecture independent anddependent binary packages (since dpkg 1.18.8) it will fallback to use the build target if make -f debian/rules -qn build-targetreturns 2 as exit code.BUGSIt should be possible to specify spaces and shell metacharacters and initial arguments for gain-root-command and sign-command.
dpkg-buildpackage --version ...