CPackDeb.cmake 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #.rst:
  4. # CPackDeb
  5. # --------
  6. #
  7. # The built in (binary) CPack Deb generator (Unix only)
  8. #
  9. # Variables specific to CPack Debian (DEB) generator
  10. # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  11. #
  12. # CPackDeb may be used to create Deb package using :module:`CPack`.
  13. # CPackDeb is a :module:`CPack` generator thus it uses the ``CPACK_XXX``
  14. # variables used by :module:`CPack`.
  15. #
  16. # CPackDeb generator should work on any Linux host but it will produce
  17. # better deb package when Debian specific tools ``dpkg-xxx`` are usable on
  18. # the build system.
  19. #
  20. # CPackDeb has specific features which are controlled by the specifics
  21. # :code:`CPACK_DEBIAN_XXX` variables.
  22. #
  23. # :code:`CPACK_DEBIAN_<COMPONENT>_XXXX` variables may be used in order to have
  24. # **component** specific values. Note however that ``<COMPONENT>`` refers to
  25. # the **grouping name** written in upper case. It may be either a component name
  26. # or a component GROUP name.
  27. #
  28. # Here are some CPackDeb wiki resources that are here for historic reasons and
  29. # are no longer maintained but may still prove useful:
  30. #
  31. # - https://cmake.org/Wiki/CMake:CPackConfiguration
  32. # - https://cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
  33. #
  34. # List of CPackDEB specific variables:
  35. #
  36. # .. variable:: CPACK_DEB_COMPONENT_INSTALL
  37. #
  38. # Enable component packaging for CPackDEB
  39. #
  40. # * Mandatory : NO
  41. # * Default : OFF
  42. #
  43. # If enabled (ON) multiple packages are generated. By default a single package
  44. # containing files of all components is generated.
  45. #
  46. # .. variable:: CPACK_DEBIAN_PACKAGE_NAME
  47. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME
  48. #
  49. # Set Package control field (variable is automatically transformed to lower
  50. # case).
  51. #
  52. # * Mandatory : YES
  53. # * Default :
  54. #
  55. # - :variable:`CPACK_PACKAGE_NAME` for non-component based
  56. # installations
  57. # - :variable:`CPACK_DEBIAN_PACKAGE_NAME` suffixed with -<COMPONENT>
  58. # for component-based installations.
  59. #
  60. # See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
  61. #
  62. # .. variable:: CPACK_DEBIAN_FILE_NAME
  63. # CPACK_DEBIAN_<COMPONENT>_FILE_NAME
  64. #
  65. # Package file name.
  66. #
  67. # * Mandatory : YES
  68. # * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].deb``
  69. #
  70. # This may be set to ``DEB-DEFAULT`` to allow CPackDeb to generate package file
  71. # name by itself in deb format::
  72. #
  73. # <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
  74. #
  75. # Alternatively provided package file name must end
  76. # with either ``.deb`` or ``.ipk`` suffix.
  77. #
  78. # .. note::
  79. #
  80. # Preferred setting of this variable is ``DEB-DEFAULT`` but for backward
  81. # compatibility with CPackDeb in CMake prior to version 3.6 this feature
  82. # is disabled by default.
  83. #
  84. # .. note::
  85. #
  86. # By using non default filenames duplicate names may occur. Duplicate files
  87. # get overwritten and it is up to the packager to set the variables in a
  88. # manner that will prevent such errors.
  89. #
  90. # .. variable:: CPACK_DEBIAN_PACKAGE_EPOCH
  91. #
  92. # The Debian package epoch
  93. #
  94. # * Mandatory : No
  95. # * Default : -
  96. #
  97. # Optional number that should be incremented when changing versioning schemas
  98. # or fixing mistakes in the version numbers of older packages.
  99. #
  100. # .. variable:: CPACK_DEBIAN_PACKAGE_VERSION
  101. #
  102. # The Debian package version
  103. #
  104. # * Mandatory : YES
  105. # * Default : :variable:`CPACK_PACKAGE_VERSION`
  106. #
  107. # This variable may contain only alphanumerics (A-Za-z0-9) and the characters
  108. # . + - ~ (full stop, plus, hyphen, tilde) and should start with a digit. If
  109. # :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` is not set then hyphens are not
  110. # allowed.
  111. #
  112. # .. variable:: CPACK_DEBIAN_PACKAGE_RELEASE
  113. #
  114. # The Debian package release - Debian revision number.
  115. #
  116. # * Mandatory : No
  117. # * Default : -
  118. #
  119. # This is the numbering of the DEB package itself, i.e. the version of the
  120. # packaging and not the version of the content (see
  121. # :variable:`CPACK_DEBIAN_PACKAGE_VERSION`). One may change the default value
  122. # if the previous packaging was buggy and/or you want to put here a fancy Linux
  123. # distro specific numbering.
  124. #
  125. # .. variable:: CPACK_DEBIAN_PACKAGE_ARCHITECTURE
  126. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE
  127. #
  128. # The Debian package architecture
  129. #
  130. # * Mandatory : YES
  131. # * Default : Output of :code:`dpkg --print-architecture` (or :code:`i386`
  132. # if :code:`dpkg` is not found)
  133. #
  134. # .. variable:: CPACK_DEBIAN_PACKAGE_DEPENDS
  135. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS
  136. #
  137. # Sets the Debian dependencies of this package.
  138. #
  139. # * Mandatory : NO
  140. # * Default :
  141. #
  142. # - An empty string for non-component based installations
  143. # - :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS` for component-based
  144. # installations.
  145. #
  146. # .. note::
  147. #
  148. # If :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` or
  149. # more specifically :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS`
  150. # is set for this component, the discovered dependencies will be appended
  151. # to :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` instead of
  152. # :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS`. If
  153. # :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` is an empty string,
  154. # only the automatically discovered dependencies will be set for this
  155. # component.
  156. #
  157. # Example::
  158. #
  159. # set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libc6 (< 2.4)")
  160. #
  161. # .. variable:: CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS
  162. #
  163. # Sets inter component dependencies if listed with
  164. # :variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables.
  165. #
  166. # * Mandatory : NO
  167. # * Default : -
  168. #
  169. # .. variable:: CPACK_DEBIAN_PACKAGE_MAINTAINER
  170. #
  171. # The Debian package maintainer
  172. #
  173. # * Mandatory : YES
  174. # * Default : :code:`CPACK_PACKAGE_CONTACT`
  175. #
  176. # .. variable:: CPACK_DEBIAN_PACKAGE_DESCRIPTION
  177. # CPACK_COMPONENT_<COMPONENT>_DESCRIPTION
  178. #
  179. # The Debian package description
  180. #
  181. # * Mandatory : YES
  182. # * Default :
  183. #
  184. # - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set or
  185. # - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
  186. #
  187. #
  188. # .. variable:: CPACK_DEBIAN_PACKAGE_SECTION
  189. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION
  190. #
  191. # Set Section control field e.g. admin, devel, doc, ...
  192. #
  193. # * Mandatory : YES
  194. # * Default : "devel"
  195. #
  196. # See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
  197. #
  198. # .. variable:: CPACK_DEBIAN_ARCHIVE_TYPE
  199. #
  200. # The archive format used for creating the Debian package.
  201. #
  202. # * Mandatory : YES
  203. # * Default : "paxr"
  204. #
  205. # Possible values are:
  206. #
  207. # - paxr
  208. # - gnutar
  209. #
  210. # .. note::
  211. #
  212. # Default pax archive format is the most portable format and generates
  213. # packages that do not treat sparse files specially.
  214. # GNU tar format on the other hand supports longer filenames.
  215. #
  216. # .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
  217. #
  218. # The compression used for creating the Debian package.
  219. #
  220. # * Mandatory : YES
  221. # * Default : "gzip"
  222. #
  223. # Possible values are:
  224. #
  225. # - lzma
  226. # - xz
  227. # - bzip2
  228. # - gzip
  229. #
  230. # .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY
  231. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY
  232. #
  233. # Set Priority control field e.g. required, important, standard, optional,
  234. # extra
  235. #
  236. # * Mandatory : YES
  237. # * Default : "optional"
  238. #
  239. # See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
  240. #
  241. # .. variable:: CPACK_DEBIAN_PACKAGE_HOMEPAGE
  242. #
  243. # The URL of the web site for this package, preferably (when applicable) the
  244. # site from which the original source can be obtained and any additional
  245. # upstream documentation or information may be found.
  246. #
  247. # * Mandatory : NO
  248. # * Default : -
  249. #
  250. # .. note::
  251. #
  252. # The content of this field is a simple URL without any surrounding
  253. # characters such as <>.
  254. #
  255. # .. variable:: CPACK_DEBIAN_PACKAGE_SHLIBDEPS
  256. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS
  257. #
  258. # May be set to ON in order to use :code:`dpkg-shlibdeps` to generate
  259. # better package dependency list.
  260. #
  261. # * Mandatory : NO
  262. # * Default :
  263. #
  264. # - :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` if set or
  265. # - OFF
  266. #
  267. # .. note::
  268. #
  269. # You may need set :variable:`CMAKE_INSTALL_RPATH` to an appropriate value
  270. # if you use this feature, because if you don't :code:`dpkg-shlibdeps`
  271. # may fail to find your own shared libs.
  272. # See https://cmake.org/Wiki/CMake_RPATH_handling.
  273. #
  274. # .. variable:: CPACK_DEBIAN_PACKAGE_DEBUG
  275. #
  276. # May be set when invoking cpack in order to trace debug information
  277. # during CPackDeb run.
  278. #
  279. # * Mandatory : NO
  280. # * Default : -
  281. #
  282. # .. variable:: CPACK_DEBIAN_PACKAGE_PREDEPENDS
  283. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_PREDEPENDS
  284. #
  285. # Sets the `Pre-Depends` field of the Debian package.
  286. # Like :variable:`Depends <CPACK_DEBIAN_PACKAGE_DEPENDS>`, except that it
  287. # also forces :code:`dpkg` to complete installation of the packages named
  288. # before even starting the installation of the package which declares the
  289. # pre-dependency.
  290. #
  291. # * Mandatory : NO
  292. # * Default :
  293. #
  294. # - An empty string for non-component based installations
  295. # - :variable:`CPACK_DEBIAN_PACKAGE_PREDEPENDS` for component-based
  296. # installations.
  297. #
  298. # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  299. #
  300. # .. variable:: CPACK_DEBIAN_PACKAGE_ENHANCES
  301. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_ENHANCES
  302. #
  303. # Sets the `Enhances` field of the Debian package.
  304. # Similar to :variable:`Suggests <CPACK_DEBIAN_PACKAGE_SUGGESTS>` but works
  305. # in the opposite direction: declares that a package can enhance the
  306. # functionality of another package.
  307. #
  308. # * Mandatory : NO
  309. # * Default :
  310. #
  311. # - An empty string for non-component based installations
  312. # - :variable:`CPACK_DEBIAN_PACKAGE_ENHANCES` for component-based
  313. # installations.
  314. #
  315. # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  316. #
  317. # .. variable:: CPACK_DEBIAN_PACKAGE_BREAKS
  318. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS
  319. #
  320. # Sets the `Breaks` field of the Debian package.
  321. # When a binary package (P) declares that it breaks other packages (B),
  322. # :code:`dpkg` will not allow the package (P) which declares `Breaks` be
  323. # **unpacked** unless the packages that will be broken (B) are deconfigured
  324. # first.
  325. # As long as the package (P) is configured, the previously deconfigured
  326. # packages (B) cannot be reconfigured again.
  327. #
  328. # * Mandatory : NO
  329. # * Default :
  330. #
  331. # - An empty string for non-component based installations
  332. # - :variable:`CPACK_DEBIAN_PACKAGE_BREAKS` for component-based
  333. # installations.
  334. #
  335. # See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks
  336. #
  337. # .. variable:: CPACK_DEBIAN_PACKAGE_CONFLICTS
  338. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTS
  339. #
  340. # Sets the `Conflicts` field of the Debian package.
  341. # When one binary package declares a conflict with another using a `Conflicts`
  342. # field, :code:`dpkg` will not allow them to be unpacked on the system at
  343. # the same time.
  344. #
  345. # * Mandatory : NO
  346. # * Default :
  347. #
  348. # - An empty string for non-component based installations
  349. # - :variable:`CPACK_DEBIAN_PACKAGE_CONFLICTS` for component-based
  350. # installations.
  351. #
  352. # See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
  353. #
  354. # .. note::
  355. #
  356. # This is a stronger restriction than
  357. # :variable:`Breaks <CPACK_DEBIAN_PACKAGE_BREAKS>`, which prevents the
  358. # broken package from being configured while the breaking package is in
  359. # the "Unpacked" state but allows both packages to be unpacked at the same
  360. # time.
  361. #
  362. # .. variable:: CPACK_DEBIAN_PACKAGE_PROVIDES
  363. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_PROVIDES
  364. #
  365. # Sets the `Provides` field of the Debian package.
  366. # A virtual package is one which appears in the `Provides` control field of
  367. # another package.
  368. #
  369. # * Mandatory : NO
  370. # * Default :
  371. #
  372. # - An empty string for non-component based installations
  373. # - :variable:`CPACK_DEBIAN_PACKAGE_PROVIDES` for component-based
  374. # installations.
  375. #
  376. # See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
  377. #
  378. # .. variable:: CPACK_DEBIAN_PACKAGE_REPLACES
  379. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACES
  380. #
  381. # Sets the `Replaces` field of the Debian package.
  382. # Packages can declare in their control file that they should overwrite
  383. # files in certain other packages, or completely replace other packages.
  384. #
  385. # * Mandatory : NO
  386. # * Default :
  387. #
  388. # - An empty string for non-component based installations
  389. # - :variable:`CPACK_DEBIAN_PACKAGE_REPLACES` for component-based
  390. # installations.
  391. #
  392. # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  393. #
  394. # .. variable:: CPACK_DEBIAN_PACKAGE_RECOMMENDS
  395. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDS
  396. #
  397. # Sets the `Recommends` field of the Debian package.
  398. # Allows packages to declare a strong, but not absolute, dependency on other
  399. # packages.
  400. #
  401. # * Mandatory : NO
  402. # * Default :
  403. #
  404. # - An empty string for non-component based installations
  405. # - :variable:`CPACK_DEBIAN_PACKAGE_RECOMMENDS` for component-based
  406. # installations.
  407. #
  408. # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  409. #
  410. # .. variable:: CPACK_DEBIAN_PACKAGE_SUGGESTS
  411. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTS
  412. #
  413. # Sets the `Suggests` field of the Debian package.
  414. # Allows packages to declare a suggested package install grouping.
  415. #
  416. # * Mandatory : NO
  417. # * Default :
  418. #
  419. # - An empty string for non-component based installations
  420. # - :variable:`CPACK_DEBIAN_PACKAGE_SUGGESTS` for component-based
  421. # installations.
  422. #
  423. # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  424. #
  425. # .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS
  426. #
  427. # * Mandatory : NO
  428. # * Default : OFF
  429. #
  430. # Allows to generate shlibs control file automatically. Compatibility is defined by
  431. # :variable:`CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY` variable value.
  432. #
  433. # .. note::
  434. #
  435. # Libraries are only considered if they have both library name and version
  436. # set. This can be done by setting SOVERSION property with
  437. # :command:`set_target_properties` command.
  438. #
  439. # .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY
  440. #
  441. # Compatibility policy for auto-generated shlibs control file.
  442. #
  443. # * Mandatory : NO
  444. # * Default : "="
  445. #
  446. # Defines compatibility policy for auto-generated shlibs control file.
  447. # Possible values: "=", ">="
  448. #
  449. # See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps
  450. #
  451. # .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  452. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA
  453. #
  454. # This variable allow advanced user to add custom script to the
  455. # control.tar.gz.
  456. # Typical usage is for conffiles, postinst, postrm, prerm.
  457. #
  458. # * Mandatory : NO
  459. # * Default : -
  460. #
  461. # Usage::
  462. #
  463. # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  464. # "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
  465. #
  466. # .. note::
  467. #
  468. # The original permissions of the files will be used in the final
  469. # package unless the variable
  470. # :variable:`CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION` is set.
  471. # In particular, the scripts should have the proper executable
  472. # flag prior to the generation of the package.
  473. #
  474. # .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
  475. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_STRICT_PERMISSION
  476. #
  477. # This variable indicates if the Debian policy on control files should be
  478. # strictly followed.
  479. #
  480. # * Mandatory : NO
  481. # * Default : FALSE
  482. #
  483. # Usage::
  484. #
  485. # set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
  486. #
  487. # .. note::
  488. #
  489. # This overrides the permissions on the original files, following the rules
  490. # set by Debian policy
  491. # https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
  492. #
  493. # .. variable:: CPACK_DEBIAN_PACKAGE_SOURCE
  494. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_SOURCE
  495. #
  496. # Sets the ``Source`` field of the binary Debian package.
  497. # When the binary package name is not the same as the source package name
  498. # (in particular when several components/binaries are generated from one
  499. # source) the source from which the binary has been generated should be
  500. # indicated with the field ``Source``.
  501. #
  502. # * Mandatory : NO
  503. # * Default :
  504. #
  505. # - An empty string for non-component based installations
  506. # - :variable:`CPACK_DEBIAN_PACKAGE_SOURCE` for component-based
  507. # installations.
  508. #
  509. # See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
  510. #
  511. # .. note::
  512. #
  513. # This value is not interpreted. It is possible to pass an optional
  514. # revision number of the referenced source package as well.
  515. #
  516. # Building Debian packages on Windows
  517. # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  518. #
  519. # To communicate UNIX file permissions from the install stage
  520. # to the CPack DEB generator the "cmake_mode_t" NTFS
  521. # alternate data stream (ADT) is used.
  522. #
  523. # When a filesystem without ADT support is used only owner read/write
  524. # permissions can be preserved.
  525. # CPack script for creating Debian package
  526. # Author: Mathieu Malaterre
  527. #
  528. # http://wiki.debian.org/HowToPackageForDebian
  529. if(CMAKE_BINARY_DIR)
  530. message(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.")
  531. endif()
  532. function(cpack_deb_variable_fallback OUTPUT_VAR_NAME)
  533. set(FALLBACK_VAR_NAMES ${ARGN})
  534. foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
  535. if(${variable_name})
  536. set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
  537. break()
  538. endif()
  539. endforeach()
  540. endfunction()
  541. function(get_component_package_name var component)
  542. string(TOUPPER "${component}" component_upcase)
  543. if(CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME)
  544. string(TOLOWER "${CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME}" package_name)
  545. else()
  546. string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${component}" package_name)
  547. endif()
  548. set("${var}" "${package_name}" PARENT_SCOPE)
  549. endfunction()
  550. #extract library name and version for given shared object
  551. function(extract_so_info shared_object libname version)
  552. if(READELF_EXECUTABLE)
  553. execute_process(COMMAND "${READELF_EXECUTABLE}" -d "${shared_object}"
  554. WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
  555. RESULT_VARIABLE result
  556. OUTPUT_VARIABLE output
  557. ERROR_QUIET
  558. OUTPUT_STRIP_TRAILING_WHITESPACE)
  559. if(result EQUAL 0)
  560. string(REGEX MATCH "\\(SONAME\\)[^\n]*\\[([^\n]+)\\.so\\.([^\n]*)\\]" soname "${output}")
  561. set(${libname} "${CMAKE_MATCH_1}" PARENT_SCOPE)
  562. set(${version} "${CMAKE_MATCH_2}" PARENT_SCOPE)
  563. else()
  564. message(WARNING "Error running readelf for \"${shared_object}\"")
  565. endif()
  566. else()
  567. message(FATAL_ERROR "Readelf utility is not available.")
  568. endif()
  569. endfunction()
  570. function(cpack_deb_prepare_package_vars)
  571. # CPACK_DEBIAN_PACKAGE_SHLIBDEPS
  572. # If specify OFF, only user depends are used
  573. if(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
  574. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF)
  575. endif()
  576. set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_PATH}")
  577. # per component automatic discover: some of the component might not have
  578. # binaries.
  579. if(CPACK_DEB_PACKAGE_COMPONENT)
  580. string(TOUPPER "${CPACK_DEB_PACKAGE_COMPONENT}" _local_component_name)
  581. set(_component_shlibdeps_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_SHLIBDEPS")
  582. # if set, overrides the global configuration
  583. if(DEFINED ${_component_shlibdeps_var})
  584. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS "${${_component_shlibdeps_var}}")
  585. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  586. message("CPackDeb Debug: component '${CPACK_DEB_PACKAGE_COMPONENT}' dpkg-shlibdeps set to ${CPACK_DEBIAN_PACKAGE_SHLIBDEPS}")
  587. endif()
  588. endif()
  589. endif()
  590. if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OR CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
  591. # Generating binary list - Get type of all install files
  592. cmake_policy(PUSH)
  593. # Tell file(GLOB_RECURSE) not to follow directory symlinks
  594. # even if the project does not set this policy to NEW.
  595. cmake_policy(SET CMP0009 NEW)
  596. file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*")
  597. cmake_policy(POP)
  598. find_program(FILE_EXECUTABLE file)
  599. if(NOT FILE_EXECUTABLE)
  600. message(FATAL_ERROR "CPackDeb: file utility is not available. CPACK_DEBIAN_PACKAGE_SHLIBDEPS and CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS options are not available.")
  601. endif()
  602. # get file info so that we can determine if file is executable or not
  603. unset(CPACK_DEB_INSTALL_FILES)
  604. foreach(FILE_ IN LISTS FILE_PATHS_)
  605. execute_process(COMMAND env LC_ALL=C ${FILE_EXECUTABLE} "./${FILE_}"
  606. WORKING_DIRECTORY "${WDIR}"
  607. RESULT_VARIABLE FILE_RESULT_
  608. OUTPUT_VARIABLE INSTALL_FILE_)
  609. if(NOT FILE_RESULT_ EQUAL 0)
  610. message (FATAL_ERROR "CPackDeb: execution of command: '${FILE_EXECUTABLE} ./${FILE_}' failed with exit code: ${FILE_RESULT_}")
  611. endif()
  612. list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}")
  613. endforeach()
  614. # Only dynamically linked ELF files are included
  615. # Extract only file name infront of ":"
  616. foreach(_FILE IN LISTS CPACK_DEB_INSTALL_FILES)
  617. if(_FILE MATCHES "ELF.*dynamically linked")
  618. string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
  619. list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}")
  620. set(CONTAINS_EXECUTABLE_FILES_ TRUE)
  621. endif()
  622. if(_FILE MATCHES "ELF.*shared object")
  623. string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
  624. list(APPEND CPACK_DEB_SHARED_OBJECT_FILES "${CMAKE_MATCH_1}")
  625. endif()
  626. endforeach()
  627. endif()
  628. if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
  629. # dpkg-shlibdeps is a Debian utility for generating dependency list
  630. find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps)
  631. if(SHLIBDEPS_EXECUTABLE)
  632. # Check version of the dpkg-shlibdeps tool using CPackDEB method
  633. execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --version
  634. OUTPUT_VARIABLE _TMP_VERSION
  635. ERROR_QUIET
  636. OUTPUT_STRIP_TRAILING_WHITESPACE)
  637. if(_TMP_VERSION MATCHES "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)")
  638. set(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
  639. else()
  640. set(SHLIBDEPS_EXECUTABLE_VERSION "")
  641. endif()
  642. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  643. message("CPackDeb Debug: dpkg-shlibdeps --version output is '${_TMP_VERSION}'")
  644. message("CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>")
  645. endif()
  646. if(CONTAINS_EXECUTABLE_FILES_)
  647. message("CPackDeb: - Generating dependency list")
  648. # Create blank control file for running dpkg-shlibdeps
  649. # There might be some other way to invoke dpkg-shlibdeps without creating this file
  650. # but standard debian package should not have anything that can collide with this file or directory
  651. file(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian)
  652. file(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "")
  653. # Create a DEBIAN directory so that dpkg-shlibdeps can find the package dir when resolving $ORIGIN.
  654. file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN")
  655. # Add --ignore-missing-info if the tool supports it
  656. execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --help
  657. OUTPUT_VARIABLE _TMP_HELP
  658. ERROR_QUIET
  659. OUTPUT_STRIP_TRAILING_WHITESPACE)
  660. if(_TMP_HELP MATCHES "--ignore-missing-info")
  661. set(IGNORE_MISSING_INFO_FLAG "--ignore-missing-info")
  662. endif()
  663. # Execute dpkg-shlibdeps
  664. # --ignore-missing-info : allow dpkg-shlibdeps to run even if some libs do not belong to a package
  665. # -O : print to STDOUT
  666. execute_process(COMMAND ${SHLIBDEPS_EXECUTABLE} ${IGNORE_MISSING_INFO_FLAG} -O ${CPACK_DEB_BINARY_FILES}
  667. WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
  668. OUTPUT_VARIABLE SHLIBDEPS_OUTPUT
  669. RESULT_VARIABLE SHLIBDEPS_RESULT
  670. ERROR_VARIABLE SHLIBDEPS_ERROR
  671. OUTPUT_STRIP_TRAILING_WHITESPACE )
  672. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  673. # dpkg-shlibdeps will throw some warnings if some input files are not binary
  674. message( "CPackDeb Debug: dpkg-shlibdeps warnings \n${SHLIBDEPS_ERROR}")
  675. endif()
  676. if(NOT SHLIBDEPS_RESULT EQUAL 0)
  677. message (FATAL_ERROR "CPackDeb: dpkg-shlibdeps: '${SHLIBDEPS_ERROR}';\n"
  678. "executed command: '${SHLIBDEPS_EXECUTABLE} ${IGNORE_MISSING_INFO_FLAG} -O ${CPACK_DEB_BINARY_FILES}';\n"
  679. "found files: '${INSTALL_FILE_}';\n"
  680. "files info: '${CPACK_DEB_INSTALL_FILES}';\n"
  681. "binary files: '${CPACK_DEB_BINARY_FILES}'")
  682. endif()
  683. #Get rid of prefix generated by dpkg-shlibdeps
  684. string(REGEX REPLACE "^.*Depends=" "" CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS "${SHLIBDEPS_OUTPUT}")
  685. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  686. message("CPackDeb Debug: Found dependency: ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS} from output ${SHLIBDEPS_OUTPUT}")
  687. endif()
  688. # Remove blank control file
  689. # Might not be safe if package actual contain file or directory named debian
  690. file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian")
  691. # remove temporary directory that was created only for dpkg-shlibdeps execution
  692. file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN")
  693. else()
  694. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  695. message(AUTHOR_WARNING "CPackDeb Debug: Using only user-provided depends because package does not contain executable files that link to shared libraries.")
  696. endif()
  697. endif()
  698. else()
  699. message("CPackDeb: Using only user-provided dependencies because dpkg-shlibdeps is not found.")
  700. endif()
  701. else()
  702. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  703. message("CPackDeb Debug: Using only user-provided dependencies")
  704. endif()
  705. endif()
  706. # Let's define the control file found in debian package:
  707. # Binary package:
  708. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles
  709. # DEBIAN/control
  710. # debian policy enforce lower case for package name
  711. # Package: (mandatory)
  712. if(NOT CPACK_DEBIAN_PACKAGE_NAME)
  713. string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
  714. endif()
  715. # Version: (mandatory)
  716. if(NOT CPACK_DEBIAN_PACKAGE_VERSION)
  717. if(NOT CPACK_PACKAGE_VERSION)
  718. message(FATAL_ERROR "CPackDeb: Debian package requires a package version")
  719. endif()
  720. set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
  721. endif()
  722. if(NOT CPACK_DEBIAN_PACKAGE_VERSION MATCHES "^[0-9][A-Za-z0-9.+-~]*$")
  723. message(FATAL_ERROR
  724. "CPackDeb: Debian package version must confirm to \"^[0-9][A-Za-z0-9.+-~]*$\" regex!")
  725. endif()
  726. if(CPACK_DEBIAN_PACKAGE_RELEASE)
  727. if(NOT CPACK_DEBIAN_PACKAGE_RELEASE MATCHES "^[A-Za-z0-9.+~]+$")
  728. message(FATAL_ERROR
  729. "CPackDeb: Debian package release must confirm to \"^[A-Za-z0-9.+~]+$\" regex!")
  730. endif()
  731. string(APPEND CPACK_DEBIAN_PACKAGE_VERSION
  732. "-${CPACK_DEBIAN_PACKAGE_RELEASE}")
  733. elseif(CPACK_DEBIAN_PACKAGE_VERSION MATCHES ".*-.*")
  734. message(FATAL_ERROR
  735. "CPackDeb: Debian package version must not contain hyphens when CPACK_DEBIAN_PACKAGE_RELEASE is not provided!")
  736. endif()
  737. if(CPACK_DEBIAN_PACKAGE_EPOCH)
  738. if(NOT CPACK_DEBIAN_PACKAGE_EPOCH MATCHES "^[0-9]+$")
  739. message(FATAL_ERROR
  740. "CPackDeb: Debian package epoch must confirm to \"^[0-9]+$\" regex!")
  741. endif()
  742. set(CPACK_DEBIAN_PACKAGE_VERSION
  743. "${CPACK_DEBIAN_PACKAGE_EPOCH}:${CPACK_DEBIAN_PACKAGE_VERSION}")
  744. endif()
  745. # Architecture: (mandatory)
  746. if(CPACK_DEB_PACKAGE_COMPONENT AND CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE)
  747. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE}")
  748. elseif(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
  749. # There is no such thing as i686 architecture on debian, you should use i386 instead
  750. # $ dpkg --print-architecture
  751. find_program(DPKG_CMD dpkg)
  752. if(NOT DPKG_CMD)
  753. message(STATUS "CPackDeb: Can not find dpkg in your path, default to i386.")
  754. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
  755. endif()
  756. execute_process(COMMAND "${DPKG_CMD}" --print-architecture
  757. OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
  758. OUTPUT_STRIP_TRAILING_WHITESPACE
  759. )
  760. endif()
  761. # Source: (optional)
  762. # in case several packages are constructed from a unique source
  763. # (multipackaging), the source may be indicated as well.
  764. # The source might contain a version if the generated package
  765. # version is different from the source version
  766. if(NOT CPACK_DEBIAN_PACKAGE_SOURCE)
  767. set(CPACK_DEBIAN_PACKAGE_SOURCE "")
  768. endif()
  769. # have a look at get_property(result GLOBAL PROPERTY ENABLED_FEATURES),
  770. # this returns the successful find_package() calls, maybe this can help
  771. # Depends:
  772. # You should set: DEBIAN_PACKAGE_DEPENDS
  773. # TODO: automate 'objdump -p | grep NEEDED'
  774. # if per-component variable, overrides the global CPACK_DEBIAN_PACKAGE_${variable_type_}
  775. # automatic dependency discovery will be performed afterwards.
  776. if(CPACK_DEB_PACKAGE_COMPONENT)
  777. foreach(value_type_ DEPENDS RECOMMENDS SUGGESTS PREDEPENDS ENHANCES BREAKS CONFLICTS PROVIDES REPLACES SOURCE SECTION PRIORITY NAME)
  778. set(_component_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_${value_type_}")
  779. # if set, overrides the global variable
  780. if(DEFINED ${_component_var})
  781. set(CPACK_DEBIAN_PACKAGE_${value_type_} "${${_component_var}}")
  782. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  783. message("CPackDeb Debug: component '${_local_component_name}' ${value_type_} "
  784. "value set to '${CPACK_DEBIAN_PACKAGE_${value_type_}}'")
  785. endif()
  786. endif()
  787. endforeach()
  788. if(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS)
  789. set(COMPONENT_DEPENDS "")
  790. foreach (_PACK ${CPACK_COMPONENT_${_local_component_name}_DEPENDS})
  791. get_component_package_name(_PACK_NAME "${_PACK}")
  792. if(COMPONENT_DEPENDS)
  793. set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION}), ${COMPONENT_DEPENDS}")
  794. else()
  795. set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})")
  796. endif()
  797. endforeach()
  798. if(COMPONENT_DEPENDS)
  799. if(CPACK_DEBIAN_PACKAGE_DEPENDS)
  800. set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}")
  801. else()
  802. set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}")
  803. endif()
  804. endif()
  805. endif()
  806. endif()
  807. # at this point, the CPACK_DEBIAN_PACKAGE_DEPENDS is properly set
  808. # to the minimal dependency of the package
  809. # Append automatically discovered dependencies .
  810. if(NOT "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}" STREQUAL "")
  811. if (CPACK_DEBIAN_PACKAGE_DEPENDS)
  812. set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
  813. else ()
  814. set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
  815. endif ()
  816. endif()
  817. if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
  818. message(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.")
  819. endif()
  820. # Maintainer: (mandatory)
  821. if(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
  822. if(NOT CPACK_PACKAGE_CONTACT)
  823. message(FATAL_ERROR "CPackDeb: Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER")
  824. endif()
  825. set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
  826. endif()
  827. # Description: (mandatory)
  828. if(NOT CPACK_DEB_PACKAGE_COMPONENT)
  829. if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
  830. if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
  831. message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
  832. endif()
  833. set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  834. endif()
  835. else()
  836. set(component_description_var CPACK_COMPONENT_${_local_component_name}_DESCRIPTION)
  837. # component description overrides package description
  838. if(${component_description_var})
  839. set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${${component_description_var}})
  840. elseif(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
  841. if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
  842. message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION or ${component_description_var}")
  843. endif()
  844. set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  845. endif()
  846. endif()
  847. # Section: (recommended)
  848. if(NOT CPACK_DEBIAN_PACKAGE_SECTION)
  849. set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
  850. endif()
  851. # Priority: (recommended)
  852. if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
  853. set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
  854. endif()
  855. if(CPACK_DEBIAN_ARCHIVE_TYPE)
  856. set(archive_types_ "paxr;gnutar")
  857. cmake_policy(PUSH)
  858. cmake_policy(SET CMP0057 NEW)
  859. if(NOT CPACK_DEBIAN_ARCHIVE_TYPE IN_LIST archive_types_)
  860. message(FATAL_ERROR "CPACK_DEBIAN_ARCHIVE_TYPE set to unsupported"
  861. "type ${CPACK_DEBIAN_ARCHIVE_TYPE}")
  862. endif()
  863. cmake_policy(POP)
  864. else()
  865. set(CPACK_DEBIAN_ARCHIVE_TYPE "paxr")
  866. endif()
  867. # Compression: (recommended)
  868. if(NOT CPACK_DEBIAN_COMPRESSION_TYPE)
  869. set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
  870. endif()
  871. # Recommends:
  872. # You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
  873. # Suggests:
  874. # You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS
  875. # CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  876. # This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
  877. # Typical examples are:
  878. # - conffiles
  879. # - postinst
  880. # - postrm
  881. # - prerm
  882. # Usage:
  883. # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  884. # "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
  885. # Are we packaging components ?
  886. if(CPACK_DEB_PACKAGE_COMPONENT)
  887. # override values with per component version if set
  888. foreach(VAR_NAME_ "PACKAGE_CONTROL_EXTRA" "PACKAGE_CONTROL_STRICT_PERMISSION")
  889. if(CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_})
  890. set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}")
  891. endif()
  892. endforeach()
  893. get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name})
  894. endif()
  895. set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "")
  896. if (NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY)
  897. set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=")
  898. endif()
  899. find_program(READELF_EXECUTABLE NAMES readelf)
  900. if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
  901. if(READELF_EXECUTABLE)
  902. foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES)
  903. extract_so_info("${_FILE}" libname soversion)
  904. if(libname AND soversion)
  905. list(APPEND CPACK_DEBIAN_PACKAGE_SHLIBS_LIST
  906. "${libname} ${soversion} ${CPACK_DEBIAN_PACKAGE_NAME} (${CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY} ${CPACK_DEBIAN_PACKAGE_VERSION})")
  907. else()
  908. message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.")
  909. endif()
  910. endforeach()
  911. if (CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
  912. string(REPLACE ";" "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}")
  913. endif()
  914. else()
  915. message(FATAL_ERROR "Readelf utility is not available. CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS option is not available.")
  916. endif()
  917. endif()
  918. # add ldconfig call in default postrm and postint
  919. set(CPACK_ADD_LDCONFIG_CALL 0)
  920. foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
  921. get_filename_component(_DIR ${_FILE} DIRECTORY)
  922. # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning
  923. if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib")
  924. set(CPACK_ADD_LDCONFIG_CALL 1)
  925. endif()
  926. endforeach()
  927. if(CPACK_ADD_LDCONFIG_CALL)
  928. set(CPACK_DEBIAN_GENERATE_POSTINST 1)
  929. set(CPACK_DEBIAN_GENERATE_POSTRM 1)
  930. foreach(f ${PACKAGE_CONTROL_EXTRA})
  931. get_filename_component(n "${f}" NAME)
  932. if("${n}" STREQUAL "postinst")
  933. set(CPACK_DEBIAN_GENERATE_POSTINST 0)
  934. endif()
  935. if("${n}" STREQUAL "postrm")
  936. set(CPACK_DEBIAN_GENERATE_POSTRM 0)
  937. endif()
  938. endforeach()
  939. else()
  940. set(CPACK_DEBIAN_GENERATE_POSTINST 0)
  941. set(CPACK_DEBIAN_GENERATE_POSTRM 0)
  942. endif()
  943. cpack_deb_variable_fallback("CPACK_DEBIAN_FILE_NAME"
  944. "CPACK_DEBIAN_${_local_component_name}_FILE_NAME"
  945. "CPACK_DEBIAN_FILE_NAME")
  946. if(CPACK_DEBIAN_FILE_NAME)
  947. if(CPACK_DEBIAN_FILE_NAME STREQUAL "DEB-DEFAULT")
  948. # Patch package file name to be in corrent debian format:
  949. # <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
  950. set(CPACK_OUTPUT_FILE_NAME
  951. "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
  952. else()
  953. cmake_policy(PUSH)
  954. cmake_policy(SET CMP0010 NEW)
  955. if(NOT CPACK_DEBIAN_FILE_NAME MATCHES ".*\\.(deb|ipk)")
  956. cmake_policy(POP)
  957. message(FATAL_ERROR "'${CPACK_DEBIAN_FILE_NAME}' is not a valid DEB package file name as it must end with '.deb' or '.ipk'!")
  958. endif()
  959. cmake_policy(POP)
  960. set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}")
  961. endif()
  962. set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}")
  963. get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY)
  964. set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}")
  965. endif() # else() back compatibility - don't change the name
  966. # Print out some debug information if we were asked for that
  967. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  968. message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = '${CPACK_TOPLEVEL_DIRECTORY}'")
  969. message("CPackDeb:Debug: CPACK_TOPLEVEL_TAG = '${CPACK_TOPLEVEL_TAG}'")
  970. message("CPackDeb:Debug: CPACK_TEMPORARY_DIRECTORY = '${CPACK_TEMPORARY_DIRECTORY}'")
  971. message("CPackDeb:Debug: CPACK_OUTPUT_FILE_NAME = '${CPACK_OUTPUT_FILE_NAME}'")
  972. message("CPackDeb:Debug: CPACK_OUTPUT_FILE_PATH = '${CPACK_OUTPUT_FILE_PATH}'")
  973. message("CPackDeb:Debug: CPACK_PACKAGE_FILE_NAME = '${CPACK_PACKAGE_FILE_NAME}'")
  974. message("CPackDeb:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = '${CPACK_PACKAGE_INSTALL_DIRECTORY}'")
  975. message("CPackDeb:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = '${CPACK_TEMPORARY_PACKAGE_FILE_NAME}'")
  976. message("CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION = '${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}'")
  977. message("CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_SOURCE = '${CPACK_DEBIAN_PACKAGE_SOURCE}'")
  978. endif()
  979. # For debian source packages:
  980. # debian/control
  981. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles
  982. # .dsc
  983. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles
  984. # Builds-Depends:
  985. #if(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
  986. # set(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
  987. # "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4"
  988. # )
  989. #endif()
  990. # move variables to parent scope so that they may be used to create debian package
  991. set(GEN_CPACK_OUTPUT_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}" PARENT_SCOPE)
  992. set(GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TEMPORARY_PACKAGE_FILE_NAME}" PARENT_SCOPE)
  993. set(GEN_CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}" PARENT_SCOPE)
  994. set(GEN_CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}" PARENT_SCOPE)
  995. set(GEN_CPACK_DEBIAN_PACKAGE_SECTION "${CPACK_DEBIAN_PACKAGE_SECTION}" PARENT_SCOPE)
  996. set(GEN_CPACK_DEBIAN_PACKAGE_PRIORITY "${CPACK_DEBIAN_PACKAGE_PRIORITY}" PARENT_SCOPE)
  997. set(GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" PARENT_SCOPE)
  998. set(GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_DEBIAN_PACKAGE_MAINTAINER}" PARENT_SCOPE)
  999. set(GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_DEBIAN_PACKAGE_DESCRIPTION}" PARENT_SCOPE)
  1000. set(GEN_CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
  1001. set(GEN_CPACK_DEBIAN_ARCHIVE_TYPE "${CPACK_DEBIAN_ARCHIVE_TYPE}" PARENT_SCOPE)
  1002. set(GEN_CPACK_DEBIAN_COMPRESSION_TYPE "${CPACK_DEBIAN_COMPRESSION_TYPE}" PARENT_SCOPE)
  1003. set(GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS "${CPACK_DEBIAN_PACKAGE_RECOMMENDS}" PARENT_SCOPE)
  1004. set(GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS "${CPACK_DEBIAN_PACKAGE_SUGGESTS}" PARENT_SCOPE)
  1005. set(GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_DEBIAN_PACKAGE_HOMEPAGE}" PARENT_SCOPE)
  1006. set(GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS "${CPACK_DEBIAN_PACKAGE_PREDEPENDS}" PARENT_SCOPE)
  1007. set(GEN_CPACK_DEBIAN_PACKAGE_ENHANCES "${CPACK_DEBIAN_PACKAGE_ENHANCES}" PARENT_SCOPE)
  1008. set(GEN_CPACK_DEBIAN_PACKAGE_BREAKS "${CPACK_DEBIAN_PACKAGE_BREAKS}" PARENT_SCOPE)
  1009. set(GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_CONFLICTS}" PARENT_SCOPE)
  1010. set(GEN_CPACK_DEBIAN_PACKAGE_PROVIDES "${CPACK_DEBIAN_PACKAGE_PROVIDES}" PARENT_SCOPE)
  1011. set(GEN_CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_REPLACES}" PARENT_SCOPE)
  1012. set(GEN_CPACK_DEBIAN_PACKAGE_SHLIBS "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}" PARENT_SCOPE)
  1013. set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" PARENT_SCOPE)
  1014. set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
  1015. "${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}" PARENT_SCOPE)
  1016. set(GEN_CPACK_DEBIAN_PACKAGE_SOURCE
  1017. "${CPACK_DEBIAN_PACKAGE_SOURCE}" PARENT_SCOPE)
  1018. set(GEN_CPACK_DEBIAN_GENERATE_POSTINST "${CPACK_DEBIAN_GENERATE_POSTINST}" PARENT_SCOPE)
  1019. set(GEN_CPACK_DEBIAN_GENERATE_POSTRM "${CPACK_DEBIAN_GENERATE_POSTRM}" PARENT_SCOPE)
  1020. set(GEN_WDIR "${WDIR}" PARENT_SCOPE)
  1021. endfunction()
  1022. cpack_deb_prepare_package_vars()