dpkg-buildpackage.1 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. .\" dpkg manual page - dpkg-buildpackage(1)
  2. .\"
  3. .\" Copyright © 1995-1996 Ian Jackson
  4. .\" Copyright © 2000 Wichert Akkerman <wakkerma@debian.org>
  5. .\" Copyright © 2007-2008 Frank Lichtenheld <djpig@debian.org>
  6. .\" Copyright © 2008-2015 Guillem Jover <guillem@debian.org>
  7. .\" Copyright © 2008-2012 Raphaël Hertzog <hertzog@debian.org>
  8. .\"
  9. .\" This is free software; you can redistribute it and/or modify
  10. .\" it under the terms of the GNU General Public License as published by
  11. .\" the Free Software Foundation; either version 2 of the License, or
  12. .\" (at your option) any later version.
  13. .\"
  14. .\" This is distributed in the hope that it will be useful,
  15. .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. .\" GNU General Public License for more details.
  18. .\"
  19. .\" You should have received a copy of the GNU General Public License
  20. .\" along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. .
  22. .TH dpkg\-buildpackage 1 "2015-07-05" "Debian Project" "dpkg utilities"
  23. .SH NAME
  24. dpkg\-buildpackage \- build binary or source packages from sources
  25. .
  26. .SH SYNOPSIS
  27. .B dpkg\-buildpackage
  28. .RI [ option ...]
  29. .
  30. .SH DESCRIPTION
  31. .B dpkg\-buildpackage
  32. is a program that automates the process of building a Debian package. It
  33. consists of the following steps:
  34. .IP \fB1.\fP 3
  35. It prepares the build environment by setting various environment
  36. variables (see \fBENVIRONMENT\fP), runs the \fBinit\fP hook, and calls
  37. \fBdpkg\-source \-\-before\-build\fP (unless \fB\-T\fP or \fB\-\-target\fP
  38. has been used).
  39. .IP \fB2.\fP 3
  40. It checks that the build-dependencies and build-conflicts
  41. are satisfied (unless \fB\-d\fP is specified).
  42. .IP \fB3.\fP 3
  43. If a specific target has been selected with the \fB\-T\fP or \fB\-\-target\fP
  44. option, it calls that target and stops here. Otherwise it runs the
  45. \fBpreclean\fP hook and calls \fBfakeroot debian/rules clean\fP to
  46. clean the build-tree (unless \fB\-nc\fP is specified).
  47. .IP \fB4.\fP 3
  48. It runs the \fBsource\fP hook and calls \fBdpkg\-source \-b\fP to generate
  49. the source package (unless a binary\-only build has been requested with
  50. \fB\-b\fP, \fB\-B\fP or \fB\-A\fP).
  51. .IP \fB5.\fP 3
  52. It runs the \fBbuild\fP hook and calls \fBdebian/rules\fP \fIbuild-target\fP,
  53. then runs the \fBbinary\fP hook followed by \fBfakeroot debian/rules\fP
  54. \fIbinary-target\fP (unless a source-only build has been requested with
  55. \fB\-S\fP). Note that \fIbuild-target\fR and \fIbinary-target\fP are either
  56. \fBbuild\fP and \fBbinary\fP (default case, or if \fB\-b\fP is specified),
  57. or \fBbuild\-arch\fP and \fBbinary\-arch\fP (if \fB\-B\fP or \fB\-G\fP are
  58. specified), or \fBbuild\-indep\fP and \fBbinary\-indep\fP (if \fB\-A\fP
  59. or \fB\-g\fP are specified).
  60. .IP \fB6.\fP 3
  61. It runs the \fBchanges\fP hook and calls \fBdpkg\-genchanges\fP to
  62. generate a \fB.changes\fP file.
  63. Many \fBdpkg\-buildpackage\fP options are forwarded to
  64. \fBdpkg\-genchanges\fP.
  65. .IP \fB7.\fP 3
  66. It runs the \fBpostclean\fP hook and if \fB\-tc\fP is specified, it will
  67. call \fBfakeroot debian/rules clean\fP again.
  68. .IP \fB8.\fP 3
  69. It calls \fBdpkg\-source \-\-after\-build\fP.
  70. .IP \fB9.\fP 3
  71. It runs the \fBcheck\fP hook and calls a package checker for the
  72. \fB.changes\fP file (if a command is specified in \fBDEB_CHECK_COMMAND\fP or
  73. with \fB\-\-check\-command\fP).
  74. .IP \fB10.\fP 3
  75. It runs the \fBsign\fP hook and calls \fBgpg2\fP or \fBgpg\fP to sign
  76. the \fB.dsc\fP file (if any, unless \fB\-us\fP is specified or on UNRELEASED
  77. builds), and the \fB.changes\fP file (unless \fB\-uc\fP is specified or on
  78. UNRELEASED builds).
  79. .IP \fB11.\fP 3
  80. It runs the \fBdone\fP hook.
  81. .
  82. .SH OPTIONS
  83. .TP
  84. .B \-g
  85. Specifies a build limited to source and architecture independent packages
  86. (since dpkg 1.17.11).
  87. Passed to \fBdpkg\-genchanges\fP.
  88. .TP
  89. .B \-G
  90. Specifies a build limited to source and architecture specific packages
  91. (since dpkg 1.17.11).
  92. Passed to \fBdpkg\-genchanges\fP.
  93. .TP
  94. .B \-b
  95. Specifies a binary-only build, no source files are to be built and/or
  96. distributed. Passed to \fBdpkg\-genchanges\fP.
  97. .TP
  98. .B \-B
  99. Specifies a binary-only build, limited to architecture dependent packages.
  100. Passed to \fBdpkg\-genchanges\fP.
  101. .TP
  102. .B \-A
  103. Specifies a binary-only build, limited to architecture independent
  104. packages. Passed to \fBdpkg\-genchanges\fP.
  105. .TP
  106. .B \-S
  107. Specifies a source-only build, no binary packages need to be made.
  108. Passed to \fBdpkg\-genchanges\fP.
  109. Note: if what you want is simply to (re-)build the source package, using
  110. \fBdpkg\-source\fP is always better as it does not require any build
  111. dependencies to be installed to be able to call the \fBclean\fP target.
  112. .TP
  113. .B \-F
  114. Specifies a normal full build, binary and source packages will be built
  115. (since dpkg 1.15.8).
  116. This is the same as the default case when no build option is specified.
  117. .TP
  118. .BI \-\-target= target
  119. .TQ
  120. .BI "\-\-target " target
  121. .TQ
  122. .BI \-T target
  123. Calls \fBdebian/rules\fP \fItarget\fP after having setup the build
  124. environment and stops the package build process here (since dpkg 1.15.0).
  125. If \fB\-\-as\-root\fP is also given, then the command is executed
  126. as root (see \fB\-r\fP). Note that known targets that are required to
  127. be run as root do not need this option (i.e. the \fBclean\fP, \fBbinary\fP,
  128. \fBbinary\-arch\fP and \fBbinary\-indep\fP targets).
  129. .TP
  130. .B \-\-as\-root
  131. Only meaningful together with \fB\-\-target\fP (since dpkg 1.15.0).
  132. Requires that the target be run with root rights.
  133. .TP
  134. .B \-si
  135. .TQ
  136. .B \-sa
  137. .TQ
  138. .B \-sd
  139. .TQ
  140. .BI \-v version
  141. .TQ
  142. .BI \-C changes-description
  143. .TQ
  144. .BI \-m maintainer-address
  145. .TQ
  146. .BI \-e maintainer-address
  147. Passed unchanged to \fBdpkg\-genchanges\fP. See its manual page.
  148. .TP
  149. .BR \-a ", " \-\-host\-arch " \fIarchitecture\fP"
  150. Specify the Debian architecture we build for (long option since dpkg 1.17.17).
  151. The architecture of the
  152. machine we build on is determined automatically, and is also the default
  153. for the host machine.
  154. .TP
  155. .BR \-t ", " \-\-host\-type " \fIgnu-system-type\fP"
  156. Specify the GNU system type we build for (long option since dpkg 1.17.17).
  157. It can be used in place
  158. of \fB\-\-host\-arch\fP or as a complement to override the default GNU system type
  159. of the host Debian architecture.
  160. .TP
  161. .BR \-\-target\-arch " \fIarchitecture\fP"
  162. Specify the Debian architecture the binaries built will build for
  163. (since dpkg 1.17.17).
  164. The default value is the host machine.
  165. .TP
  166. .BR \-\-target\-type " \fIgnu-system-type\fP"
  167. Specify the GNU system type the binaries built will build for
  168. (since dpkg 1.17.17).
  169. It can be
  170. used in place of \fB\-\-target\-arch\fP or as a complement to override the
  171. default GNU system type of the target Debian architecture.
  172. .TP
  173. .BR \-P \fIprofile\fP[ , ...]
  174. Specify the profile(s) we build, as a comma-separated list (since dpkg 1.17.2).
  175. The default
  176. behavior is to build for no specific profile. Also sets them (as a space
  177. separated list) as the \fBDEB_BUILD_PROFILES\fP environment variable which
  178. allows, for example, \fBdebian/rules\fP files to use this information for
  179. conditional builds.
  180. .TP
  181. .BR \-j [\fIjobs\fP|\fBauto\fP]
  182. Number of jobs allowed to be run simultaneously, number of jobs matching
  183. the number of online processors if \fBauto\fP is specified
  184. (since dpkg 1.17.10), or unlimited number if \fIjobs\fP is not specified,
  185. equivalent to the
  186. .BR make (1)
  187. option of the same name (since dpkg 1.14.7).
  188. Will add itself to the \fB\%MAKEFLAGS\fP
  189. environment variable, which should cause all subsequent make
  190. invocations to inherit the option, thus forcing the parallel setting on
  191. the packaging (and possibly the upstream build system if that uses make)
  192. regardless of their support for parallel builds, which might cause build
  193. failures.
  194. Also adds \fBparallel=\fP\fIjobs\fP or
  195. \fBparallel\fP to the \fBDEB_BUILD_OPTIONS\fP environment variable which
  196. allows debian/rules files to use this information for their own purposes.
  197. The \fB\-j\fP value will override the \fBparallel=\fP\fIjobs\fP or
  198. \fBparallel\fP option in the \fBDEB_BUILD_OPTIONS\fP environment variable.
  199. Note that the \fBauto\fP value will get replaced by the actual number of
  200. currently active processors, and as such will not get propagated to any
  201. child process. If the number of online processors cannot be inferred then
  202. the code will fallback to using an unlimited number.
  203. .TP
  204. .BR \-J [\fIjobs\fP|\fBauto\fP]
  205. This option (since dpkg 1.18.2) is equivalent to the \fB\-j\fP option
  206. except that it does not set the \fB\%MAKEFLAGS\fP environment variable,
  207. and as such it is safer to use with any package including those that are
  208. not parallel-build safe.
  209. .TP
  210. .B \-D
  211. Check build dependencies and conflicts; abort if unsatisfied. This is the
  212. default behavior.
  213. .TP
  214. .B \-d
  215. Do not check build dependencies and conflicts.
  216. .TP
  217. .B \-\-ignore\-builtin\-builddeps
  218. Do not check built-in build dependencies and conflicts (since dpkg 1.18.2).
  219. These are the distribution specific implicit build dependencies usually
  220. required in a build environment, the so called Build-Essential package set.
  221. .TP
  222. .B \-nc
  223. Do not clean the source tree.
  224. Implies \fB\-b\fP if nothing else has been selected among \fB\-F\fP,
  225. \fB\-g\fP, \fB\-G\fP, \fB\-B\fP, \fB\-A\fP or \fB\-S\fP.
  226. Implies \fB\-d\fP with \fB\-S\fP (since dpkg 1.18.0).
  227. .TP
  228. .B \-tc
  229. Clean the source tree (using
  230. .I gain-root-command
  231. .BR "debian/rules clean" )
  232. after the package has been built.
  233. .TP
  234. .BI \-r gain-root-command
  235. When
  236. .B dpkg\-buildpackage
  237. needs to execute part of the build process as root, it prefixes the
  238. command it executes with
  239. .I gain-root-command
  240. if one has been specified. Otherwise, if none has been specified,
  241. \fBfakeroot\fP will be used by default, if the command is present.
  242. .I gain-root-command
  243. should start with the name of a program on the
  244. .B PATH
  245. and will get as arguments the name of the real command to run and the
  246. arguments it should take.
  247. .I gain-root-command
  248. can include parameters (they must be space-separated) but no shell
  249. metacharacters.
  250. .I gain-root-command
  251. might typically be
  252. .BR fakeroot ", " sudo ", " super " or " really .
  253. .B su
  254. is not suitable, since it can only invoke the user's shell with
  255. .B \-c
  256. instead of passing arguments individually to the command to be run.
  257. .TP
  258. .BI \-R rules-file
  259. Building a Debian package usually involves invoking
  260. .B debian/rules
  261. as a command with several standard parameters (since dpkg 1.14.17).
  262. With this option it's
  263. possible to use another program invocation to build the package (it can
  264. include space separated parameters).
  265. Alternatively it can be used to execute the standard rules file with
  266. another make program (for example by using
  267. .B /usr/local/bin/make \-f debian/rules
  268. as \fIrules-file\fR).
  269. .TP
  270. .BI \-\-check\-command= check-command
  271. Command used to check the \fB.changes\fP file itself and any artifact built
  272. referenced in the file (since dpkg 1.17.6).
  273. The command should take the \fB.changes\fP pathname
  274. as an argument. This command will usually be \fBlintian\fP.
  275. .TP
  276. .BI \-\-check\-option= opt
  277. Pass option \fIopt\fP to the \fIcheck-command\fP specified with
  278. \fBDEB_CHECK_COMMAND\fP or \fB\-\-check\-command\fP (since dpkg 1.17.6).
  279. Can be used multiple times.
  280. .TP
  281. .BI \-\-hook\- hook-name = hook-command
  282. Set the specified shell code \fIhook-command\fP as the hook \fIhook-name\fP,
  283. which will run at the times specified in the run steps (since dpkg 1.17.6).
  284. The hooks will
  285. always be executed even if the following action is not performed (except
  286. for the \fBbinary\fP hook).
  287. Note: Hooks can affect the build process, and cause build failures if
  288. their commands fail, so watch out for unintended consequences.
  289. The current \fIhook-name\fP supported are:
  290. .B init preclean source build binary changes postclean check sign done
  291. The \fIhook-command\fP supports the following substitution format string,
  292. which will get applied to it before execution:
  293. .RS
  294. .TP
  295. .B %%
  296. A single % character.
  297. .TP
  298. .B %a
  299. A boolean value (0 or 1), representing whether the following action is
  300. being performed.
  301. .TP
  302. .B %p
  303. The source package name.
  304. .TP
  305. .B %v
  306. The source package version.
  307. .TP
  308. .B %s
  309. The source package version (without the epoch).
  310. .TP
  311. .B %u
  312. The upstream version.
  313. .RE
  314. .TP
  315. .BI \-p sign-command
  316. When \fBdpkg\-buildpackage\fP needs to execute GPG to sign a source
  317. control (\fB.dsc\fP) file or a \fB.changes\fP file it will run
  318. \fIsign-command\fP (searching the \fBPATH\fP if necessary) instead of
  319. \fBgpg2\fP or \fBgpg\fP. \fIsign-command\fP will get all the arguments
  320. that \fBgpg2\fP or \fBgpg\fP would have gotten. \fIsign-command\fP
  321. should not contain spaces or any other shell metacharacters.
  322. .TP
  323. .BI \-k key-id
  324. Specify a key-ID to use when signing packages.
  325. .TP
  326. .BR \-us
  327. Do not sign the source package.
  328. .TP
  329. .BR \-uc
  330. Do not sign the \fB.changes\fP file.
  331. .TP
  332. .BR \-\-force\-sign
  333. Force the signing of the resulting files (since dpkg 1.17.0),
  334. regardless of \fB\-us\fP or \fB\-uc\fP or other internal heuristics.
  335. .TP
  336. .BR \-i [\fIregex\fP]
  337. .TQ
  338. .BR \-I [\fIpattern\fP]
  339. .TQ
  340. .BR \-s [ nsAkurKUR ]
  341. .TQ
  342. .BR \-z ", " \-Z
  343. Passed unchanged to \fBdpkg\-source\fP. See its manual page.
  344. .TP
  345. .BI \-\-source\-option= opt
  346. Pass option \fIopt\fP to \fBdpkg\-source\fP (since dpkg 1.15.6).
  347. Can be used multiple times.
  348. .TP
  349. .BI \-\-changes\-option= opt
  350. Pass option \fIopt\fP to \fBdpkg\-genchanges\fP (since dpkg 1.15.6).
  351. Can be used multiple times.
  352. .TP
  353. .BI \-\-admindir= dir
  354. .TQ
  355. .BI "\-\-admindir " dir
  356. Change the location of the \fBdpkg\fR database (since dpkg 1.14.0).
  357. The default location is \fI/var/lib/dpkg\fP.
  358. .TP
  359. .BR \-? ", " \-\-help
  360. Show the usage message and exit.
  361. .TP
  362. .BR \-\-version
  363. Show the version and exit.
  364. .
  365. .SH ENVIRONMENT
  366. .TP
  367. .B DEB_CHECK_COMMAND
  368. If set, it will be used as the command to check the \fB.changes\fP file
  369. (since dpkg 1.17.6).
  370. Overridden by the \fB\-\-check\-command\fP option.
  371. .TP
  372. .B DEB_SIGN_KEYID
  373. If set, it will be used to sign the \fB.changes\fP and \fB.dsc\fP files
  374. (since dpkg 1.17.2).
  375. Overridden by the \fB\-k\fP option.
  376. .TP
  377. .B DEB_BUILD_OPTIONS
  378. If set, and containing \fBnocheck\fP the \fBDEB_CHECK_COMMAND\fP variable
  379. will be ignored.
  380. .TP
  381. .B DEB_BUILD_PROFILES
  382. If set, it will be used as the active build profile(s) for the package
  383. being built (since dpkg 1.17.2).
  384. It is a space separated list of profile names.
  385. Overridden by the \fB\-P\fP option.
  386. .TP
  387. .B DPKG_COLORS
  388. Sets the color mode (since dpkg 1.18.5).
  389. The currently accepted values are: \fBauto\fP, \fBalways\fP and
  390. \fBnever\fP (default).
  391. .SS Reliance on exported environment flags
  392. Even if \fBdpkg\-buildpackage\fP exports some variables, \fBdebian/rules\fP
  393. should not rely on their presence and should instead use the
  394. respective interface to retrieve the needed values.
  395. .SS Variables set by dpkg\-architecture
  396. \fBdpkg\-architecture\fP is called with the \fB\-a\fP and \fB\-t\fP
  397. parameters forwarded. Any variable that is output by its \fB\-s\fP
  398. option is integrated in the build environment.
  399. .
  400. .SH NOTES
  401. .SS Compiler flags are no longer exported
  402. Between dpkg 1.14.17 and 1.16.1, \fBdpkg\-buildpackage\fP
  403. exported compiler flags (\fBCFLAGS\fP, \fBCXXFLAGS\fP, \fBFFLAGS\fP,
  404. \fBCPPFLAGS\fP and \fBLDFLAGS\fP) with values as returned
  405. by \fBdpkg\-buildflags\fP. This is no longer the case.
  406. .SS Default build targets
  407. \fBdpkg\-buildpackage\fP is using the \fBbuild\-arch\fP and
  408. \fBbuild\-indep\fP targets since dpkg 1.16.2. Those targets are thus
  409. mandatory. But to avoid breakages of existing packages, and ease
  410. the transition, it will fallback to using the \fBbuild\fP target
  411. if \fBmake \-f debian/rules \-qn\fP \fIbuild-target\fP returns 2 as
  412. exit code.
  413. .SH BUGS
  414. It should be possible to specify spaces and shell metacharacters
  415. and initial arguments for
  416. .IR gain-root-command " and " sign-command .
  417. .
  418. .SH SEE ALSO
  419. .ad l
  420. .nh
  421. .BR dpkg\-source (1),
  422. .BR dpkg\-architecture (1),
  423. .BR dpkg\-buildflags (1),
  424. .BR dpkg\-genchanges (1),
  425. .BR fakeroot (1),
  426. .BR lintian (1),
  427. .BR gpg2 (1),
  428. .BR gpg (1).