rpm.rst 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  1. CPack RPM Generator
  2. -------------------
  3. The built in (binary) CPack RPM generator (Unix only)
  4. Variables specific to CPack RPM generator
  5. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6. The CPack RPM generator may be used to create RPM packages using :module:`CPack`.
  7. The CPack RPM generator is a :module:`CPack` generator thus it uses the
  8. :variable:`!CPACK_XXX` variables used by :module:`CPack`.
  9. The CPack RPM generator has specific features which are controlled by the specifics
  10. :variable:`!CPACK_RPM_XXX` variables.
  11. :variable:`!CPACK_RPM_<COMPONENT>_XXXX` variables may be used in order to have
  12. **component-specific** values. Note however that ``<COMPONENT>`` refers to the
  13. **grouping name** written in upper case. It may be either a component name or
  14. a component GROUP name. Usually, those variables correspond to RPM spec file
  15. entities. One may find information about spec files here
  16. https://rpm.org/documentation.
  17. .. versionchanged:: 3.6
  18. ``<COMPONENT>`` part of variables is preferred to be in upper case (e.g. if
  19. component is named ``foo`` then use :variable:`!CPACK_RPM_FOO_XXXX` variable
  20. name format) as is with other :variable:`!CPACK_<COMPONENT>_XXXX` variables.
  21. For the purposes of back compatibility (CMake/CPack version 3.5 and lower)
  22. support for same cased component (e.g. ``fOo`` would be used as
  23. :variable:`!CPACK_RPM_fOo_XXXX`) is still supported for variables defined in
  24. older versions of CMake/CPack but is not guaranteed for variables that
  25. will be added in the future. For the sake of back compatibility same cased
  26. component variables also override upper cased versions where both are
  27. present.
  28. Here are some CPack RPM generator wiki resources that are here for historic
  29. reasons and are no longer maintained but may still prove useful:
  30. - https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/Configuration
  31. - https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/PackageGenerators#rpm-unix-only
  32. List of CPack RPM generator specific variables:
  33. .. variable:: CPACK_RPM_COMPONENT_INSTALL
  34. Enable component packaging for CPack RPM generator
  35. :Mandatory: No
  36. :Default: ``OFF``
  37. If enabled (``ON``) multiple packages are generated. By default
  38. a single package containing files of all components is generated.
  39. .. variable:: CPACK_RPM_PACKAGE_SUMMARY
  40. CPACK_RPM_<component>_PACKAGE_SUMMARY
  41. The RPM package summary.
  42. :Mandatory: Yes
  43. :Default: :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
  44. .. versionadded:: 3.2
  45. Per-component :variable:`!CPACK_RPM_<component>_PACKAGE_SUMMARY` variables.
  46. .. variable:: CPACK_RPM_PACKAGE_NAME
  47. CPACK_RPM_<component>_PACKAGE_NAME
  48. The RPM package name.
  49. :Mandatory: Yes
  50. :Default: :variable:`CPACK_PACKAGE_NAME`
  51. .. versionadded:: 3.5
  52. Per-component :variable:`!CPACK_RPM_<component>_PACKAGE_NAME` variables.
  53. .. variable:: CPACK_RPM_FILE_NAME
  54. CPACK_RPM_<component>_FILE_NAME
  55. .. versionadded:: 3.6
  56. Package file name.
  57. :Mandatory: Yes
  58. :Default: ``<CPACK_PACKAGE_FILE_NAME>[-<component>].rpm`` with spaces
  59. replaced by '-'
  60. This may be set to:
  61. ``RPM-DEFAULT``
  62. Tell ``rpmbuild`` to automatically generate the package file name.
  63. ``<file-name>[.rpm]``
  64. Use the given file name.
  65. .. versionchanged:: 3.29
  66. The ``.rpm`` suffix will be automatically added if missing.
  67. Previously the suffix was required.
  68. .. note::
  69. By using user provided spec file, rpm macro extensions such as for
  70. generating ``debuginfo`` packages or by simply using multiple components more
  71. than one rpm file may be generated, either from a single spec file or from
  72. multiple spec files (each component execution produces its own spec file).
  73. In such cases duplicate file names may occur as a result of this variable
  74. setting or spec file content structure. Duplicate files get overwritten
  75. and it is up to the packager to set the variables in a manner that will
  76. prevent such errors.
  77. .. variable:: CPACK_RPM_MAIN_COMPONENT
  78. .. versionadded:: 3.8
  79. Main component that is packaged without component suffix.
  80. :Mandatory: No
  81. :Default:
  82. This variable can be set to any component or group name so that component or
  83. group rpm package is generated without component suffix in filename and
  84. package name.
  85. .. variable:: CPACK_RPM_PACKAGE_EPOCH
  86. .. versionadded:: 3.10
  87. The RPM package epoch
  88. :Mandatory: No
  89. :Default:
  90. Optional number that should be incremented when changing versioning schemas
  91. or fixing mistakes in the version numbers of older packages.
  92. .. variable:: CPACK_RPM_PACKAGE_VERSION
  93. The RPM package version.
  94. :Mandatory: Yes
  95. :Default: :variable:`CPACK_PACKAGE_VERSION`
  96. .. variable:: CPACK_RPM_PACKAGE_ARCHITECTURE
  97. CPACK_RPM_<component>_PACKAGE_ARCHITECTURE
  98. The RPM package architecture.
  99. :Mandatory: Yes
  100. :Default: Native architecture output by ``uname -m``
  101. This may be set to ``noarch`` if you know you are building a ``noarch`` package.
  102. .. versionadded:: 3.3
  103. Per-component :variable:`!CPACK_RPM_<component>_PACKAGE_ARCHITECTURE` variables.
  104. .. variable:: CPACK_RPM_PACKAGE_RELEASE
  105. The RPM package release.
  106. :Mandatory: Yes
  107. :Default: 1
  108. This is the numbering of the RPM package itself, i.e. the version of the
  109. packaging and not the version of the content (see
  110. :variable:`CPACK_RPM_PACKAGE_VERSION`). One may change the default value if
  111. the previous packaging was buggy and/or you want to put here a fancy Linux
  112. distro specific numbering.
  113. .. note::
  114. This is the string that goes into the RPM ``Release:`` field. Some distros
  115. (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a number.
  116. ``%{?dist}`` part can be added by setting :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.
  117. .. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST
  118. .. versionadded:: 3.6
  119. The dist tag that is added RPM ``Release:`` field.
  120. :Mandatory: No
  121. :Default: ``OFF``
  122. This is the reported ``%{dist}`` tag from the current distribution or empty
  123. ``%{dist}`` if RPM macro is not set. If this variable is set then RPM
  124. ``Release:`` field value is set to ``${CPACK_RPM_PACKAGE_RELEASE}%{?dist}``.
  125. .. variable:: CPACK_RPM_PACKAGE_LICENSE
  126. The RPM package license policy.
  127. :Mandatory: Yes
  128. :Default: "unknown"
  129. .. variable:: CPACK_RPM_PACKAGE_GROUP
  130. CPACK_RPM_<component>_PACKAGE_GROUP
  131. The RPM package group.
  132. :Mandatory: Yes
  133. :Default: "unknown"
  134. .. versionadded:: 3.5
  135. Per-component :variable:`!CPACK_RPM_<component>_PACKAGE_GROUP` variables.
  136. .. variable:: CPACK_RPM_PACKAGE_VENDOR
  137. The RPM package vendor.
  138. :Mandatory: Yes
  139. :Default: CPACK_PACKAGE_VENDOR if set or "unknown"
  140. .. variable:: CPACK_RPM_PACKAGE_URL
  141. CPACK_RPM_<component>_PACKAGE_URL
  142. The projects URL.
  143. :Mandatory: No
  144. :Default: :variable:`CMAKE_PROJECT_HOMEPAGE_URL`
  145. .. versionadded:: 3.12
  146. The :variable:`!CMAKE_PROJECT_HOMEPAGE_URL` variable.
  147. .. variable:: CPACK_RPM_PACKAGE_DESCRIPTION
  148. CPACK_RPM_<component>_PACKAGE_DESCRIPTION
  149. RPM package description.
  150. :Mandatory: Yes
  151. :Default:
  152. - :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION`
  153. (component based installers only) if set,
  154. - :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`
  155. if set, or
  156. - ``no package description available``
  157. .. versionadded:: 3.2
  158. Per-component :variable:`!CPACK_RPM_<component>_PACKAGE_DESCRIPTION` variables.
  159. .. variable:: CPACK_RPM_COMPRESSION_TYPE
  160. RPM compression type.
  161. :Mandatory: No
  162. :Default: (system default)
  163. May be used to override RPM compression type to be used to build the
  164. RPM. For example some Linux distributions default to ``xz`` or ``zstd``.
  165. Using this, one can specify a specific compression type to be used.
  166. Possible values are:
  167. ``lzma``
  168. Lempel–Ziv–Markov chain algorithm
  169. ``xz``
  170. XZ Utils compression
  171. ``bzip2``
  172. bzip2 Burrows–Wheeler algorithm
  173. ``gzip``
  174. GNU Gzip compression
  175. ``zstd``
  176. .. versionadded:: 3.31
  177. Zstandard compression
  178. .. variable:: CPACK_RPM_PACKAGE_AUTOREQ
  179. CPACK_RPM_<component>_PACKAGE_AUTOREQ
  180. RPM spec autoreq field.
  181. :Mandatory: No
  182. :Default:
  183. May be used to enable (``1``, ``yes``) or disable (``0``, ``no``) automatic
  184. shared libraries dependency detection. Dependencies are added to requires list.
  185. .. note::
  186. By default automatic dependency detection is enabled by rpm generator.
  187. .. variable:: CPACK_RPM_PACKAGE_AUTOPROV
  188. CPACK_RPM_<component>_PACKAGE_AUTOPROV
  189. RPM spec autoprov field.
  190. :Mandatory: No
  191. :Default:
  192. May be used to enable (``1``, ``yes``) or disable (``0``, ``no``)
  193. automatic listing of shared libraries that are provided by the package.
  194. Shared libraries are added to provides list.
  195. .. note::
  196. By default automatic provides detection is enabled by rpm generator.
  197. .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV
  198. CPACK_RPM_<component>_PACKAGE_AUTOREQPROV
  199. RPM spec autoreqprov field.
  200. :Mandatory: No
  201. :Default:
  202. Variable enables/disables autoreq and autoprov at the same time.
  203. See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and
  204. :variable:`CPACK_RPM_PACKAGE_AUTOPROV` for more details.
  205. .. note::
  206. By default automatic detection feature is enabled by rpm.
  207. .. variable:: CPACK_RPM_PACKAGE_REQUIRES
  208. CPACK_RPM_<component>_PACKAGE_REQUIRES
  209. RPM spec requires field.
  210. :Mandatory: No
  211. :Default:
  212. May be used to set RPM dependencies (requires). Note that you must enclose
  213. the entire value between quotes when setting this variable, for example:
  214. .. code-block:: cmake
  215. set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8")
  216. The required package list of an RPM file could be printed with::
  217. rpm -qp --requires file.rpm
  218. .. variable:: CPACK_RPM_PACKAGE_CONFLICTS
  219. CPACK_RPM_<component>_PACKAGE_CONFLICTS
  220. RPM spec conflicts field.
  221. :Mandatory: No
  222. :Default:
  223. May be used to set negative RPM dependencies (conflicts). Note that you must
  224. enclose the entire value between quotes when setting this variable,
  225. for example:
  226. .. code-block:: cmake
  227. set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2")
  228. The conflicting package list of an RPM file could be printed with::
  229. rpm -qp --conflicts file.rpm
  230. .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
  231. CPACK_RPM_<component>_PACKAGE_REQUIRES_PRE
  232. .. versionadded:: 3.2
  233. RPM spec requires(pre) field.
  234. :Mandatory: No
  235. :Default:
  236. May be used to set RPM preinstall dependencies (requires(pre)). Note that
  237. you must enclose the entire value between quotes when setting this variable,
  238. for example:
  239. .. code-block:: cmake
  240. set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
  241. .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
  242. CPACK_RPM_<component>_PACKAGE_REQUIRES_POST
  243. .. versionadded:: 3.2
  244. RPM spec requires(post) field.
  245. :Mandatory: No
  246. :Default:
  247. May be used to set RPM postinstall dependencies (requires(post)). Note that
  248. you must enclose the entire value between quotes when setting this variable,
  249. for example:
  250. .. code-block:: cmake
  251. set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts")
  252. .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
  253. CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN
  254. .. versionadded:: 3.2
  255. RPM spec requires(postun) field.
  256. :Mandatory: No
  257. :Default:
  258. May be used to set RPM postuninstall dependencies (requires(postun)). Note
  259. that you must enclose the entire value between quotes when setting this
  260. variable, for example:
  261. .. code-block:: cmake
  262. set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "shadow-utils, initscripts")
  263. .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
  264. CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN
  265. .. versionadded:: 3.2
  266. RPM spec requires(preun) field.
  267. :Mandatory: No
  268. :Default:
  269. May be used to set RPM preuninstall dependencies (requires(preun)). Note that
  270. you must enclose the entire value between quotes when setting this variable,
  271. for example:
  272. .. code-block:: cmake
  273. set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts")
  274. .. variable:: CPACK_RPM_PACKAGE_SUGGESTS
  275. CPACK_RPM_<component>_PACKAGE_SUGGESTS
  276. RPM spec suggests field.
  277. :Mandatory: No
  278. :Default:
  279. May be used to set weak RPM dependencies (suggests). If ``rpmbuild`` doesn't
  280. support the ``Suggests`` tag, CPack will emit a warning and ignore this
  281. variable. Note that you must enclose the entire value between quotes when
  282. setting this variable.
  283. .. variable:: CPACK_RPM_PACKAGE_RECOMMENDS
  284. CPACK_RPM_<component>_PACKAGE_RECOMMENDS
  285. .. versionadded:: 4.1
  286. RPM spec recommends field.
  287. :Mandatory: No
  288. :Default:
  289. May be used to set weak RPM dependencies (recommends). If ``rpmbuild`` doesn't
  290. support the ``Recommends`` tag, CPack will emit a warning and ignore this
  291. variable. Note that you must enclose the entire value between quotes when
  292. setting this variable.
  293. .. variable:: CPACK_RPM_PACKAGE_SUPPLEMENTS
  294. CPACK_RPM_<component>_PACKAGE_SUPPLEMENTS
  295. .. versionadded:: 4.1
  296. RPM spec supplements field.
  297. :Mandatory: No
  298. :Default:
  299. May be used to set weak RPM dependencies (supplements). If ``rpmbuild`` doesn't
  300. support the ``Supplements`` tag, CPack will emit a warning and ignore this
  301. variable. Note that you must enclose the entire value between quotes when
  302. setting this variable.
  303. .. variable:: CPACK_RPM_PACKAGE_ENHANCES
  304. CPACK_RPM_<component>_PACKAGE_ENHANCES
  305. .. versionadded:: 4.1
  306. RPM spec enhances field.
  307. :Mandatory: No
  308. :Default:
  309. May be used to set weak RPM dependencies (enhances). If ``rpmbuild`` doesn't
  310. support the ``Enhances`` tag, CPack will emit a warning and ignore this
  311. variable. Note that you must enclose the entire value between quotes when
  312. setting this variable.
  313. .. variable:: CPACK_RPM_PACKAGE_PROVIDES
  314. CPACK_RPM_<component>_PACKAGE_PROVIDES
  315. RPM spec provides field.
  316. :Mandatory: No
  317. :Default:
  318. May be used to set RPM dependencies (provides). The provided package list
  319. of an RPM file could be printed with::
  320. rpm -qp --provides file.rpm
  321. .. variable:: CPACK_RPM_PACKAGE_OBSOLETES
  322. CPACK_RPM_<component>_PACKAGE_OBSOLETES
  323. RPM spec obsoletes field.
  324. :Mandatory: No
  325. :Default:
  326. May be used to set RPM packages that are obsoleted by this one.
  327. .. variable:: CPACK_RPM_PACKAGE_RELOCATABLE
  328. build a relocatable RPM.
  329. :Mandatory: No
  330. :Default: CPACK_PACKAGE_RELOCATABLE
  331. If this variable is set to TRUE or ON, the CPack RPM generator will try
  332. to build a relocatable RPM package. A relocatable RPM may
  333. be installed using::
  334. rpm --prefix or --relocate
  335. in order to install it at an alternate place see rpm(8). Note that
  336. currently this may fail if :variable:`CPACK_SET_DESTDIR` is set to ``ON``. If
  337. :variable:`CPACK_SET_DESTDIR` is set then you will get a warning message but
  338. if there is file installed with absolute path you'll get unexpected behavior.
  339. .. variable:: CPACK_RPM_SPEC_INSTALL_POST
  340. .. deprecated:: 2.8.12 Use :variable:`CPACK_RPM_SPEC_MORE_DEFINE` instead.
  341. :Mandatory: No
  342. :Default:
  343. May be used to override the ``__spec_install_post`` section within the
  344. generated spec file. This affects the install step during package creation,
  345. not during package installation. For adding operations to be performed
  346. during package installation, use
  347. :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE` instead.
  348. .. variable:: CPACK_RPM_SPEC_MORE_DEFINE
  349. RPM extended spec definitions lines.
  350. :Mandatory: No
  351. :Default:
  352. May be used to add any ``%define`` lines to the generated spec file. An
  353. example of its use is to prevent stripping of executables (but note that
  354. this may also disable other default post install processing):
  355. .. code-block:: cmake
  356. set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true")
  357. .. variable:: CPACK_RPM_PACKAGE_DEBUG
  358. Toggle CPack RPM generator debug output.
  359. :Mandatory: No
  360. :Default:
  361. May be set when invoking cpack in order to trace debug information
  362. during CPack RPM run. For example you may launch CPack like this::
  363. cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM
  364. .. variable:: CPACK_RPM_USER_BINARY_SPECFILE
  365. CPACK_RPM_<componentName>_USER_BINARY_SPECFILE
  366. A user provided spec file.
  367. :Mandatory: No
  368. :Default:
  369. May be set by the user in order to specify a USER binary spec file
  370. to be used by the CPack RPM generator instead of generating the file.
  371. The specified file will be processed by configure_file(@ONLY).
  372. .. variable:: CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
  373. Spec file template.
  374. :Mandatory: No
  375. :Default:
  376. If set CPack will generate a template for USER specified binary
  377. spec file and stop with an error. For example launch CPack like this::
  378. cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM
  379. The user may then use this file in order to hand-craft is own
  380. binary spec file which may be used with
  381. :variable:`CPACK_RPM_USER_BINARY_SPECFILE`.
  382. .. variable:: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
  383. CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
  384. CPACK_RPM_PRE_TRANS_SCRIPT_FILE
  385. Path to file containing pre install/uninstall/transaction script.
  386. :Mandatory: No
  387. :Default:
  388. May be used to embed a pre installation/uninstallation/transaction script in the spec file.
  389. The referred script file (or both) will be read and directly
  390. put after the ``%pre`` or ``%preun`` section
  391. If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the install/uninstall/transaction
  392. script for each component can be overridden with
  393. :variable:`!CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE`,
  394. :variable:`!CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE`, and
  395. :variable:`!CPACK_RPM_<COMPONENT>_PRE_TRANS_SCRIPT_FILE`
  396. One may verify which scriptlet has been included with::
  397. rpm -qp --scripts package.rpm
  398. .. versionadded:: 3.18
  399. The :variable:`!CPACK_RPM_PRE_TRANS_SCRIPT_FILE` variable.
  400. .. variable:: CPACK_RPM_POST_INSTALL_SCRIPT_FILE
  401. CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
  402. CPACK_RPM_POST_TRANS_SCRIPT_FILE
  403. Path to file containing post install/uninstall/transaction script.
  404. :Mandatory: No
  405. :Default:
  406. May be used to embed a post installation/uninstallation/transaction script in the spec file.
  407. The referred script file (or both) will be read and directly
  408. put after the ``%post`` or ``%postun`` section.
  409. If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the install/uninstall/transaction
  410. script for each component can be overridden with
  411. :variable:`!CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE`,
  412. :variable:`!CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE`, and
  413. :variable:`!CPACK_RPM_<COMPONENT>_POST_TRANS_SCRIPT_FILE`
  414. One may verify which scriptlet has been included with::
  415. rpm -qp --scripts package.rpm
  416. .. versionadded:: 3.18
  417. The :variable:`!CPACK_RPM_POST_TRANS_SCRIPT_FILE` variable.
  418. .. variable:: CPACK_RPM_USER_FILELIST
  419. CPACK_RPM_<COMPONENT>_USER_FILELIST
  420. :Mandatory: No
  421. :Default:
  422. May be used to explicitly specify ``%(<directive>)`` file line
  423. in the spec file. Like ``%config(noreplace)`` or any other directive
  424. that be found in the ``%files`` section. Since
  425. the CPack RPM generator is generating the list of files (and directories) the
  426. user specified files of the :variable:`!CPACK_RPM_<COMPONENT>_USER_FILELIST` list will
  427. be removed from the generated list. If referring to directories do
  428. not add a trailing slash.
  429. .. versionadded:: 3.8
  430. You can have multiple directives per line, as in
  431. ``%attr(600,root,root) %config(noreplace)``.
  432. .. variable:: CPACK_RPM_CHANGELOG_FILE
  433. RPM changelog file.
  434. :Mandatory: No
  435. :Default:
  436. May be used to embed a changelog in the spec file.
  437. The referred file will be read and directly put after the ``%changelog``
  438. section.
  439. .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
  440. list of path to be excluded.
  441. :Mandatory: No
  442. :Default:
  443. The following paths are excluded by default:
  444. - ``/etc``
  445. - ``/etc/init.d``
  446. - ``/usr``
  447. - ``/usr/bin``
  448. - ``/usr/include``
  449. - ``/usr/lib``
  450. - ``/usr/libx32``
  451. - ``/usr/lib64``
  452. - ``/usr/share``
  453. - ``/usr/share/aclocal``
  454. - ``/usr/share/doc``
  455. May be used to exclude path (directories or files) from the auto-generated
  456. list of paths discovered by CPack RPM. The default value contains a
  457. reasonable set of values if the variable is not defined by the user. If the
  458. variable is defined by the user then the CPack RPM generator will NOT any of
  459. the default path. If you want to add some path to the default list then you
  460. can use :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` variable.
  461. .. versionadded:: 3.10
  462. Added ``/usr/share/aclocal`` to the default list of excludes.
  463. .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
  464. additional list of path to be excluded.
  465. :Mandatory: No
  466. :Default:
  467. May be used to add more exclude path (directories or files) from the initial
  468. default list of excluded paths. See
  469. :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST`.
  470. .. variable:: CPACK_RPM_RELOCATION_PATHS
  471. .. versionadded:: 3.2
  472. Packages relocation paths list.
  473. :Mandatory: No
  474. :Default:
  475. May be used to specify more than one relocation path per relocatable RPM.
  476. Variable contains a list of relocation paths that if relative are prefixed
  477. by the value of :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX` or by the
  478. value of :variable:`CPACK_PACKAGING_INSTALL_PREFIX` if the component version
  479. is not provided.
  480. Variable is not component based as its content can be used to set a different
  481. path prefix for e.g. binary dir and documentation dir at the same time.
  482. Only prefixes that are required by a certain component are added to that
  483. component - component must contain at least one file/directory/symbolic link
  484. with :variable:`CPACK_RPM_RELOCATION_PATHS` prefix for a certain relocation
  485. path to be added. Package will not contain any relocation paths if there are
  486. no files/directories/symbolic links on any of the provided prefix locations.
  487. Packages that either do not contain any relocation paths or contain
  488. files/directories/symbolic links that are outside relocation paths print
  489. out an :command:`AUTHOR_WARNING <message>` that RPM will be partially relocatable.
  490. .. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
  491. .. versionadded:: 3.2
  492. Per component relocation path install prefix.
  493. :Mandatory: No
  494. :Default: :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
  495. May be used to set per component :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
  496. for relocatable RPM packages.
  497. .. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION
  498. CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION
  499. .. versionadded:: 3.3
  500. Removal of default install prefix from relocation paths list.
  501. :Mandatory: No
  502. :Default: :variable:`CPACK_PACKAGING_INSTALL_PREFIX` or
  503. :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX`
  504. are treated as one of relocation paths
  505. May be used to remove :variable:`CPACK_PACKAGING_INSTALL_PREFIX` and
  506. :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX`
  507. from relocatable RPM prefix paths.
  508. .. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS
  509. .. versionadded:: 3.3
  510. :Mandatory: No
  511. :Default:
  512. Regular expressions that are added by default were taken from ``brp-compress`` RPM macro:
  513. - ``/usr/man/man.*``
  514. - ``/usr/man/.*/man.*``
  515. - ``/usr/info.*``
  516. - ``/usr/share/man/man.*``
  517. - ``/usr/share/man/.*/man.*``
  518. - ``/usr/share/info.*``
  519. - ``/usr/kerberos/man.*``
  520. - ``/usr/X11R6/man/man.*``
  521. - ``/usr/lib/perl5/man/man.*``
  522. - ``/usr/share/doc/.*/man/man.*``
  523. - ``/usr/lib/.*/man/man.*``
  524. May be used to set additional man dirs that could potentially be compressed
  525. by brp-compress RPM macro. Variable content must be a list of regular
  526. expressions that point to directories containing man files or to man files
  527. directly. Note that in order to compress man pages a path must also be
  528. present in brp-compress RPM script and that brp-compress script must be
  529. added to RPM configuration by the operating system.
  530. .. variable:: CPACK_RPM_DEFAULT_USER
  531. CPACK_RPM_<compName>_DEFAULT_USER
  532. .. versionadded:: 3.6
  533. default user ownership of RPM content
  534. :Mandatory: No
  535. :Default: ``root``
  536. Value should be user name and not UID.
  537. Note that ``<compName>`` must be in upper-case.
  538. .. variable:: CPACK_RPM_DEFAULT_GROUP
  539. CPACK_RPM_<compName>_DEFAULT_GROUP
  540. .. versionadded:: 3.6
  541. default group ownership of RPM content
  542. :Mandatory: No
  543. :Default: root
  544. Value should be group name and not GID.
  545. Note that ``<compName>`` must be in upper-case.
  546. .. variable:: CPACK_RPM_DEFAULT_FILE_PERMISSIONS
  547. CPACK_RPM_<compName>_DEFAULT_FILE_PERMISSIONS
  548. .. versionadded:: 3.6
  549. default permissions used for packaged files
  550. :Mandatory: No
  551. :Default: (system default)
  552. Accepted values are lists with PERMISSIONS. Valid permissions
  553. are:
  554. - ``OWNER_READ``
  555. - ``OWNER_WRITE``
  556. - ``OWNER_EXECUTE``
  557. - ``GROUP_READ``
  558. - ``GROUP_WRITE``
  559. - ``GROUP_EXECUTE``
  560. - ``WORLD_READ``
  561. - ``WORLD_WRITE``
  562. - ``WORLD_EXECUTE``
  563. Note that ``<compName>`` must be in upper-case.
  564. .. variable:: CPACK_RPM_DEFAULT_DIR_PERMISSIONS
  565. CPACK_RPM_<compName>_DEFAULT_DIR_PERMISSIONS
  566. .. versionadded:: 3.6
  567. default permissions used for packaged directories
  568. :Mandatory: No
  569. :Default: (system default)
  570. Accepted values are lists with PERMISSIONS. Valid permissions
  571. are the same as for :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`.
  572. Note that ``<compName>`` must be in upper-case.
  573. .. variable:: CPACK_RPM_INSTALL_WITH_EXEC
  574. .. versionadded:: 3.11
  575. force execute permissions on programs and shared libraries
  576. :Mandatory: No
  577. :Default: (system default)
  578. Force set owner, group and world execute permissions on programs and shared
  579. libraries. This can be used for creating valid rpm packages on systems such
  580. as Debian where shared libraries do not have execute permissions set.
  581. .. note::
  582. Programs and shared libraries without execute permissions are ignored during
  583. separation of debug symbols from the binary for debuginfo packages.
  584. Packaging of Symbolic Links
  585. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  586. .. versionadded:: 3.3
  587. The CPack RPM generator supports packaging of symbolic links:
  588. .. code-block:: cmake
  589. execute_process(COMMAND ${CMAKE_COMMAND}
  590. -E create_symlink <relative_path_location> <symlink_name>)
  591. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/<symlink_name>
  592. DESTINATION <symlink_location> COMPONENT libraries)
  593. Symbolic links will be optimized (paths will be shortened if possible)
  594. before being added to the package or if multiple relocation paths are
  595. detected, a post install symlink relocation script will be generated.
  596. Symbolic links may point to locations that are not packaged by the same
  597. package (either a different component or even not packaged at all) but
  598. those locations will be treated as if they were a part of the package
  599. while determining if symlink should be either created or present in a
  600. post install script - depending on relocation paths.
  601. .. versionchanged:: 3.6
  602. Symbolic links that point to locations outside packaging path produce a
  603. warning and are treated as non relocatable permanent symbolic links.
  604. Previous versions of CMake produced an error in this case.
  605. Currently there are a few limitations though:
  606. * For component based packaging component interdependency is not checked
  607. when processing symbolic links. Symbolic links pointing to content of
  608. a different component are treated the same way as if pointing to location
  609. that will not be packaged.
  610. * Symbolic links pointing to a location through one or more intermediate
  611. symbolic links will not be handled differently - if the intermediate
  612. symbolic link(s) is also on a relocatable path, relocating it during
  613. package installation may cause initial symbolic link to point to an
  614. invalid location.
  615. Packaging of debug information
  616. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  617. .. versionadded:: 3.7
  618. Debuginfo packages contain debug symbols and sources for debugging packaged
  619. binaries.
  620. Debuginfo RPM packaging has its own set of variables:
  621. .. variable:: CPACK_RPM_DEBUGINFO_PACKAGE
  622. CPACK_RPM_<component>_DEBUGINFO_PACKAGE
  623. Enable generation of debuginfo RPM package(s).
  624. :Mandatory: No
  625. :Default: ``OFF``
  626. .. note::
  627. Binaries must contain debug symbols before packaging so use either ``Debug``
  628. or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value.
  629. Additionally, if :variable:`CPACK_STRIP_FILES` is set, the files will be stripped before
  630. they get to the RPM generator, so will not contain debug symbols and
  631. a debuginfo package will not get built. Do not use with :variable:`CPACK_STRIP_FILES`.
  632. .. note::
  633. Packages generated from packages without binary files, with binary files but
  634. without execute permissions or without debug symbols will cause packaging
  635. termination.
  636. .. variable:: CPACK_BUILD_SOURCE_DIRS
  637. Provides locations of root directories of source files from which binaries
  638. were built.
  639. :Mandatory: Yes if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
  640. :Default:
  641. .. note::
  642. For CMake project :variable:`CPACK_BUILD_SOURCE_DIRS` is set by default to
  643. point to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR` paths.
  644. .. note::
  645. Sources with path prefixes that do not fall under any location provided with
  646. :variable:`CPACK_BUILD_SOURCE_DIRS` will not be present in debuginfo package.
  647. .. variable:: CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
  648. CPACK_RPM_<component>_BUILD_SOURCE_DIRS_PREFIX
  649. Prefix of location where sources will be placed during package installation.
  650. :Mandatory: Yes if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
  651. :Default: ``/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}`` and
  652. for component packaging ``/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}-<component>``
  653. .. note::
  654. Each source path prefix is additionally suffixed by ``src_<index>`` where
  655. index is index of the path used from :variable:`CPACK_BUILD_SOURCE_DIRS`
  656. variable. This produces ``${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_<index>``
  657. replacement path.
  658. Limitation is that replaced path part must be shorter or of equal
  659. length than the length of its replacement. If that is not the case either
  660. :variable:`CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX` variable has to be set to
  661. a shorter path or source directories must be placed on a longer path.
  662. .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS
  663. Directories containing sources that should be excluded from debuginfo packages.
  664. :Mandatory: No
  665. :Default:
  666. The following paths are excluded by default:
  667. - ``/usr``
  668. - ``/usr/src``
  669. - ``/usr/src/debug``
  670. Listed paths are owned by other RPM packages and should therefore not be
  671. deleted on debuginfo package uninstallation.
  672. .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION
  673. Paths that should be appended to :variable:`CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS`
  674. for exclusion.
  675. :Mandatory: No
  676. :Default:
  677. .. variable:: CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE
  678. .. versionadded:: 3.8
  679. Create a single debuginfo package even if components packaging is set.
  680. :Mandatory: No
  681. :Default: ``OFF``
  682. When this variable is enabled it produces a single debuginfo package even if
  683. component packaging is enabled.
  684. When using this feature in combination with components packaging and there is
  685. more than one component this variable requires :variable:`CPACK_RPM_MAIN_COMPONENT`
  686. to be set.
  687. .. note::
  688. If none of the :variable:`CPACK_RPM_<component>_DEBUGINFO_PACKAGE` variables
  689. is set then :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is automatically set to
  690. ``ON`` when :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` is set.
  691. .. variable:: CPACK_RPM_DEBUGINFO_FILE_NAME
  692. CPACK_RPM_<component>_DEBUGINFO_FILE_NAME
  693. .. versionadded:: 3.9
  694. Debuginfo package file name.
  695. :Mandatory: No
  696. :Default: rpmbuild tool generated package file name
  697. Alternatively provided debuginfo package file name must end with ``.rpm``
  698. suffix and should differ from file names of other generated packages.
  699. Variable may contain ``@cpack_component@`` placeholder which will be
  700. replaced by component name if component packaging is enabled otherwise it
  701. deletes the placeholder.
  702. Setting the variable to ``RPM-DEFAULT`` may be used to explicitly set
  703. filename generation to default.
  704. .. note::
  705. :variable:`CPACK_RPM_FILE_NAME` also supports rpmbuild tool generated package
  706. file name - disabled by default but can be enabled by setting the variable to
  707. ``RPM-DEFAULT``.
  708. Packaging of sources (SRPM)
  709. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  710. .. versionadded:: 3.7
  711. SRPM packaging is enabled by setting :variable:`CPACK_RPM_PACKAGE_SOURCES`
  712. variable while usually using :variable:`CPACK_INSTALLED_DIRECTORIES` variable
  713. to provide directory containing CMakeLists.txt and source files.
  714. For CMake projects SRPM package would be produced by executing::
  715. cpack -G RPM --config ./CPackSourceConfig.cmake
  716. .. note::
  717. Produced SRPM package is expected to be built with :manual:`cmake(1)` executable
  718. and packaged with :manual:`cpack(1)` executable so CMakeLists.txt has to be
  719. located in root source directory and must be able to generate binary rpm
  720. packages by executing :option:`cpack -G` command. The two executables as well as
  721. rpmbuild must also be present when generating binary rpm packages from the
  722. produced SRPM package.
  723. Once the SRPM package is generated it can be used to generate binary packages
  724. by creating a directory structure for rpm generation and executing rpmbuild
  725. tool::
  726. mkdir -p build_dir/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
  727. rpmbuild --define "_topdir <path_to_build_dir>" --rebuild <SRPM_file_name>
  728. Generated packages will be located in build_dir/RPMS directory or its sub
  729. directories.
  730. .. note::
  731. SRPM package internally uses CPack/RPM generator to generate binary packages
  732. so CMakeScripts.txt can decide during the SRPM to binary rpm generation step
  733. what content the package(s) should have as well as how they should be packaged
  734. (monolithic or components). CMake can decide this for e.g. by reading environment
  735. variables set by the package manager before starting the process of generating
  736. binary rpm packages. This way a single SRPM package can be used to produce
  737. different binary rpm packages on different platforms depending on the platform's
  738. packaging rules.
  739. Source RPM packaging has its own set of variables:
  740. .. variable:: CPACK_RPM_PACKAGE_SOURCES
  741. Should the content be packaged as a source rpm (default is binary rpm).
  742. :Mandatory: No
  743. :Default: ``OFF``
  744. .. note::
  745. For cmake projects :variable:`CPACK_RPM_PACKAGE_SOURCES` variable is set
  746. to ``OFF`` in CPackConfig.cmake and ``ON`` in CPackSourceConfig.cmake
  747. generated files.
  748. .. variable:: CPACK_RPM_SOURCE_PKG_BUILD_PARAMS
  749. Additional command-line parameters provided to :manual:`cmake(1)` executable.
  750. :Mandatory: No
  751. :Default:
  752. .. variable:: CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX
  753. Packaging install prefix that would be provided in :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
  754. variable for producing binary RPM packages.
  755. :Mandatory: Yes
  756. :Default: ``/``
  757. .. variable:: CPACK_RPM_BUILDREQUIRES
  758. List of source rpm build dependencies.
  759. :Mandatory: No
  760. :Default:
  761. May be used to set source RPM build dependencies (BuildRequires). Note that
  762. you must enclose the entire value between quotes when setting this variable,
  763. for example:
  764. .. code-block:: cmake
  765. set(CPACK_RPM_BUILDREQUIRES "python >= 2.5.0, cmake >= 2.8")
  766. .. variable:: CPACK_RPM_REQUIRES_EXCLUDE_FROM
  767. .. versionadded:: 3.22
  768. :Mandatory: No
  769. :Default:
  770. May be used to keep the dependency generator from scanning specific files
  771. or directories for dependencies. Note that you can use a regular
  772. expression that matches all of the directories or files, for example:
  773. .. code-block:: cmake
  774. set(CPACK_RPM_REQUIRES_EXCLUDE_FROM "bin/libqsqloci.*\\.so.*")