dpkg-buildpackage.1 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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 <http://www.gnu.org/licenses/>.
  21. .
  22. .TH dpkg\-buildpackage 1 "2013-04-02" "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) and calls \fBdpkg\-source
  37. \-\-before\-build\fP (unless \fB\-T\fP or \fB\-\-target\fP has been used).
  38. .IP \fB2.\fP 3
  39. It checks that the build-dependencies and build-conflicts
  40. are satisfied (unless \fB\-d\fP is specified).
  41. .IP \fB3.\fP 3
  42. If a specific target has been selected with the \fB\-T\fP or \fB\-\-target\fP
  43. option, it calls that target and stops here. Otherwise it calls
  44. \fBfakeroot debian/rules clean\fP to clean the build-tree (unless
  45. \fB\-nc\fP is specified).
  46. .IP \fB4.\fP 3
  47. It calls \fBdpkg\-source \-b\fP to generate the source package (unless
  48. a binary\-only build has been requested with \fB\-b\fP, \fB\-B\fP or
  49. \fB\-A\fP).
  50. .IP \fB5.\fP 3
  51. It calls \fBdebian/rules\fP \fIbuild-target\fP followed by
  52. \fBfakeroot debian/rules\fP \fIbinary-target\fP (unless a source-only
  53. build has been requested with \fB\-S\fP). Note that \fIbuild-target\fR
  54. and \fIbinary-target\fP are either \fBbuild\fP and \fBbinary\fP (default
  55. case, or if \fB\-b\fP is specified), or \fBbuild\-arch\fP and
  56. \fBbinary\-arch\fP (if \fB\-B\fP is specified), or \fBbuild\-indep\fP and
  57. \fBbinary\-indep\fP (if \fB\-A\fP is specified).
  58. .IP \fB6.\fP 3
  59. It calls \fBgpg\fP to sign the \fB.dsc\fP file (if any, unless
  60. \fB\-us\fP is specified or on UNRELEASED builds).
  61. .IP \fB7.\fP 3
  62. It calls \fBdpkg\-genchanges\fP to generate a \fB.changes\fP file.
  63. Many \fBdpkg\-buildpackage\fP options are forwarded to
  64. \fBdpkg\-genchanges\fP.
  65. .IP \fB8.\fP 3
  66. It calls \fBgpg\fP to sign the \fB.changes\fP file (unless \fB\-uc\fP
  67. is specified or on UNRELEASED builds).
  68. .IP \fB9.\fP 3
  69. If \fB\-tc\fP is specified, it will call \fBfakeroot debian/rules clean\fP
  70. again. Finally it calls \fBdpkg\-source \-\-after\-build\fP.
  71. .
  72. .SH OPTIONS
  73. .TP
  74. .B \-b
  75. Specifies a binary-only build, no source files are to be built and/or
  76. distributed. Passed to \fBdpkg\-genchanges\fP.
  77. .TP
  78. .B \-B
  79. Specifies a binary-only build, limited to architecture dependent packages.
  80. Passed to \fBdpkg\-genchanges\fP.
  81. .TP
  82. .B \-A
  83. Specifies a binary-only build, limited to architecture independent
  84. packages. Passed to \fBdpkg\-genchanges\fP.
  85. .TP
  86. .B \-S
  87. Specifies a source-only build, no binary packages need to be made.
  88. Passed to \fBdpkg\-genchanges\fP.
  89. .TP
  90. .B \-F
  91. Specifies a normal full build, binary and source packages will be built.
  92. This is the same as the default case when no build option is specified.
  93. .TP
  94. .BI \-\-target= target
  95. .TQ
  96. .BI "\-\-target " target
  97. .TQ
  98. .BI \-T target
  99. Calls \fBdebian/rules\fP \fItarget\fP after having setup the build
  100. environment and stops the package build process here. If
  101. \fB\-\-as\-root\fP is also given, then the command is executed
  102. as root (see \fB\-r\fP). Note that official targets that are required to
  103. be run as root by the Debian policy do not need this option.
  104. .TP
  105. .B \-\-as\-root
  106. Only meaningful together with \fB\-\-target\fP. Requires that the target be
  107. run with root rights.
  108. .TP
  109. .B \-si
  110. .TQ
  111. .B \-sa
  112. .TQ
  113. .B \-sd
  114. .TQ
  115. .BI \-v version
  116. .TQ
  117. .BI \-C changes-description
  118. .TQ
  119. .BI \-m maintainer-address
  120. .TQ
  121. .BI \-e maintainer-address
  122. Passed unchanged to \fBdpkg\-genchanges\fP. See its manual page.
  123. .TP
  124. .BI \-a architecture
  125. Specify the Debian architecture we build for. The architecture of the
  126. machine we build on is determined automatically, and is also the default
  127. for the host machine.
  128. .TP
  129. .BI \-t gnu-system-type
  130. Specify the GNU system type we build for. It can be used in place
  131. of \-a or as a complement to override the default GNU system type
  132. of the target Debian architecture.
  133. .TP
  134. .BI \-j jobs
  135. Number of jobs allowed to be run simultaneously, equivalent to the
  136. .BR make (1)
  137. option of the same name. Will add itself to the \fBMAKEFLAGS\fP
  138. environment variable, which should cause all subsequent make
  139. invocations to inherit the option. Also adds \fBparallel=\fP\fIjobs\fP
  140. to the \fBDEB_BUILD_OPTIONS\fP environment variable which allows
  141. debian/rules files to use this information for their own purposes.
  142. The \fBparallel=\fP\fIjobs\fP in \fBDEB_BUILD_OPTIONS\fP environment variable
  143. will override the \fB\-j\fP value if this option is given.
  144. .TP
  145. .B \-D
  146. Check build dependencies and conflicts; abort if unsatisfied. This is the
  147. default behavior.
  148. .TP
  149. .B \-d
  150. Do not check build dependencies and conflicts.
  151. .TP
  152. .B \-nc
  153. Do not clean the source tree (implies \fB\-b\fP if nothing else has been
  154. selected among \fB\-B\fP, \fB\-A\fP or \fB\-S\fP).
  155. .TP
  156. .B \-tc
  157. Clean the source tree (using
  158. .I gain-root-command
  159. .BR "debian/rules clean" )
  160. after the package has been built.
  161. .TP
  162. .BI \-r gain-root-command
  163. When
  164. .B dpkg\-buildpackage
  165. needs to execute part of the build process as root, it prefixes the
  166. command it executes with
  167. .I gain-root-command
  168. if one has been specified. Otherwise, if none has been specified,
  169. \fBfakeroot\fP will be used by default, if the command is present.
  170. .I gain-root-command
  171. should start with the name of a program on the
  172. .B PATH
  173. and will get as arguments the name of the real command to run and the
  174. arguments it should take.
  175. .I gain-root-command
  176. can include parameters (they must be space-separated) but no shell
  177. metacharacters.
  178. .I gain-root-command
  179. might typically be
  180. .BR fakeroot ", " sudo ", " super " or " really .
  181. .B su
  182. is not suitable, since it can only invoke the user's shell with
  183. .B \-c
  184. instead of passing arguments individually to the command to be run.
  185. .TP
  186. .BI \-R rules-file
  187. Building a Debian package usually involves invoking
  188. .B debian/rules
  189. as a command with several standard parameters. With this option it's
  190. possible to use another program invocation to build the package (it can
  191. include space separated parameters).
  192. Alternatively it can be used to execute the standard rules file with
  193. another make program (for example by using
  194. .B /usr/local/bin/make \-f debian/rules
  195. as \fIrules-file\fR).
  196. .TP
  197. .BI \-p sign-command
  198. When \fBdpkg\-buildpackage\fP needs to execute GPG to sign a source
  199. control (\fB.dsc\fP) file or a \fB.changes\fP file it will run
  200. \fIsign-command\fP (searching the \fBPATH\fP if necessary) instead of
  201. \fBgpg\fP. \fIsign-command\fP will get all the arguments that
  202. \fBgpg\fP would have gotten. \fIsign-command\fP
  203. should not contain spaces or any other shell metacharacters.
  204. .TP
  205. .BI \-k key-id
  206. Specify a key-ID to use when signing packages.
  207. .TP
  208. .BR \-us
  209. Do not sign the source package.
  210. .TP
  211. .BR \-uc
  212. Do not sign the \fB.changes\fP file.
  213. .TP
  214. .BR \-\-force\-sign
  215. Force the signing of the resulting files (since dpkg 1.17.0),
  216. regardless of \fB\-us\fP or \fB\-uc\fP or other internal heuristics.
  217. .TP
  218. .BR \-i [\fIregexp\fP]
  219. .TQ
  220. .BI \-I [\fIpattern\fP]
  221. .TQ
  222. .BR \-s [ nsAkurKUR ]
  223. .TQ
  224. .BR \-z ", " \-Z
  225. Passed unchanged to \fBdpkg\-source\fP. See its manual page.
  226. .TP
  227. .BI \-\-source\-option= opt
  228. Pass option \fIopt\fP to \fBdpkg\-source\fP.
  229. .TP
  230. .BI \-\-changes\-option= opt
  231. Pass option \fIopt\fP to \fBdpkg\-genchanges\fP.
  232. .TP
  233. .BI \-\-admindir= dir
  234. .TQ
  235. .BI "\-\-admindir " dir
  236. Change the location of the \fBdpkg\fR database. The default location is
  237. \fI/var/lib/dpkg\fP.
  238. .TP
  239. .BR \-? ", " \-\-help
  240. Show the usage message and exit.
  241. .TP
  242. .BR \-\-version
  243. Show the version and exit.
  244. .
  245. .SH ENVIRONMENT
  246. Even if \fBdpkg\-buildpackage\fP exports some variables, \fBdebian/rules\fP
  247. should not rely on their presence and should instead use the
  248. respective interface to retrieve the needed values.
  249. .SS Variables set by dpkg\-architecture
  250. \fBdpkg\-architecture\fP is called with the \fB\-a\fP and \fB\-t\fP
  251. parameters forwarded. Any variable that is output by its \fB\-s\fP
  252. option is integrated in the build environment.
  253. .
  254. .SH NOTES
  255. .SS Compiler flags are no longer exported
  256. Between dpkg 1.14.17 and 1.16.1, \fBdpkg\-buildpackage\fP
  257. exported compiler flags (\fBCFLAGS\fP, \fBCXXFLAGS\fP, \fBFFLAGS\fP,
  258. \fBCPPFLAGS\fP and \fBLDFLAGS\fP) with values as returned
  259. by \fBdpkg\-buildflags\fP. This is no longer the case.
  260. .SS Default build targets
  261. \fBdpkg\-buildpackage\fP is using the \fBbuild\-arch\fP and
  262. \fBbuild\-indep\fP targets since dpkg 1.16.2. Those targets are thus
  263. mandatory. But to avoid breakages of existing packages, and ease
  264. the transition, it will fallback to using the \fBbuild\fP target
  265. if \fBmake \-f debian/rules \-qn\fP \fIbuild-target\fP returns 2 as
  266. exit code.
  267. .SH BUGS
  268. It should be possible to specify spaces and shell metacharacters in
  269. and initial arguments for
  270. .IR gain-root-command " and " sign-command .
  271. .
  272. .SH SEE ALSO
  273. .ad l
  274. .nh
  275. .BR dpkg\-source (1),
  276. .BR dpkg\-architecture (1),
  277. .BR dpkg\-buildflags (1),
  278. .BR dpkg\-genchanges (1),
  279. .BR fakeroot (1),
  280. .BR gpg (1).