deb.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. CPack DEB Generator
  2. -------------------
  3. The built in (binary) CPack DEB generator (Unix only)
  4. Variables specific to CPack Debian (DEB) generator
  5. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6. The CPack DEB generator may be used to create DEB package using :module:`CPack`.
  7. The CPack DEB generator is a :module:`CPack` generator thus it uses the
  8. ``CPACK_XXX`` variables used by :module:`CPack`.
  9. The CPack DEB generator should work on any Linux host but it will produce
  10. better deb package when Debian specific tools ``dpkg-xxx`` are usable on
  11. the build system.
  12. The CPack DEB generator has specific features which are controlled by the
  13. specifics ``CPACK_DEBIAN_XXX`` variables.
  14. ``CPACK_DEBIAN_<COMPONENT>_XXXX`` variables may be used in order to have
  15. **component** specific values. Note however that ``<COMPONENT>`` refers to
  16. the **grouping name** written in upper case. It may be either a component name
  17. or a component GROUP name.
  18. Here are some CPack DEB generator wiki resources that are here for historic
  19. reasons and are no longer maintained but may still prove useful:
  20. - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/Configuration
  21. - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/PackageGenerators#deb-unix-only
  22. List of CPack DEB generator specific variables:
  23. .. variable:: CPACK_DEB_COMPONENT_INSTALL
  24. Enable component packaging for CPackDEB
  25. * Mandatory : NO
  26. * Default : OFF
  27. If enabled (ON) multiple packages are generated. By default a single package
  28. containing files of all components is generated.
  29. .. variable:: CPACK_DEBIAN_PACKAGE_NAME
  30. CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME
  31. Set Package control field (variable is automatically transformed to lower
  32. case).
  33. * Mandatory : YES
  34. * Default :
  35. - :variable:`CPACK_PACKAGE_NAME` for non-component based
  36. installations
  37. - :variable:`CPACK_DEBIAN_PACKAGE_NAME` suffixed with -<COMPONENT>
  38. for component-based installations.
  39. See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
  40. .. variable:: CPACK_DEBIAN_FILE_NAME
  41. CPACK_DEBIAN_<COMPONENT>_FILE_NAME
  42. Package file name.
  43. * Mandatory : YES
  44. * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].deb``
  45. This may be set to ``DEB-DEFAULT`` to allow the CPack DEB generator to generate
  46. package file name by itself in deb format::
  47. <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
  48. Alternatively provided package file name must end
  49. with either ``.deb`` or ``.ipk`` suffix.
  50. .. note::
  51. Preferred setting of this variable is ``DEB-DEFAULT`` but for backward
  52. compatibility with the CPack DEB generator in CMake prior to version 3.6 this
  53. feature is disabled by default.
  54. .. note::
  55. By using non default filenames duplicate names may occur. Duplicate files
  56. get overwritten and it is up to the packager to set the variables in a
  57. manner that will prevent such errors.
  58. .. variable:: CPACK_DEBIAN_PACKAGE_EPOCH
  59. The Debian package epoch
  60. * Mandatory : No
  61. * Default : -
  62. Optional number that should be incremented when changing versioning schemas
  63. or fixing mistakes in the version numbers of older packages.
  64. .. variable:: CPACK_DEBIAN_PACKAGE_VERSION
  65. The Debian package version
  66. * Mandatory : YES
  67. * Default : :variable:`CPACK_PACKAGE_VERSION`
  68. This variable may contain only alphanumerics (A-Za-z0-9) and the characters
  69. . + - ~ (full stop, plus, hyphen, tilde) and should start with a digit. If
  70. :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` is not set then hyphens are not
  71. allowed.
  72. .. note::
  73. For backward compatibility with CMake 3.9 and lower a failed test of this
  74. variable's content is not a hard error when both
  75. :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` and
  76. :variable:`CPACK_DEBIAN_PACKAGE_EPOCH` variables are not set. An author
  77. warning is reported instead.
  78. .. variable:: CPACK_DEBIAN_PACKAGE_RELEASE
  79. The Debian package release - Debian revision number.
  80. * Mandatory : No
  81. * Default : -
  82. This is the numbering of the DEB package itself, i.e. the version of the
  83. packaging and not the version of the content (see
  84. :variable:`CPACK_DEBIAN_PACKAGE_VERSION`). One may change the default value
  85. if the previous packaging was buggy and/or you want to put here a fancy Linux
  86. distro specific numbering.
  87. .. variable:: CPACK_DEBIAN_PACKAGE_ARCHITECTURE
  88. CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE
  89. The Debian package architecture
  90. * Mandatory : YES
  91. * Default : Output of ``dpkg --print-architecture`` (or ``i386``
  92. if ``dpkg`` is not found)
  93. .. variable:: CPACK_DEBIAN_PACKAGE_DEPENDS
  94. CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS
  95. Sets the Debian dependencies of this package.
  96. * Mandatory : NO
  97. * Default :
  98. - An empty string for non-component based installations
  99. - :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS` for component-based
  100. installations.
  101. .. note::
  102. If :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` or
  103. more specifically :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS`
  104. is set for this component, the discovered dependencies will be appended
  105. to :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` instead of
  106. :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS`. If
  107. :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` is an empty string,
  108. only the automatically discovered dependencies will be set for this
  109. component.
  110. Example::
  111. set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libc6 (< 2.4)")
  112. .. variable:: CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS
  113. Sets inter component dependencies if listed with
  114. :variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables.
  115. * Mandatory : NO
  116. * Default : -
  117. .. variable:: CPACK_DEBIAN_PACKAGE_MAINTAINER
  118. The Debian package maintainer
  119. * Mandatory : YES
  120. * Default : ``CPACK_PACKAGE_CONTACT``
  121. .. variable:: CPACK_DEBIAN_PACKAGE_DESCRIPTION
  122. CPACK_COMPONENT_<COMPONENT>_DESCRIPTION
  123. The Debian package description
  124. * Mandatory : YES
  125. * Default :
  126. - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set or
  127. - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
  128. .. variable:: CPACK_DEBIAN_PACKAGE_SECTION
  129. CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION
  130. Set Section control field e.g. admin, devel, doc, ...
  131. * Mandatory : YES
  132. * Default : "devel"
  133. See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
  134. .. variable:: CPACK_DEBIAN_ARCHIVE_TYPE
  135. The archive format used for creating the Debian package.
  136. * Mandatory : YES
  137. * Default : "gnutar"
  138. Possible value is:
  139. - gnutar
  140. .. note::
  141. This variable previously defaulted to the ``paxr`` value, but ``dpkg``
  142. has never supported that tar format. For backwards compatibility the
  143. ``paxr`` value will be mapped to ``gnutar`` and a deprecation message
  144. will be emitted.
  145. .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
  146. The compression used for creating the Debian package.
  147. * Mandatory : YES
  148. * Default : "gzip"
  149. Possible values are:
  150. - lzma
  151. - xz
  152. - bzip2
  153. - gzip
  154. .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY
  155. CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY
  156. Set Priority control field e.g. required, important, standard, optional,
  157. extra
  158. * Mandatory : YES
  159. * Default : "optional"
  160. See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
  161. .. variable:: CPACK_DEBIAN_PACKAGE_HOMEPAGE
  162. The URL of the web site for this package, preferably (when applicable) the
  163. site from which the original source can be obtained and any additional
  164. upstream documentation or information may be found.
  165. * Mandatory : NO
  166. * Default : :variable:`CMAKE_PROJECT_HOMEPAGE_URL`
  167. .. note::
  168. The content of this field is a simple URL without any surrounding
  169. characters such as <>.
  170. .. variable:: CPACK_DEBIAN_PACKAGE_SHLIBDEPS
  171. CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS
  172. May be set to ON in order to use ``dpkg-shlibdeps`` to generate
  173. better package dependency list.
  174. * Mandatory : NO
  175. * Default :
  176. - :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` if set or
  177. - OFF
  178. .. note::
  179. You may need set :variable:`CMAKE_INSTALL_RPATH` to an appropriate value
  180. if you use this feature, because if you don't ``dpkg-shlibdeps``
  181. may fail to find your own shared libs.
  182. See https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
  183. .. variable:: CPACK_DEBIAN_PACKAGE_DEBUG
  184. May be set when invoking cpack in order to trace debug information
  185. during the CPack DEB generator run.
  186. * Mandatory : NO
  187. * Default : -
  188. .. variable:: CPACK_DEBIAN_PACKAGE_PREDEPENDS
  189. CPACK_DEBIAN_<COMPONENT>_PACKAGE_PREDEPENDS
  190. Sets the `Pre-Depends` field of the Debian package.
  191. Like :variable:`Depends <CPACK_DEBIAN_PACKAGE_DEPENDS>`, except that it
  192. also forces ``dpkg`` to complete installation of the packages named
  193. before even starting the installation of the package which declares the
  194. pre-dependency.
  195. * Mandatory : NO
  196. * Default :
  197. - An empty string for non-component based installations
  198. - :variable:`CPACK_DEBIAN_PACKAGE_PREDEPENDS` for component-based
  199. installations.
  200. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  201. .. variable:: CPACK_DEBIAN_PACKAGE_ENHANCES
  202. CPACK_DEBIAN_<COMPONENT>_PACKAGE_ENHANCES
  203. Sets the `Enhances` field of the Debian package.
  204. Similar to :variable:`Suggests <CPACK_DEBIAN_PACKAGE_SUGGESTS>` but works
  205. in the opposite direction: declares that a package can enhance the
  206. functionality of another package.
  207. * Mandatory : NO
  208. * Default :
  209. - An empty string for non-component based installations
  210. - :variable:`CPACK_DEBIAN_PACKAGE_ENHANCES` for component-based
  211. installations.
  212. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  213. .. variable:: CPACK_DEBIAN_PACKAGE_BREAKS
  214. CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS
  215. Sets the `Breaks` field of the Debian package.
  216. When a binary package (P) declares that it breaks other packages (B),
  217. ``dpkg`` will not allow the package (P) which declares `Breaks` be
  218. **unpacked** unless the packages that will be broken (B) are deconfigured
  219. first.
  220. As long as the package (P) is configured, the previously deconfigured
  221. packages (B) cannot be reconfigured again.
  222. * Mandatory : NO
  223. * Default :
  224. - An empty string for non-component based installations
  225. - :variable:`CPACK_DEBIAN_PACKAGE_BREAKS` for component-based
  226. installations.
  227. See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks
  228. .. variable:: CPACK_DEBIAN_PACKAGE_CONFLICTS
  229. CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTS
  230. Sets the `Conflicts` field of the Debian package.
  231. When one binary package declares a conflict with another using a `Conflicts`
  232. field, ``dpkg`` will not allow them to be unpacked on the system at
  233. the same time.
  234. * Mandatory : NO
  235. * Default :
  236. - An empty string for non-component based installations
  237. - :variable:`CPACK_DEBIAN_PACKAGE_CONFLICTS` for component-based
  238. installations.
  239. See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
  240. .. note::
  241. This is a stronger restriction than
  242. :variable:`Breaks <CPACK_DEBIAN_PACKAGE_BREAKS>`, which prevents the
  243. broken package from being configured while the breaking package is in
  244. the "Unpacked" state but allows both packages to be unpacked at the same
  245. time.
  246. .. variable:: CPACK_DEBIAN_PACKAGE_PROVIDES
  247. CPACK_DEBIAN_<COMPONENT>_PACKAGE_PROVIDES
  248. Sets the `Provides` field of the Debian package.
  249. A virtual package is one which appears in the `Provides` control field of
  250. another package.
  251. * Mandatory : NO
  252. * Default :
  253. - An empty string for non-component based installations
  254. - :variable:`CPACK_DEBIAN_PACKAGE_PROVIDES` for component-based
  255. installations.
  256. See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
  257. .. variable:: CPACK_DEBIAN_PACKAGE_REPLACES
  258. CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACES
  259. Sets the `Replaces` field of the Debian package.
  260. Packages can declare in their control file that they should overwrite
  261. files in certain other packages, or completely replace other packages.
  262. * Mandatory : NO
  263. * Default :
  264. - An empty string for non-component based installations
  265. - :variable:`CPACK_DEBIAN_PACKAGE_REPLACES` for component-based
  266. installations.
  267. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  268. .. variable:: CPACK_DEBIAN_PACKAGE_RECOMMENDS
  269. CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDS
  270. Sets the `Recommends` field of the Debian package.
  271. Allows packages to declare a strong, but not absolute, dependency on other
  272. packages.
  273. * Mandatory : NO
  274. * Default :
  275. - An empty string for non-component based installations
  276. - :variable:`CPACK_DEBIAN_PACKAGE_RECOMMENDS` for component-based
  277. installations.
  278. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  279. .. variable:: CPACK_DEBIAN_PACKAGE_SUGGESTS
  280. CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTS
  281. Sets the `Suggests` field of the Debian package.
  282. Allows packages to declare a suggested package install grouping.
  283. * Mandatory : NO
  284. * Default :
  285. - An empty string for non-component based installations
  286. - :variable:`CPACK_DEBIAN_PACKAGE_SUGGESTS` for component-based
  287. installations.
  288. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  289. .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS
  290. * Mandatory : NO
  291. * Default : OFF
  292. Allows to generate shlibs control file automatically. Compatibility is defined by
  293. :variable:`CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY` variable value.
  294. .. note::
  295. Libraries are only considered if they have both library name and version
  296. set. This can be done by setting SOVERSION property with
  297. :command:`set_target_properties` command.
  298. .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY
  299. Compatibility policy for auto-generated shlibs control file.
  300. * Mandatory : NO
  301. * Default : "="
  302. Defines compatibility policy for auto-generated shlibs control file.
  303. Possible values: "=", ">="
  304. See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps
  305. .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  306. CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA
  307. This variable allow advanced user to add custom script to the
  308. control.tar.gz.
  309. Typical usage is for conffiles, postinst, postrm, prerm.
  310. * Mandatory : NO
  311. * Default : -
  312. Usage::
  313. set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  314. "${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
  315. .. note::
  316. The original permissions of the files will be used in the final
  317. package unless the variable
  318. :variable:`CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION` is set.
  319. In particular, the scripts should have the proper executable
  320. flag prior to the generation of the package.
  321. .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
  322. CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_STRICT_PERMISSION
  323. This variable indicates if the Debian policy on control files should be
  324. strictly followed.
  325. * Mandatory : NO
  326. * Default : FALSE
  327. Usage::
  328. set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
  329. .. note::
  330. This overrides the permissions on the original files, following the rules
  331. set by Debian policy
  332. https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
  333. .. variable:: CPACK_DEBIAN_PACKAGE_SOURCE
  334. CPACK_DEBIAN_<COMPONENT>_PACKAGE_SOURCE
  335. Sets the ``Source`` field of the binary Debian package.
  336. When the binary package name is not the same as the source package name
  337. (in particular when several components/binaries are generated from one
  338. source) the source from which the binary has been generated should be
  339. indicated with the field ``Source``.
  340. * Mandatory : NO
  341. * Default :
  342. - An empty string for non-component based installations
  343. - :variable:`CPACK_DEBIAN_PACKAGE_SOURCE` for component-based
  344. installations.
  345. See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
  346. .. note::
  347. This value is not interpreted. It is possible to pass an optional
  348. revision number of the referenced source package as well.
  349. Packaging of debug information
  350. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  351. Dbgsym packages contain debug symbols for debugging packaged binaries.
  352. Dbgsym packaging has its own set of variables:
  353. .. variable:: CPACK_DEBIAN_DEBUGINFO_PACKAGE
  354. CPACK_DEBIAN_<component>_DEBUGINFO_PACKAGE
  355. Enable generation of dbgsym .ddeb package(s).
  356. * Mandatory : NO
  357. * Default : OFF
  358. .. note::
  359. Binaries must contain debug symbols before packaging so use either ``Debug``
  360. or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value.
  361. Building Debian packages on Windows
  362. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  363. To communicate UNIX file permissions from the install stage
  364. to the CPack DEB generator the "cmake_mode_t" NTFS
  365. alternate data stream (ADT) is used.
  366. When a filesystem without ADT support is used only owner read/write
  367. permissions can be preserved.
  368. Reproducible packages
  369. ^^^^^^^^^^^^^^^^^^^^^
  370. The environment variable ``SOURCE_DATE_EPOCH`` may be set to a UNIX
  371. timestamp, defined as the number of seconds, excluding leap seconds,
  372. since 01 Jan 1970 00:00:00 UTC. If set, the CPack DEB generator will
  373. use its value for timestamps in the package.