dpkg-buildpackage.1 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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-2013 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 "2013-12-12" "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 is specified),
  58. or \fBbuild\-indep\fP and \fBbinary\-indep\fP (if \fB\-A\fP is specified).
  59. .IP \fB6.\fP 3
  60. It runs the \fBchanges\fP hook and calls \fBdpkg\-genchanges\fP to
  61. generate a \fB.changes\fP file.
  62. Many \fBdpkg\-buildpackage\fP options are forwarded to
  63. \fBdpkg\-genchanges\fP.
  64. .IP \fB7.\fP 3
  65. It runs the \fBpostclean\fP hook and if \fB\-tc\fP is specified, it will
  66. call \fBfakeroot debian/rules clean\fP again.
  67. .IP \fB8.\fP 3
  68. It calls \fBdpkg\-source \-\-after\-build\fP.
  69. .IP \fB9.\fP 3
  70. It runs the \fBcheck\fP hook and calls a package checker for the
  71. \fB.changes\fP file (if a command is specified in \fBDEB_CHECK_COMMAND\fP or
  72. with \fB\-\-check\-command\fP).
  73. .IP \fB10.\fP 3
  74. It runs the \fBsign\fP hook and calls \fBgpg2\fP or \fBgpg\fP to sign
  75. the \fB.dsc\fP file (if any, unless \fB\-us\fP is specified or on UNRELEASED
  76. builds), and the \fB.changes\fP file (unless \fB\-uc\fP is specified or on
  77. UNRELEASED builds).
  78. .IP \fB11.\fP 3
  79. It runs the \fBdone\fP hook.
  80. .
  81. .SH OPTIONS
  82. .TP
  83. .B \-b
  84. Specifies a binary-only build, no source files are to be built and/or
  85. distributed. Passed to \fBdpkg\-genchanges\fP.
  86. .TP
  87. .B \-B
  88. Specifies a binary-only build, limited to architecture dependent packages.
  89. Passed to \fBdpkg\-genchanges\fP.
  90. .TP
  91. .B \-A
  92. Specifies a binary-only build, limited to architecture independent
  93. packages. Passed to \fBdpkg\-genchanges\fP.
  94. .TP
  95. .B \-S
  96. Specifies a source-only build, no binary packages need to be made.
  97. Passed to \fBdpkg\-genchanges\fP.
  98. .TP
  99. .B \-F
  100. Specifies a normal full build, binary and source packages will be built.
  101. This is the same as the default case when no build option is specified.
  102. .TP
  103. .BI \-\-target= target
  104. .TQ
  105. .BI "\-\-target " target
  106. .TQ
  107. .BI \-T target
  108. Calls \fBdebian/rules\fP \fItarget\fP after having setup the build
  109. environment and stops the package build process here. If
  110. \fB\-\-as\-root\fP is also given, then the command is executed
  111. as root (see \fB\-r\fP). Note that official targets that are required to
  112. be run as root by the Debian policy do not need this option.
  113. .TP
  114. .B \-\-as\-root
  115. Only meaningful together with \fB\-\-target\fP. Requires that the target be
  116. run with root rights.
  117. .TP
  118. .B \-si
  119. .TQ
  120. .B \-sa
  121. .TQ
  122. .B \-sd
  123. .TQ
  124. .BI \-v version
  125. .TQ
  126. .BI \-C changes-description
  127. .TQ
  128. .BI \-m maintainer-address
  129. .TQ
  130. .BI \-e maintainer-address
  131. Passed unchanged to \fBdpkg\-genchanges\fP. See its manual page.
  132. .TP
  133. .BI \-a architecture
  134. Specify the Debian architecture we build for. The architecture of the
  135. machine we build on is determined automatically, and is also the default
  136. for the host machine.
  137. .TP
  138. .BI \-t gnu-system-type
  139. Specify the GNU system type we build for. It can be used in place
  140. of \-a or as a complement to override the default GNU system type
  141. of the target Debian architecture.
  142. .TP
  143. .BR \-P \fIprofile\fP[ , ...]
  144. Specify the profile(s) we build, as a comma-separated list, without the
  145. "\fBprofile.\fP" namespace prefix. The default behavior is to build for
  146. no specific profile. Also adds them (as a space separated list) to the
  147. \fBDEB_BUILD_PROFILES\fP environment variable which allows, for example,
  148. \fBdebian/rules\fP files to use this information for conditional builds.
  149. .TP
  150. .BR \-j [\fIjobs\fP|\fBauto\fP]
  151. Number of jobs allowed to be run simultaneously, number of jobs matching
  152. the number of online processors if \fBauto\fP is specified, or unlimited
  153. number if \fIjobs\fP is not specified, equivalent to the
  154. .BR make (1)
  155. option of the same name. Will add itself to the \fBMAKEFLAGS\fP
  156. environment variable, which should cause all subsequent make
  157. invocations to inherit the option. Also adds \fBparallel=\fP\fIjobs\fP or
  158. \fBparallel=\fP to the \fBDEB_BUILD_OPTIONS\fP environment variable which
  159. allows debian/rules files to use this information for their own purposes.
  160. The \fBparallel=\fP\fIjobs\fP or \fBparallel=\fP option in
  161. \fBDEB_BUILD_OPTIONS\fP environment variable will override the \fB\-j\fP
  162. value if this option is given.
  163. Note that the \fBauto\fP value will get replaced by the actual number of
  164. currently active processors, and as such will not get propagated to any
  165. child process. If the number of online processors cannot be inferred then
  166. the code will fallback to using an unlimited number.
  167. .TP
  168. .B \-D
  169. Check build dependencies and conflicts; abort if unsatisfied. This is the
  170. default behavior.
  171. .TP
  172. .B \-d
  173. Do not check build dependencies and conflicts.
  174. .TP
  175. .B \-nc
  176. Do not clean the source tree (implies \fB\-b\fP if nothing else has been
  177. selected among \fB\-F\fP, \fB\-B\fP, \fB\-A\fP or \fB\-S\fP).
  178. .TP
  179. .B \-tc
  180. Clean the source tree (using
  181. .I gain-root-command
  182. .BR "debian/rules clean" )
  183. after the package has been built.
  184. .TP
  185. .BI \-r gain-root-command
  186. When
  187. .B dpkg\-buildpackage
  188. needs to execute part of the build process as root, it prefixes the
  189. command it executes with
  190. .I gain-root-command
  191. if one has been specified. Otherwise, if none has been specified,
  192. \fBfakeroot\fP will be used by default, if the command is present.
  193. .I gain-root-command
  194. should start with the name of a program on the
  195. .B PATH
  196. and will get as arguments the name of the real command to run and the
  197. arguments it should take.
  198. .I gain-root-command
  199. can include parameters (they must be space-separated) but no shell
  200. metacharacters.
  201. .I gain-root-command
  202. might typically be
  203. .BR fakeroot ", " sudo ", " super " or " really .
  204. .B su
  205. is not suitable, since it can only invoke the user's shell with
  206. .B \-c
  207. instead of passing arguments individually to the command to be run.
  208. .TP
  209. .BI \-R rules-file
  210. Building a Debian package usually involves invoking
  211. .B debian/rules
  212. as a command with several standard parameters. With this option it's
  213. possible to use another program invocation to build the package (it can
  214. include space separated parameters).
  215. Alternatively it can be used to execute the standard rules file with
  216. another make program (for example by using
  217. .B /usr/local/bin/make \-f debian/rules
  218. as \fIrules-file\fR).
  219. .TP
  220. .BI \-\-check\-command= check-command
  221. Command used to check the \fB.changes\fP file itself and any artifact built
  222. referenced in the file. The command should take the \fB.changes\fP pathname
  223. as an argument. This command will usually be \fBlintian\fP.
  224. .TP
  225. .BI \-\-check\-option= opt
  226. Pass option \fIopt\fP to the \fIcheck-command\fP specified with
  227. \fBDEB_CHECK_COMMAND\fP or \fB\-\-check\-command\fP.
  228. Can be used multiple times.
  229. .TP
  230. .BI \-\-hook\- hook-name = hook-command
  231. Set the specified shell code \fIhook-command\fP as the hook \fIhook-name\fP,
  232. which will run at the times specified in the run steps. The hooks will
  233. always be executed even if the following action is not performed (except
  234. for the \fBbinary\fP hook).
  235. Note: Hooks can affect the build process, and cause build failures if
  236. their commands fail, so watch out for unintended consequences.
  237. The current \fIhook-name\fP supported are:
  238. .B init preclean source build binary changes postclean check sign done
  239. The \fIhook-command\fP supports the following substitution format string,
  240. which will get applied to it before execution:
  241. .RS
  242. .TP
  243. .B %%
  244. A single % character.
  245. .TP
  246. .B %a
  247. A boolean value (0 or 1), representing whether the following action is
  248. being performed.
  249. .TP
  250. .B %p
  251. The source package name.
  252. .TP
  253. .B %v
  254. The source package version.
  255. .TP
  256. .B %s
  257. The source package version (without the epoch).
  258. .TP
  259. .B %u
  260. The upstream version.
  261. .RE
  262. .TP
  263. .BI \-p sign-command
  264. When \fBdpkg\-buildpackage\fP needs to execute GPG to sign a source
  265. control (\fB.dsc\fP) file or a \fB.changes\fP file it will run
  266. \fIsign-command\fP (searching the \fBPATH\fP if necessary) instead of
  267. \fBgpg2\fP or \fBgpg\fP. \fIsign-command\fP will get all the arguments
  268. that \fBgpg2\fP or \fBgpg\fP would have gotten. \fIsign-command\fP
  269. should not contain spaces or any other shell metacharacters.
  270. .TP
  271. .BI \-k key-id
  272. Specify a key-ID to use when signing packages.
  273. .TP
  274. .BR \-us
  275. Do not sign the source package.
  276. .TP
  277. .BR \-uc
  278. Do not sign the \fB.changes\fP file.
  279. .TP
  280. .BR \-\-force\-sign
  281. Force the signing of the resulting files (since dpkg 1.17.0),
  282. regardless of \fB\-us\fP or \fB\-uc\fP or other internal heuristics.
  283. .TP
  284. .BR \-i [\fIregex\fP]
  285. .TQ
  286. .BR \-I [\fIpattern\fP]
  287. .TQ
  288. .BR \-s [ nsAkurKUR ]
  289. .TQ
  290. .BR \-z ", " \-Z
  291. Passed unchanged to \fBdpkg\-source\fP. See its manual page.
  292. .TP
  293. .BI \-\-source\-option= opt
  294. Pass option \fIopt\fP to \fBdpkg\-source\fP.
  295. Can be used multiple times.
  296. .TP
  297. .BI \-\-changes\-option= opt
  298. Pass option \fIopt\fP to \fBdpkg\-genchanges\fP.
  299. Can be used multiple times.
  300. .TP
  301. .BI \-\-admindir= dir
  302. .TQ
  303. .BI "\-\-admindir " dir
  304. Change the location of the \fBdpkg\fR database. The default location is
  305. \fI/var/lib/dpkg\fP.
  306. .TP
  307. .BR \-? ", " \-\-help
  308. Show the usage message and exit.
  309. .TP
  310. .BR \-\-version
  311. Show the version and exit.
  312. .
  313. .SH ENVIRONMENT
  314. .TP
  315. .B DEB_CHECK_COMMAND
  316. If set, it will be used as the command to check the \fB.changes\fP file.
  317. Overridden by the \fB\-\-check\-command\fP option.
  318. .TP
  319. .B DEB_SIGN_KEYID
  320. If set, it will be used to sign the \fB.changes\fP and \fB.dsc\fP files.
  321. Overridden by the \fB\-k\fP option.
  322. .TP
  323. .B DEB_BUILD_OPTIONS
  324. If set, and containing \fBnocheck\fP the \fBDEB_CHECK_COMMAND\fP variable
  325. will be ignored.
  326. .TP
  327. .B DEB_BUILD_PROFILES
  328. If set, it will be used as the active build profile(s) for the package
  329. being built. It is a space separated list of profile names, without the
  330. "\fBprofile.\fP" namespace prefix. Overridden by the \fB\-P\fP option.
  331. .SS Reliance on exported environment flags
  332. Even if \fBdpkg\-buildpackage\fP exports some variables, \fBdebian/rules\fP
  333. should not rely on their presence and should instead use the
  334. respective interface to retrieve the needed values.
  335. .SS Variables set by dpkg\-architecture
  336. \fBdpkg\-architecture\fP is called with the \fB\-a\fP and \fB\-t\fP
  337. parameters forwarded. Any variable that is output by its \fB\-s\fP
  338. option is integrated in the build environment.
  339. .
  340. .SH NOTES
  341. .SS Compiler flags are no longer exported
  342. Between dpkg 1.14.17 and 1.16.1, \fBdpkg\-buildpackage\fP
  343. exported compiler flags (\fBCFLAGS\fP, \fBCXXFLAGS\fP, \fBFFLAGS\fP,
  344. \fBCPPFLAGS\fP and \fBLDFLAGS\fP) with values as returned
  345. by \fBdpkg\-buildflags\fP. This is no longer the case.
  346. .SS Default build targets
  347. \fBdpkg\-buildpackage\fP is using the \fBbuild\-arch\fP and
  348. \fBbuild\-indep\fP targets since dpkg 1.16.2. Those targets are thus
  349. mandatory. But to avoid breakages of existing packages, and ease
  350. the transition, it will fallback to using the \fBbuild\fP target
  351. if \fBmake \-f debian/rules \-qn\fP \fIbuild-target\fP returns 2 as
  352. exit code.
  353. .SH BUGS
  354. It should be possible to specify spaces and shell metacharacters
  355. and initial arguments for
  356. .IR gain-root-command " and " sign-command .
  357. .
  358. .SH SEE ALSO
  359. .ad l
  360. .nh
  361. .BR dpkg\-source (1),
  362. .BR dpkg\-architecture (1),
  363. .BR dpkg\-buildflags (1),
  364. .BR dpkg\-genchanges (1),
  365. .BR fakeroot (1),
  366. .BR lintian (1),
  367. .BR gpg2 (1),
  368. .BR gpg (1).