dpkg-buildpackage.1 9.4 KB

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