deb.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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_DEBIAN_<COMPONENT>_DESCRIPTION
  123. The Debian package description
  124. * Mandatory : YES
  125. * Default :
  126. - :variable:`CPACK_DEBIAN_<COMPONENT>_DESCRIPTION` (component
  127. based installers only) if set, or :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set, or
  128. - :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component
  129. based installers only) if set, or :variable:`CPACK_PACKAGE_DESCRIPTION` if set, or
  130. - content of the file specified in :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` if set
  131. If after that description is not set, :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` going to be
  132. used if set. Otherwise, :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` will be added as the first
  133. line of description as defined in `Debian Policy Manual`_.
  134. .. _Debian Policy Manual: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description
  135. .. variable:: CPACK_DEBIAN_PACKAGE_SECTION
  136. CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION
  137. Set Section control field e.g. admin, devel, doc, ...
  138. * Mandatory : YES
  139. * Default : "devel"
  140. See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
  141. .. variable:: CPACK_DEBIAN_ARCHIVE_TYPE
  142. The archive format used for creating the Debian package.
  143. * Mandatory : YES
  144. * Default : "gnutar"
  145. Possible value is:
  146. - gnutar
  147. .. note::
  148. This variable previously defaulted to the ``paxr`` value, but ``dpkg``
  149. has never supported that tar format. For backwards compatibility the
  150. ``paxr`` value will be mapped to ``gnutar`` and a deprecation message
  151. will be emitted.
  152. .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
  153. The compression used for creating the Debian package.
  154. * Mandatory : YES
  155. * Default : "gzip"
  156. Possible values are:
  157. - lzma
  158. - xz
  159. - bzip2
  160. - gzip
  161. .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY
  162. CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY
  163. Set Priority control field e.g. required, important, standard, optional,
  164. extra
  165. * Mandatory : YES
  166. * Default : "optional"
  167. See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
  168. .. variable:: CPACK_DEBIAN_PACKAGE_HOMEPAGE
  169. The URL of the web site for this package, preferably (when applicable) the
  170. site from which the original source can be obtained and any additional
  171. upstream documentation or information may be found.
  172. * Mandatory : NO
  173. * Default : :variable:`CMAKE_PROJECT_HOMEPAGE_URL`
  174. .. note::
  175. The content of this field is a simple URL without any surrounding
  176. characters such as <>.
  177. .. variable:: CPACK_DEBIAN_PACKAGE_SHLIBDEPS
  178. CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS
  179. May be set to ON in order to use ``dpkg-shlibdeps`` to generate
  180. better package dependency list.
  181. * Mandatory : NO
  182. * Default :
  183. - :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` if set or
  184. - OFF
  185. .. note::
  186. You may need set :variable:`CMAKE_INSTALL_RPATH` to an appropriate value
  187. if you use this feature, because if you don't ``dpkg-shlibdeps``
  188. may fail to find your own shared libs.
  189. See https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
  190. .. variable:: CPACK_DEBIAN_PACKAGE_DEBUG
  191. May be set when invoking cpack in order to trace debug information
  192. during the CPack DEB generator run.
  193. * Mandatory : NO
  194. * Default : -
  195. .. variable:: CPACK_DEBIAN_PACKAGE_PREDEPENDS
  196. CPACK_DEBIAN_<COMPONENT>_PACKAGE_PREDEPENDS
  197. Sets the `Pre-Depends` field of the Debian package.
  198. Like :variable:`Depends <CPACK_DEBIAN_PACKAGE_DEPENDS>`, except that it
  199. also forces ``dpkg`` to complete installation of the packages named
  200. before even starting the installation of the package which declares the
  201. pre-dependency.
  202. * Mandatory : NO
  203. * Default :
  204. - An empty string for non-component based installations
  205. - :variable:`CPACK_DEBIAN_PACKAGE_PREDEPENDS` for component-based
  206. installations.
  207. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  208. .. variable:: CPACK_DEBIAN_PACKAGE_ENHANCES
  209. CPACK_DEBIAN_<COMPONENT>_PACKAGE_ENHANCES
  210. Sets the `Enhances` field of the Debian package.
  211. Similar to :variable:`Suggests <CPACK_DEBIAN_PACKAGE_SUGGESTS>` but works
  212. in the opposite direction: declares that a package can enhance the
  213. functionality of another package.
  214. * Mandatory : NO
  215. * Default :
  216. - An empty string for non-component based installations
  217. - :variable:`CPACK_DEBIAN_PACKAGE_ENHANCES` for component-based
  218. installations.
  219. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  220. .. variable:: CPACK_DEBIAN_PACKAGE_BREAKS
  221. CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS
  222. Sets the `Breaks` field of the Debian package.
  223. When a binary package (P) declares that it breaks other packages (B),
  224. ``dpkg`` will not allow the package (P) which declares `Breaks` be
  225. **unpacked** unless the packages that will be broken (B) are deconfigured
  226. first.
  227. As long as the package (P) is configured, the previously deconfigured
  228. packages (B) cannot be reconfigured again.
  229. * Mandatory : NO
  230. * Default :
  231. - An empty string for non-component based installations
  232. - :variable:`CPACK_DEBIAN_PACKAGE_BREAKS` for component-based
  233. installations.
  234. See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks
  235. .. variable:: CPACK_DEBIAN_PACKAGE_CONFLICTS
  236. CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTS
  237. Sets the `Conflicts` field of the Debian package.
  238. When one binary package declares a conflict with another using a `Conflicts`
  239. field, ``dpkg`` will not allow them to be unpacked on the system at
  240. the same time.
  241. * Mandatory : NO
  242. * Default :
  243. - An empty string for non-component based installations
  244. - :variable:`CPACK_DEBIAN_PACKAGE_CONFLICTS` for component-based
  245. installations.
  246. See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
  247. .. note::
  248. This is a stronger restriction than
  249. :variable:`Breaks <CPACK_DEBIAN_PACKAGE_BREAKS>`, which prevents the
  250. broken package from being configured while the breaking package is in
  251. the "Unpacked" state but allows both packages to be unpacked at the same
  252. time.
  253. .. variable:: CPACK_DEBIAN_PACKAGE_PROVIDES
  254. CPACK_DEBIAN_<COMPONENT>_PACKAGE_PROVIDES
  255. Sets the `Provides` field of the Debian package.
  256. A virtual package is one which appears in the `Provides` control field of
  257. another package.
  258. * Mandatory : NO
  259. * Default :
  260. - An empty string for non-component based installations
  261. - :variable:`CPACK_DEBIAN_PACKAGE_PROVIDES` for component-based
  262. installations.
  263. See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
  264. .. variable:: CPACK_DEBIAN_PACKAGE_REPLACES
  265. CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACES
  266. Sets the `Replaces` field of the Debian package.
  267. Packages can declare in their control file that they should overwrite
  268. files in certain other packages, or completely replace other packages.
  269. * Mandatory : NO
  270. * Default :
  271. - An empty string for non-component based installations
  272. - :variable:`CPACK_DEBIAN_PACKAGE_REPLACES` for component-based
  273. installations.
  274. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  275. .. variable:: CPACK_DEBIAN_PACKAGE_RECOMMENDS
  276. CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDS
  277. Sets the `Recommends` field of the Debian package.
  278. Allows packages to declare a strong, but not absolute, dependency on other
  279. packages.
  280. * Mandatory : NO
  281. * Default :
  282. - An empty string for non-component based installations
  283. - :variable:`CPACK_DEBIAN_PACKAGE_RECOMMENDS` for component-based
  284. installations.
  285. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  286. .. variable:: CPACK_DEBIAN_PACKAGE_SUGGESTS
  287. CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTS
  288. Sets the `Suggests` field of the Debian package.
  289. Allows packages to declare a suggested package install grouping.
  290. * Mandatory : NO
  291. * Default :
  292. - An empty string for non-component based installations
  293. - :variable:`CPACK_DEBIAN_PACKAGE_SUGGESTS` for component-based
  294. installations.
  295. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  296. .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS
  297. * Mandatory : NO
  298. * Default : OFF
  299. Allows to generate shlibs control file automatically. Compatibility is defined by
  300. :variable:`CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY` variable value.
  301. .. note::
  302. Libraries are only considered if they have both library name and version
  303. set. This can be done by setting SOVERSION property with
  304. :command:`set_target_properties` command.
  305. .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY
  306. Compatibility policy for auto-generated shlibs control file.
  307. * Mandatory : NO
  308. * Default : "="
  309. Defines compatibility policy for auto-generated shlibs control file.
  310. Possible values: "=", ">="
  311. See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps
  312. .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  313. CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA
  314. This variable allow advanced user to add custom script to the
  315. control.tar.gz.
  316. Typical usage is for conffiles, postinst, postrm, prerm.
  317. * Mandatory : NO
  318. * Default : -
  319. Usage::
  320. set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  321. "${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
  322. .. note::
  323. The original permissions of the files will be used in the final
  324. package unless the variable
  325. :variable:`CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION` is set.
  326. In particular, the scripts should have the proper executable
  327. flag prior to the generation of the package.
  328. .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
  329. CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_STRICT_PERMISSION
  330. This variable indicates if the Debian policy on control files should be
  331. strictly followed.
  332. * Mandatory : NO
  333. * Default : FALSE
  334. Usage::
  335. set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
  336. .. note::
  337. This overrides the permissions on the original files, following the rules
  338. set by Debian policy
  339. https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
  340. .. variable:: CPACK_DEBIAN_PACKAGE_SOURCE
  341. CPACK_DEBIAN_<COMPONENT>_PACKAGE_SOURCE
  342. Sets the ``Source`` field of the binary Debian package.
  343. When the binary package name is not the same as the source package name
  344. (in particular when several components/binaries are generated from one
  345. source) the source from which the binary has been generated should be
  346. indicated with the field ``Source``.
  347. * Mandatory : NO
  348. * Default :
  349. - An empty string for non-component based installations
  350. - :variable:`CPACK_DEBIAN_PACKAGE_SOURCE` for component-based
  351. installations.
  352. See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
  353. .. note::
  354. This value is not interpreted. It is possible to pass an optional
  355. revision number of the referenced source package as well.
  356. Packaging of debug information
  357. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  358. Dbgsym packages contain debug symbols for debugging packaged binaries.
  359. Dbgsym packaging has its own set of variables:
  360. .. variable:: CPACK_DEBIAN_DEBUGINFO_PACKAGE
  361. CPACK_DEBIAN_<component>_DEBUGINFO_PACKAGE
  362. Enable generation of dbgsym .ddeb package(s).
  363. * Mandatory : NO
  364. * Default : OFF
  365. .. note::
  366. Binaries must contain debug symbols before packaging so use either ``Debug``
  367. or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value.
  368. Building Debian packages on Windows
  369. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  370. To communicate UNIX file permissions from the install stage
  371. to the CPack DEB generator the "cmake_mode_t" NTFS
  372. alternate data stream (ADT) is used.
  373. When a filesystem without ADT support is used only owner read/write
  374. permissions can be preserved.
  375. Reproducible packages
  376. ^^^^^^^^^^^^^^^^^^^^^
  377. The environment variable ``SOURCE_DATE_EPOCH`` may be set to a UNIX
  378. timestamp, defined as the number of seconds, excluding leap seconds,
  379. since 01 Jan 1970 00:00:00 UTC. If set, the CPack DEB generator will
  380. use its value for timestamps in the package.