1dpkg-buildpackage(1) dpkg suite dpkg-buildpackage(1)
2
3
4
6 dpkg-buildpackage - build binary or source packages from sources
7
9 dpkg-buildpackage [option...]
10
12 dpkg-buildpackage is a program that automates the process of building a
13 Debian package. It consists of the following steps:
14
15 1. It prepares the build environment by setting various environment
16 variables (see ENVIRONMENT), runs the init hook, and calls
17 dpkg-source --before-build (unless -T or --target has been used).
18
19 2. It checks that the build-dependencies and build-conflicts are
20 satisfied (unless -d or --no-check-builddeps is specified).
21
22 3. If one or more specific targets have been selected with the -T or
23 --target option, it calls those targets and stops here. Otherwise it
24 runs the preclean hook and calls fakeroot debian/rules clean to
25 clean the build-tree (unless -nc or --no-pre-clean is specified).
26
27 4. It runs the source hook and calls dpkg-source -b to generate the
28 source package (if a source build has been requested with --build or
29 equivalent options).
30
31 5. It runs the build hook and calls debian/rules build-target, then
32 runs the binary hook followed by fakeroot debian/rules binary-target
33 (unless a source-only build has been requested with --build=source
34 or equivalent options). Note that build-target and binary-target
35 are either build and binary (default case, or if an any and all
36 build has been requested with --build or equivalent options), or
37 build-arch and binary-arch (if an any and not all build has been
38 requested with --build or equivalent options), or build-indep and
39 binary-indep (if an all and not any build has been requested with
40 --build or equivalent options).
41
42 6. It runs the buildinfo hook and calls dpkg-genbuildinfo to generate a
43 .buildinfo file. Several dpkg-buildpackage options are forwarded to
44 dpkg-genbuildinfo.
45
46 7. It runs the changes hook and calls dpkg-genchanges to generate a
47 .changes file. The name of the .changes file will depend on the
48 type of build and will be as specific as necessary but not more; for
49 a build that includes any the name will be source-name_binary-
50 version_arch.changes, or otherwise for a build that includes all the
51 name will be source-name_binary-version_all.changes, or otherwise
52 for a build that includes source the name will be source-
53 name_source-version_source.changes. Many dpkg-buildpackage options
54 are forwarded to dpkg-genchanges.
55
56 8. It runs the postclean hook and if -tc or --post-clean is specified,
57 it will call fakeroot debian/rules clean again.
58
59 9. It calls dpkg-source --after-build.
60
61 10.
62 It runs the check hook and calls a package checker for the .changes
63 file (if a command is specified in DEB_CHECK_COMMAND or with
64 --check-command).
65
66 11.
67 It runs the sign hook and calls gpg2 or gpg (as long as it is not an
68 UNRELEASED build, or --no-sign is specified) to sign the .dsc file
69 (if any, unless -us or --unsigned-source is specified), the
70 .buildinfo file (unless -ui, --unsigned-buildinfo, -uc or
71 --unsigned-changes is specified) and the .changes file (unless -uc
72 or --unsigned-changes is specified).
73
74 12.
75 It runs the done hook.
76
78 All long options can be specified both on the command line and in the
79 dpkg-buildpackage system and user configuration files. Each line in
80 the configuration file is either an option (exactly the same as the
81 command line option but without leading hyphens) or a comment (if it
82 starts with a ‘#’).
83
84
85 --build=type
86 Specifies the build type from a comma-separated list of
87 components (since dpkg 1.18.5). Passed to dpkg-genchanges.
88
89 The allowed values are:
90
91 source Builds the source package. Note: when using this value
92 standalone and if what you want is simply to (re-)build
93 the source package from a clean source tree, using
94 dpkg-source directly is always a better option as it does
95 not require any build dependencies to be installed which
96 are otherwise needed to be able to call the clean target.
97
98 any Builds the architecture specific binary packages.
99
100 all Builds the architecture independent binary packages.
101
102 binary Builds the architecture specific and independent binary
103 packages. This is an alias for any,all.
104
105 full Builds everything. This is an alias for source,any,all,
106 and the same as the default case when no build option is
107 specified.
108
109 -g Equivalent to --build=source,all (since dpkg 1.17.11).
110
111 -G Equivalent to --build=source,any (since dpkg 1.17.11).
112
113 -b Equivalent to --build=binary or --build=any,all.
114
115 -B Equivalent to --build=any.
116
117 -A Equivalent to --build=all.
118
119 -S Equivalent to --build=source.
120
121 -F Equivalent to --build=full, --build=source,binary or
122 --build=source,any,all (since dpkg 1.15.8).
123
124 --target=target[,...]
125 --target target[,...]
126 -T, --rules-target=target[,...]
127 Calls debian/rules target once per target specified, after
128 having setup the build environment (except for calling
129 dpkg-source --before-build), and stops the package build process
130 here (since dpkg 1.15.0, long option since dpkg 1.18.8, multi-
131 target support since dpkg 1.18.16). If --as-root is also given,
132 then the command is executed as root (see --root-command). Note
133 that known targets that are required to be run as root do not
134 need this option (i.e. the clean, binary, binary-arch and
135 binary-indep targets).
136
137 --as-root
138 Only meaningful together with --target (since dpkg 1.15.0).
139 Requires that the target be run with root rights.
140
141 -si
142 -sa
143 -sd
144 -vversion
145 -Cchanges-description
146 -m, --release-by=maintainer-address
147 -e, --build-by=maintainer-address
148 Passed unchanged to dpkg-genchanges. See its manual page.
149
150 -a, --host-arch architecture
151 Specify the Debian architecture we build for (long option since
152 dpkg 1.17.17). The architecture of the machine we build on is
153 determined automatically, and is also the default for the host
154 machine.
155
156 -t, --host-type gnu-system-type
157 Specify the GNU system type we build for (long option since dpkg
158 1.17.17). It can be used in place of --host-arch or as a
159 complement to override the default GNU system type of the host
160 Debian architecture.
161
162 --target-arch architecture
163 Specify the Debian architecture the binaries built will build
164 for (since dpkg 1.17.17). The default value is the host
165 machine.
166
167 --target-type gnu-system-type
168 Specify the GNU system type the binaries built will build for
169 (since dpkg 1.17.17). It can be used in place of --target-arch
170 or as a complement to override the default GNU system type of
171 the target Debian architecture.
172
173 -P, --build-profiles=profile[,...]
174 Specify the profile(s) we build, as a comma-separated list
175 (since dpkg 1.17.2, long option since dpkg 1.18.8). The default
176 behavior is to build for no specific profile. Also sets them (as
177 a space separated list) as the DEB_BUILD_PROFILES environment
178 variable which allows, for example, debian/rules files to use
179 this information for conditional builds.
180
181 -j, --jobs[=jobs|auto]
182 Number of jobs allowed to be run simultaneously, number of jobs
183 matching the number of online processors if auto is specified
184 (since dpkg 1.17.10), or unlimited number if jobs is not
185 specified, equivalent to the make(1) option of the same name
186 (since dpkg 1.14.7, long option since dpkg 1.18.8). Will add
187 itself to the MAKEFLAGS environment variable, which should cause
188 all subsequent make invocations to inherit the option, thus
189 forcing the parallel setting on the packaging (and possibly the
190 upstream build system if that uses make) regardless of their
191 support for parallel builds, which might cause build failures.
192 Also adds parallel=jobs or parallel to the DEB_BUILD_OPTIONS
193 environment variable which allows debian/rules files to use this
194 information for their own purposes. The -j value will override
195 the parallel=jobs or parallel option in the DEB_BUILD_OPTIONS
196 environment variable. Note that the auto value will get
197 replaced by the actual number of currently active processors,
198 and as such will not get propagated to any child process. If the
199 number of online processors cannot be inferred then the code
200 will fallback to using serial execution (since dpkg 1.18.15),
201 although this should only happen on exotic and unsupported
202 systems.
203
204 -J, --jobs-try[=jobs|auto]
205 This option (since dpkg 1.18.2, long option since dpkg 1.18.8)
206 is equivalent to the -j option except that it does not set the
207 MAKEFLAGS environment variable, and as such it is safer to use
208 with any package including those that are not parallel-build
209 safe.
210
211 auto is the default behavior (since dpkg 1.18.11). Setting the
212 number of jobs to 1 will restore a serial behavior.
213
214 -D, --check-builddeps
215 Check build dependencies and conflicts; abort if unsatisfied
216 (long option since dpkg 1.18.8). This is the default behavior.
217
218 -d, --no-check-builddeps
219 Do not check build dependencies and conflicts (long option since
220 dpkg 1.18.8).
221
222 --ignore-builtin-builddeps
223 Do not check built-in build dependencies and conflicts (since
224 dpkg 1.18.2). These are the distribution specific implicit
225 build dependencies usually required in a build environment, the
226 so called Build-Essential package set.
227
228 --rules-requires-root
229 Do not honor the Rules-Requires-Root field, falling back to its
230 legacy default value (since dpkg 1.19.1).
231
232 -nc, --no-pre-clean
233 Do not clean the source tree before building (long option since
234 dpkg 1.18.8). Implies -b if nothing else has been selected
235 among -F, -g, -G, -B, -A or -S. Implies -d with -S (since dpkg
236 1.18.0).
237
238 --pre-clean
239 Clean the source tree before building (since dpkg 1.18.8). This
240 is the default behavior.
241
242 -tc, --post-clean
243 Clean the source tree (using gain-root-command debian/rules
244 clean) after the package has been built (long option since dpkg
245 1.18.8).
246
247 --no-post-clean
248 Do not clean the source tree after the package has been built
249 (since dpkg 1.19.1). This is the default behavior.
250
251 -r, --root-command=gain-root-command
252 When dpkg-buildpackage needs to execute part of the build
253 process as root, it prefixes the command it executes with gain-
254 root-command if one has been specified (long option since dpkg
255 1.18.8). Otherwise, if none has been specified, fakeroot will
256 be used by default, if the command is present. gain-root-
257 command should start with the name of a program on the PATH and
258 will get as arguments the name of the real command to run and
259 the arguments it should take. gain-root-command can include
260 parameters (they must be space-separated) but no shell
261 metacharacters. gain-root-command might typically be fakeroot,
262 sudo, super or really. su is not suitable, since it can only
263 invoke the user's shell with -c instead of passing arguments
264 individually to the command to be run.
265
266 -R, --rules-file=rules-file
267 Building a Debian package usually involves invoking debian/rules
268 as a command with several standard parameters (since dpkg
269 1.14.17, long option since dpkg 1.18.8). With this option it's
270 possible to use another program invocation to build the package
271 (it can include space separated parameters). Alternatively it
272 can be used to execute the standard rules file with another make
273 program (for example by using /usr/local/bin/make -f
274 debian/rules as rules-file).
275
276 --check-command=check-command
277 Command used to check the .changes file itself and any artifact
278 built referenced in the file (since dpkg 1.17.6). The command
279 should take the .changes pathname as an argument. This command
280 will usually be lintian.
281
282 --check-option=opt
283 Pass option opt to the check-command specified with
284 DEB_CHECK_COMMAND or --check-command (since dpkg 1.17.6). Can
285 be used multiple times.
286
287 --hook-hook-name=hook-command
288 Set the specified shell code hook-command as the hook hook-name,
289 which will run at the times specified in the run steps (since
290 dpkg 1.17.6). The hooks will always be executed even if the
291 following action is not performed (except for the binary hook).
292 All the hooks will run in the unpacked source directory.
293
294 Note: Hooks can affect the build process, and cause build
295 failures if their commands fail, so watch out for unintended
296 consequences.
297
298 The current hook-name supported are:
299
300 init preclean source build binary buildinfo changes postclean
301 check sign done
302
303 The hook-command supports the following substitution format
304 string, which will get applied to it before execution:
305
306
307 %% A single % character.
308
309 %a A boolean value (0 or 1), representing whether the
310 following action is being performed.
311
312 %p The source package name.
313
314 %v The source package version.
315
316 %s The source package version (without the epoch).
317
318 %u The upstream version.
319
320 --buildinfo-option=opt
321 Pass option opt to dpkg-genbuildinfo (since dpkg 1.18.11). Can
322 be used multiple times.
323
324 -p, --sign-command=sign-command
325 When dpkg-buildpackage needs to execute GPG to sign a source
326 control (.dsc) file or a .changes file it will run sign-command
327 (searching the PATH if necessary) instead of gpg2 or gpg (long
328 option since dpkg 1.18.8). sign-command will get all the
329 arguments that gpg2 or gpg would have gotten. sign-command
330 should not contain spaces or any other shell metacharacters.
331
332 -k, --sign-key=key-id
333 Specify a key-ID to use when signing packages (long option since
334 dpkg 1.18.8).
335
336 -us, --unsigned-source
337 Do not sign the source package (long option since dpkg 1.18.8).
338
339 -ui, --unsigned-buildinfo
340 Do not sign the .buildinfo file (since dpkg 1.18.19).
341
342 -uc, --unsigned-changes
343 Do not sign the .buildinfo and .changes files (long option since
344 dpkg 1.18.8).
345
346 --no-sign
347 Do not sign any file, this includes the source package, the
348 .buildinfo file and the .changes file (since dpkg 1.18.20).
349
350 --force-sign
351 Force the signing of the resulting files (since dpkg 1.17.0),
352 regardless of -us, --unsigned-source, -ui, --unsigned-buildinfo,
353 -uc, --unsigned-changes or other internal heuristics.
354
355 -sn
356 -ss
357 -sA
358 -sk
359 -su
360 -sr
361 -sK
362 -sU
363 -sR
364 -i, --diff-ignore[=regex]
365 -I, --tar-ignore[=pattern]
366 -z, --compression-level=level
367 -Z, --compression=compressor
368 Passed unchanged to dpkg-source. See its manual page.
369
370 --source-option=opt
371 Pass option opt to dpkg-source (since dpkg 1.15.6). Can be used
372 multiple times.
373
374 --changes-option=opt
375 Pass option opt to dpkg-genchanges (since dpkg 1.15.6). Can be
376 used multiple times.
377
378 --admindir=dir
379 --admindir dir
380 Change the location of the dpkg database (since dpkg 1.14.0).
381 The default location is /var/lib/dpkg.
382
383 -?, --help
384 Show the usage message and exit.
385
386 --version
387 Show the version and exit.
388
390 External environment
391 DEB_CHECK_COMMAND
392 If set, it will be used as the command to check the .changes
393 file (since dpkg 1.17.6). Overridden by the --check-command
394 option.
395
396 DEB_SIGN_KEYID
397 If set, it will be used to sign the .changes and .dsc files
398 (since dpkg 1.17.2). Overridden by the --sign-key option.
399
400 DEB_BUILD_OPTIONS
401 If set, it will contain a space-separated list of options that
402 might affect the build process in debian/rules, and the behavior
403 of some dpkg commands.
404
405 With nocheck the DEB_CHECK_COMMAND variable will be ignored.
406 With parallel=N the parallel jobs will be set to N, overridden
407 by the --jobs-try option.
408
409 DEB_BUILD_PROFILES
410 If set, it will be used as the active build profile(s) for the
411 package being built (since dpkg 1.17.2). It is a space
412 separated list of profile names. Overridden by the -P option.
413
414 DPKG_COLORS
415 Sets the color mode (since dpkg 1.18.5). The currently accepted
416 values are: auto (default), always and never.
417
418 DPKG_NLS
419 If set, it will be used to decide whether to activate Native
420 Language Support, also known as internationalization (or i18n)
421 support (since dpkg 1.19.0). The accepted values are: 0 and 1
422 (default).
423
424
425 Internal environment
426 Even if dpkg-buildpackage exports some variables, debian/rules should
427 not rely on their presence and should instead use the respective
428 interface to retrieve the needed values, because that file is the main
429 entry point to build packages and running it standalone should be
430 supported.
431
432
433 DEB_BUILD_*
434 DEB_HOST_*
435 DEB_TARGET_*
436 dpkg-architecture is called with the -a and -t parameters
437 forwarded. Any variable that is output by its -s option is
438 integrated in the build environment.
439
440 DEB_RULES_REQUIRES_ROOT
441 This variable is set to the value obtained from the
442 Rules-Requires-Root field or from the command-line. When set,
443 it will be a valid value for the Rules-Requires-Root field. It
444 is used to notify debian/rules whether the rootless-builds.txt
445 specification is supported.
446
447 DEB_GAIN_ROOT_CMD
448 This variable is set to gain-root-command when the field
449 Rules-Requires-Root is set to a value different to no and
450 binary-targets.
451
452 SOURCE_DATE_EPOCH
453 This variable is set to the Unix timestamp since the epoch of
454 the latest entry in debian/changelog, if it is not already
455 defined.
456
458 /etc/dpkg/buildpackage.conf
459 System wide configuration file
460
461 $XDG_CONFIG_HOME/dpkg/buildpackage.conf or
462 $HOME/.config/dpkg/buildpackage.conf
463 User configuration file.
464
466 Compiler flags are no longer exported
467 Between dpkg 1.14.17 and 1.16.1, dpkg-buildpackage exported compiler
468 flags (CFLAGS, CXXFLAGS, FFLAGS, CPPFLAGS and LDFLAGS) with values as
469 returned by dpkg-buildflags. This is no longer the case.
470
471 Default build targets
472 dpkg-buildpackage is using the build-arch and build-indep targets since
473 dpkg 1.16.2. Those targets are thus mandatory. But to avoid breakages
474 of existing packages, and ease the transition, if the source package
475 does not build both architecture independent and dependent binary
476 packages (since dpkg 1.18.8) it will fallback to use the build target
477 if make -f debian/rules -qn build-target returns 2 as exit code.
478
480 It should be possible to specify spaces and shell metacharacters and
481 initial arguments for gain-root-command and sign-command.
482
484 dpkg-source(1), dpkg-architecture(1), dpkg-buildflags(1),
485 dpkg-genbuildinfo(1), dpkg-genchanges(1), fakeroot(1), lintian(1),
486 gpg2(1), gpg(1).
487
488
489
4901.19.7 2019-06-03 dpkg-buildpackage(1)