dpkg-buildpackage.1 14 KB

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