1dpkg-buildpackage(1)              dpkg suite              dpkg-buildpackage(1)
2
3
4

NAME

6       dpkg-buildpackage - build binary or source packages from sources
7

SYNOPSIS

9       dpkg-buildpackage [option...]
10

DESCRIPTION

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

OPTIONS

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, using dpkg-source is always better as
94                     it   does  not  require  any  build  dependencies  to  be
95                     installed to be able to call the clean target.
96
97              any    Builds the architecture specific binary packages.
98
99              all    Builds the architecture independent binary packages.
100
101              binary Builds the architecture specific and  independent  binary
102                     packages.  This is an alias for any,all.
103
104              full   Builds  everything.  This is an alias for source,any,all,
105                     and the same as the default case when no build option  is
106                     specified.
107
108       -g     Equivalent to --build=source,all (since dpkg 1.17.11).
109
110       -G     Equivalent to --build=source,any (since dpkg 1.17.11).
111
112       -b     Equivalent to --build=binary or --build=any,all.
113
114       -B     Equivalent to --build=any.
115
116       -A     Equivalent to --build=all.
117
118       -S     Equivalent to --build=source.
119
120       -F     Equivalent    to    --build=full,    --build=source,binary    or
121              --build=source,any,all (since dpkg 1.15.8).
122
123       --target=target[,...]
124       --target target[,...]
125       -T, --rules-target=target[,...]
126              Calls debian/rules  target  once  per  target  specified,  after
127              having   setup   the   build  environment  (except  for  calling
128              dpkg-source --before-build), and stops the package build process
129              here  (since  dpkg 1.15.0, long option since dpkg 1.18.8, multi-
130              target support since dpkg 1.18.16).  If --as-root is also given,
131              then the command is executed as root (see --root-command).  Note
132              that known targets that are required to be run as  root  do  not
133              need  this  option  (i.e.  the  clean,  binary,  binary-arch and
134              binary-indep targets).
135
136       --as-root
137              Only meaningful together  with  --target  (since  dpkg  1.15.0).
138              Requires that the target be run with root rights.
139
140       -si
141       -sa
142       -sd
143       -vversion
144       -Cchanges-description
145       -m, --release-by=maintainer-address
146       -e, --build-by=maintainer-address
147              Passed unchanged to dpkg-genchanges. See its manual page.
148
149       -a, --host-arch architecture
150              Specify  the Debian architecture we build for (long option since
151              dpkg 1.17.17).  The architecture of the machine we build  on  is
152              determined  automatically,  and is also the default for the host
153              machine.
154
155       -t, --host-type gnu-system-type
156              Specify the GNU system type we build for (long option since dpkg
157              1.17.17).   It  can  be  used  in  place  of --host-arch or as a
158              complement to override the default GNU system type of  the  host
159              Debian architecture.
160
161       --target-arch architecture
162              Specify  the  Debian  architecture the binaries built will build
163              for (since  dpkg  1.17.17).   The  default  value  is  the  host
164              machine.
165
166       --target-type gnu-system-type
167              Specify  the  GNU  system type the binaries built will build for
168              (since dpkg 1.17.17).  It can be used in place of  --target-arch
169              or  as  a  complement to override the default GNU system type of
170              the target Debian architecture.
171
172       -P, --build-profiles=profile[,...]
173              Specify the profile(s)  we  build,  as  a  comma-separated  list
174              (since dpkg 1.17.2, long option since dpkg 1.18.8).  The default
175              behavior is to build for no specific profile. Also sets them (as
176              a  space  separated  list) as the DEB_BUILD_PROFILES environment
177              variable which allows, for example, debian/rules  files  to  use
178              this information for conditional builds.
179
180       -j, --jobs[=jobs|auto]
181              Number  of jobs allowed to be run simultaneously, number of jobs
182              matching the number of online processors if  auto  is  specified
183              (since  dpkg  1.17.10),  or  unlimited  number  if  jobs  is not
184              specified, equivalent to the make(1) option  of  the  same  name
185              (since  dpkg  1.14.7,  long option since dpkg 1.18.8).  Will add
186              itself to the MAKEFLAGS environment variable, which should cause
187              all  subsequent  make  invocations  to  inherit the option, thus
188              forcing the parallel setting on the packaging (and possibly  the
189              upstream  build  system  if  that uses make) regardless of their
190              support for parallel builds, which might cause  build  failures.
191              Also  adds  parallel=jobs  or  parallel to the DEB_BUILD_OPTIONS
192              environment variable which allows debian/rules files to use this
193              information  for their own purposes.  The -j value will override
194              the parallel=jobs or parallel option  in  the  DEB_BUILD_OPTIONS
195              environment  variable.   Note  that  the  auto  value  will  get
196              replaced by the actual number of  currently  active  processors,
197              and as such will not get propagated to any child process. If the
198              number of online processors cannot be  inferred  then  the  code
199              will  fallback  to  using serial execution (since dpkg 1.18.15),
200              although this should  only  happen  on  exotic  and  unsupported
201              systems.
202
203       -J, --jobs-try[=jobs|auto]
204              This  option  (since dpkg 1.18.2, long option since dpkg 1.18.8)
205              is equivalent to the -j option except that it does not  set  the
206              MAKEFLAGS  environment  variable, and as such it is safer to use
207              with any package including those  that  are  not  parallel-build
208              safe.
209
210              auto  is  the default behavior (since dpkg 1.18.11). Setting the
211              number of jobs to 1 will restore a serial behavior.
212
213       -D, --check-builddeps
214              Check build dependencies and  conflicts;  abort  if  unsatisfied
215              (long option since dpkg 1.18.8).  This is the default behavior.
216
217       -d, --no-check-builddeps
218              Do not check build dependencies and conflicts (long option since
219              dpkg 1.18.8).
220
221       --ignore-builtin-builddeps
222              Do not check built-in build dependencies  and  conflicts  (since
223              dpkg  1.18.2).   These  are  the  distribution specific implicit
224              build dependencies usually required in a build environment,  the
225              so called Build-Essential package set.
226
227       -nc, --no-pre-clean
228              Do  not  clean  the source tree (long option since dpkg 1.18.8).
229              Implies -b if nothing else has been selected among -F,  -g,  -G,
230              -B, -A or -S.  Implies -d with -S (since dpkg 1.18.0).
231
232       --pre-clean
233              Clean the source tree before building (since dpkg 1.18.8).
234
235       -tc, --post-clean
236              Clean  the  source  tree  (using  gain-root-command debian/rules
237              clean) after the package has been built (long option since  dpkg
238              1.18.8).
239
240       -r, --root-command=gain-root-command
241              When  dpkg-buildpackage  needs  to  execute  part  of  the build
242              process as root, it prefixes the command it executes with  gain-
243              root-command  if  one has been specified (long option since dpkg
244              1.18.8).  Otherwise, if none has been specified,  fakeroot  will
245              be  used  by  default,  if  the  command is present.  gain-root-
246              command should start with the name of a program on the PATH  and
247              will  get  as  arguments the name of the real command to run and
248              the arguments it should  take.   gain-root-command  can  include
249              parameters   (they   must   be  space-separated)  but  no  shell
250              metacharacters.  gain-root-command might typically be  fakeroot,
251              sudo,  super  or  really.  su is not suitable, since it can only
252              invoke the user's shell with -c  instead  of  passing  arguments
253              individually to the command to be run.
254
255       -R, --rules-file=rules-file
256              Building a Debian package usually involves invoking debian/rules
257              as a  command  with  several  standard  parameters  (since  dpkg
258              1.14.17,  long option since dpkg 1.18.8).  With this option it's
259              possible to use another program invocation to build the  package
260              (it  can  include space separated parameters).  Alternatively it
261              can be used to execute the standard rules file with another make
262              program   (for   example   by   using   /usr/local/bin/make   -f
263              debian/rules as rules-file).
264
265       --check-command=check-command
266              Command used to check the .changes file itself and any  artifact
267              built  referenced  in the file (since dpkg 1.17.6).  The command
268              should take the .changes pathname as an argument.  This  command
269              will usually be lintian.
270
271       --check-option=opt
272              Pass   option   opt   to   the   check-command   specified  with
273              DEB_CHECK_COMMAND or --check-command (since dpkg  1.17.6).   Can
274              be used multiple times.
275
276       --hook-hook-name=hook-command
277              Set the specified shell code hook-command as the hook hook-name,
278              which will run at the times specified in the  run  steps  (since
279              dpkg  1.17.6).   The  hooks  will always be executed even if the
280              following action is not performed (except for the binary  hook).
281              All the hooks will run in the unpacked source directory.
282
283              Note:  Hooks  can  affect  the  build  process,  and cause build
284              failures if their commands fail, so  watch  out  for  unintended
285              consequences.
286
287              The current hook-name supported are:
288
289              init  preclean  source  build binary buildinfo changes postclean
290              check sign done
291
292              The hook-command  supports  the  following  substitution  format
293              string, which will get applied to it before execution:
294
295
296              %%     A single % character.
297
298              %a     A  boolean  value  (0  or  1),  representing  whether the
299                     following action is being performed.
300
301              %p     The source package name.
302
303              %v     The source package version.
304
305              %s     The source package version (without the epoch).
306
307              %u     The upstream version.
308
309       --buildinfo-option=opt
310              Pass option opt to dpkg-genbuildinfo (since dpkg 1.18.11).   Can
311              be used multiple times.
312
313       -p, --sign-command=sign-command
314              When  dpkg-buildpackage  needs  to  execute GPG to sign a source
315              control (.dsc) file or a .changes file it will run  sign-command
316              (searching  the  PATH if necessary) instead of gpg2 or gpg (long
317              option since  dpkg  1.18.8).   sign-command  will  get  all  the
318              arguments  that  gpg2  or  gpg  would  have gotten. sign-command
319              should not contain spaces or any other shell metacharacters.
320
321       -k, --sign-key=key-id
322              Specify a key-ID to use when signing packages (long option since
323              dpkg 1.18.8).
324
325       -us, --unsigned-source
326              Do not sign the source package (long option since dpkg 1.18.8).
327
328       -ui, --unsigned-buildinfo
329              Do not sign the .buildinfo file (since dpkg 1.18.19).
330
331       -uc, --unsigned-changes
332              Do not sign the .buildinfo and .changes files (long option since
333              dpkg 1.18.8).
334
335       --no-sign
336              Do not sign any file, this  includes  the  source  package,  the
337              .buildinfo file and the .changes file (since dpkg 1.18.20).
338
339       --force-sign
340              Force  the  signing  of the resulting files (since dpkg 1.17.0),
341              regardless of -us, --unsigned-source, -ui, --unsigned-buildinfo,
342              -uc, --unsigned-changes or other internal heuristics.
343
344       -sn
345       -ss
346       -sA
347       -sk
348       -su
349       -sr
350       -sK
351       -sU
352       -sR
353       -i, --diff-ignore[=regex]
354       -I, --tar-ignore[=pattern]
355       -z, --compression-level=level
356       -Z, --compression=compressor
357              Passed unchanged to dpkg-source. See its manual page.
358
359       --source-option=opt
360              Pass option opt to dpkg-source (since dpkg 1.15.6).  Can be used
361              multiple times.
362
363       --changes-option=opt
364              Pass option opt to dpkg-genchanges (since dpkg 1.15.6).  Can  be
365              used multiple times.
366
367       --admindir=dir
368       --admindir dir
369              Change  the  location  of the dpkg database (since dpkg 1.14.0).
370              The default location is /var/lib/dpkg.
371
372       -?, --help
373              Show the usage message and exit.
374
375       --version
376              Show the version and exit.
377

ENVIRONMENT

379   External environment
380       DEB_CHECK_COMMAND
381              If set, it will be used as the command  to  check  the  .changes
382              file  (since  dpkg  1.17.6).   Overridden by the --check-command
383              option.
384
385       DEB_SIGN_KEYID
386              If set, it will be used to sign  the  .changes  and  .dsc  files
387              (since dpkg 1.17.2).  Overridden by the --sign-key option.
388
389       DEB_BUILD_OPTIONS
390              If  set,  it will contain a space-separated list of options that
391              might affect the build process in debian/rules, and the behavior
392              of some dpkg commands.
393
394              With  nocheck  the  DEB_CHECK_COMMAND  variable will be ignored.
395              With parallel=N the parallel jobs will be set to  N,  overridden
396              by the --jobs-try option.
397
398       DEB_BUILD_PROFILES
399              If  set,  it will be used as the active build profile(s) for the
400              package  being  built  (since  dpkg  1.17.2).   It  is  a  space
401              separated list of profile names.  Overridden by the -P option.
402
403       DPKG_COLORS
404              Sets the color mode (since dpkg 1.18.5).  The currently accepted
405              values are: auto (default), always and never.
406
407
408   Internal environment
409       Even if dpkg-buildpackage exports some variables,  debian/rules  should
410       not  rely  on  their  presence  and  should  instead use the respective
411       interface to retrieve the needed values, because that file is the  main
412       entry  point  to  build  packages  and  running it standalone should be
413       supported.
414
415
416       DEB_BUILD_*
417       DEB_HOST_*
418       DEB_TARGET_*
419              dpkg-architecture is  called  with  the  -a  and  -t  parameters
420              forwarded.  Any  variable  that  is  output  by its -s option is
421              integrated in the build environment.
422
423
424       SOURCE_DATE_EPOCH
425              This variable is set to the Unix timestamp since  the  epoch  of
426              the  latest  entry  in  debian/changelog,  if  it is not already
427              defined.
428

FILES

430       /etc/dpkg/buildpackage.conf
431              System wide configuration file
432
433       $XDG_CONFIG_HOME/dpkg/buildpackage.conf or
434       $HOME/.config/dpkg/buildpackage.conf
435              User configuration file.
436

NOTES

438   Compiler flags are no longer exported
439       Between dpkg 1.14.17 and 1.16.1,  dpkg-buildpackage  exported  compiler
440       flags  (CFLAGS,  CXXFLAGS, FFLAGS, CPPFLAGS and LDFLAGS) with values as
441       returned by dpkg-buildflags. This is no longer the case.
442
443   Default build targets
444       dpkg-buildpackage is using the build-arch and build-indep targets since
445       dpkg  1.16.2.  Those targets are thus mandatory. But to avoid breakages
446       of existing packages, and ease the transition, if  the  source  package
447       does  not  build  both  architecture  independent  and dependent binary
448       packages (since dpkg 1.18.8) it will fallback to use the  build  target
449       if make -f debian/rules -qn build-target returns 2 as exit code.
450

BUGS

452       It  should  be  possible to specify spaces and shell metacharacters and
453       initial arguments for gain-root-command and sign-command.
454

SEE ALSO

456       dpkg-source(1), dpkg-architecture(1), dpkg-buildflags(1),
457       dpkg-genbuildinfo(1), dpkg-genchanges(1), fakeroot(1), lintian(1),
458       gpg2(1), gpg(1).
459
460
461
4621.18.25                           2018-06-26              dpkg-buildpackage(1)
Impressum