rpm.rst 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  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 complete requires string between quotes, 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 complete requires string between quotes, for example:
  225. .. code-block:: cmake
  226. set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2")
  227. The conflicting package list of an RPM file could be printed with::
  228. rpm -qp --conflicts file.rpm
  229. .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
  230. CPACK_RPM_<component>_PACKAGE_REQUIRES_PRE
  231. .. versionadded:: 3.2
  232. RPM spec requires(pre) field.
  233. :Mandatory: No
  234. :Default:
  235. May be used to set RPM preinstall dependencies (requires(pre)). Note that
  236. you must enclose the complete requires string between quotes, for example:
  237. .. code-block:: cmake
  238. set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
  239. .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
  240. CPACK_RPM_<component>_PACKAGE_REQUIRES_POST
  241. .. versionadded:: 3.2
  242. RPM spec requires(post) field.
  243. :Mandatory: No
  244. :Default:
  245. May be used to set RPM postinstall dependencies (requires(post)). Note that
  246. you must enclose the complete requires string between quotes, for example:
  247. .. code-block:: cmake
  248. set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts")
  249. .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
  250. CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN
  251. .. versionadded:: 3.2
  252. RPM spec requires(postun) field.
  253. :Mandatory: No
  254. :Default:
  255. May be used to set RPM postuninstall dependencies (requires(postun)). Note
  256. that you must enclose the complete requires string between quotes, for
  257. example:
  258. .. code-block:: cmake
  259. set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "shadow-utils, initscripts")
  260. .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
  261. CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN
  262. .. versionadded:: 3.2
  263. RPM spec requires(preun) field.
  264. :Mandatory: No
  265. :Default:
  266. May be used to set RPM preuninstall dependencies (requires(preun)). Note that
  267. you must enclose the complete requires string between quotes, for example:
  268. .. code-block:: cmake
  269. set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts")
  270. .. variable:: CPACK_RPM_PACKAGE_SUGGESTS
  271. CPACK_RPM_<component>_PACKAGE_SUGGESTS
  272. RPM spec suggest field.
  273. :Mandatory: No
  274. :Default:
  275. May be used to set weak RPM dependencies (suggests). If ``rpmbuild`` doesn't
  276. support the ``Suggests`` tag, CPack will emit a warning and ignore this
  277. variable. Note that you must enclose the complete requires string between
  278. quotes.
  279. .. variable:: CPACK_RPM_PACKAGE_PROVIDES
  280. CPACK_RPM_<component>_PACKAGE_PROVIDES
  281. RPM spec provides field.
  282. :Mandatory: No
  283. :Default:
  284. May be used to set RPM dependencies (provides). The provided package list
  285. of an RPM file could be printed with::
  286. rpm -qp --provides file.rpm
  287. .. variable:: CPACK_RPM_PACKAGE_OBSOLETES
  288. CPACK_RPM_<component>_PACKAGE_OBSOLETES
  289. RPM spec obsoletes field.
  290. :Mandatory: No
  291. :Default:
  292. May be used to set RPM packages that are obsoleted by this one.
  293. .. variable:: CPACK_RPM_PACKAGE_RELOCATABLE
  294. build a relocatable RPM.
  295. :Mandatory: No
  296. :Default: CPACK_PACKAGE_RELOCATABLE
  297. If this variable is set to TRUE or ON, the CPack RPM generator will try
  298. to build a relocatable RPM package. A relocatable RPM may
  299. be installed using::
  300. rpm --prefix or --relocate
  301. in order to install it at an alternate place see rpm(8). Note that
  302. currently this may fail if :variable:`CPACK_SET_DESTDIR` is set to ``ON``. If
  303. :variable:`CPACK_SET_DESTDIR` is set then you will get a warning message but
  304. if there is file installed with absolute path you'll get unexpected behavior.
  305. .. variable:: CPACK_RPM_SPEC_INSTALL_POST
  306. .. deprecated:: 2.8.12 Use :variable:`CPACK_RPM_SPEC_MORE_DEFINE` instead.
  307. :Mandatory: No
  308. :Default:
  309. May be used to override the ``__spec_install_post`` section within the
  310. generated spec file. This affects the install step during package creation,
  311. not during package installation. For adding operations to be performed
  312. during package installation, use
  313. :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE` instead.
  314. .. variable:: CPACK_RPM_SPEC_MORE_DEFINE
  315. RPM extended spec definitions lines.
  316. :Mandatory: No
  317. :Default:
  318. May be used to add any ``%define`` lines to the generated spec file. An
  319. example of its use is to prevent stripping of executables (but note that
  320. this may also disable other default post install processing):
  321. .. code-block:: cmake
  322. set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true")
  323. .. variable:: CPACK_RPM_PACKAGE_DEBUG
  324. Toggle CPack RPM generator debug output.
  325. :Mandatory: No
  326. :Default:
  327. May be set when invoking cpack in order to trace debug information
  328. during CPack RPM run. For example you may launch CPack like this::
  329. cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM
  330. .. variable:: CPACK_RPM_USER_BINARY_SPECFILE
  331. CPACK_RPM_<componentName>_USER_BINARY_SPECFILE
  332. A user provided spec file.
  333. :Mandatory: No
  334. :Default:
  335. May be set by the user in order to specify a USER binary spec file
  336. to be used by the CPack RPM generator instead of generating the file.
  337. The specified file will be processed by configure_file( @ONLY).
  338. .. variable:: CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
  339. Spec file template.
  340. :Mandatory: No
  341. :Default:
  342. If set CPack will generate a template for USER specified binary
  343. spec file and stop with an error. For example launch CPack like this::
  344. cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM
  345. The user may then use this file in order to hand-craft is own
  346. binary spec file which may be used with
  347. :variable:`CPACK_RPM_USER_BINARY_SPECFILE`.
  348. .. variable:: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
  349. CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
  350. CPACK_RPM_PRE_TRANS_SCRIPT_FILE
  351. Path to file containing pre install/uninstall/transaction script.
  352. :Mandatory: No
  353. :Default:
  354. May be used to embed a pre installation/uninstallation/transaction script in the spec file.
  355. The referred script file (or both) will be read and directly
  356. put after the ``%pre`` or ``%preun`` section
  357. If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the install/uninstall/transaction
  358. script for each component can be overridden with
  359. :variable:`!CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE`,
  360. :variable:`!CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE`, and
  361. :variable:`!CPACK_RPM_<COMPONENT>_PRE_TRANS_SCRIPT_FILE`
  362. One may verify which scriptlet has been included with::
  363. rpm -qp --scripts package.rpm
  364. .. versionadded:: 3.18
  365. The :variable:`!CPACK_RPM_PRE_TRANS_SCRIPT_FILE` variable.
  366. .. variable:: CPACK_RPM_POST_INSTALL_SCRIPT_FILE
  367. CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
  368. CPACK_RPM_POST_TRANS_SCRIPT_FILE
  369. Path to file containing post install/uninstall/transaction script.
  370. :Mandatory: No
  371. :Default:
  372. May be used to embed a post installation/uninstallation/transaction script in the spec file.
  373. The referred script file (or both) will be read and directly
  374. put after the ``%post`` or ``%postun`` section.
  375. If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the install/uninstall/transaction
  376. script for each component can be overridden with
  377. :variable:`!CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE`,
  378. :variable:`!CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE`, and
  379. :variable:`!CPACK_RPM_<COMPONENT>_POST_TRANS_SCRIPT_FILE`
  380. One may verify which scriptlet has been included with::
  381. rpm -qp --scripts package.rpm
  382. .. versionadded:: 3.18
  383. The :variable:`!CPACK_RPM_POST_TRANS_SCRIPT_FILE` variable.
  384. .. variable:: CPACK_RPM_USER_FILELIST
  385. CPACK_RPM_<COMPONENT>_USER_FILELIST
  386. :Mandatory: No
  387. :Default:
  388. May be used to explicitly specify ``%(<directive>)`` file line
  389. in the spec file. Like ``%config(noreplace)`` or any other directive
  390. that be found in the ``%files`` section. Since
  391. the CPack RPM generator is generating the list of files (and directories) the
  392. user specified files of the :variable:`!CPACK_RPM_<COMPONENT>_USER_FILELIST` list will
  393. be removed from the generated list. If referring to directories do
  394. not add a trailing slash.
  395. .. versionadded:: 3.8
  396. You can have multiple directives per line, as in
  397. ``%attr(600,root,root) %config(noreplace)``.
  398. .. variable:: CPACK_RPM_CHANGELOG_FILE
  399. RPM changelog file.
  400. :Mandatory: No
  401. :Default:
  402. May be used to embed a changelog in the spec file.
  403. The referred file will be read and directly put after the ``%changelog``
  404. section.
  405. .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
  406. list of path to be excluded.
  407. :Mandatory: No
  408. :Default:
  409. The following paths are excluded by default:
  410. - ``/etc``
  411. - ``/etc/init.d``
  412. - ``/usr``
  413. - ``/usr/bin``
  414. - ``/usr/include``
  415. - ``/usr/lib``
  416. - ``/usr/libx32``
  417. - ``/usr/lib64``
  418. - ``/usr/share``
  419. - ``/usr/share/aclocal``
  420. - ``/usr/share/doc``
  421. May be used to exclude path (directories or files) from the auto-generated
  422. list of paths discovered by CPack RPM. The default value contains a
  423. reasonable set of values if the variable is not defined by the user. If the
  424. variable is defined by the user then the CPack RPM generator will NOT any of
  425. the default path. If you want to add some path to the default list then you
  426. can use :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` variable.
  427. .. versionadded:: 3.10
  428. Added ``/usr/share/aclocal`` to the default list of excludes.
  429. .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
  430. additional list of path to be excluded.
  431. :Mandatory: No
  432. :Default:
  433. May be used to add more exclude path (directories or files) from the initial
  434. default list of excluded paths. See
  435. :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST`.
  436. .. variable:: CPACK_RPM_RELOCATION_PATHS
  437. .. versionadded:: 3.2
  438. Packages relocation paths list.
  439. :Mandatory: No
  440. :Default:
  441. May be used to specify more than one relocation path per relocatable RPM.
  442. Variable contains a list of relocation paths that if relative are prefixed
  443. by the value of :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX` or by the
  444. value of :variable:`CPACK_PACKAGING_INSTALL_PREFIX` if the component version
  445. is not provided.
  446. Variable is not component based as its content can be used to set a different
  447. path prefix for e.g. binary dir and documentation dir at the same time.
  448. Only prefixes that are required by a certain component are added to that
  449. component - component must contain at least one file/directory/symbolic link
  450. with :variable:`CPACK_RPM_RELOCATION_PATHS` prefix for a certain relocation
  451. path to be added. Package will not contain any relocation paths if there are
  452. no files/directories/symbolic links on any of the provided prefix locations.
  453. Packages that either do not contain any relocation paths or contain
  454. files/directories/symbolic links that are outside relocation paths print
  455. out an :command:`AUTHOR_WARNING <message>` that RPM will be partially relocatable.
  456. .. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
  457. .. versionadded:: 3.2
  458. Per component relocation path install prefix.
  459. :Mandatory: No
  460. :Default: :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
  461. May be used to set per component :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
  462. for relocatable RPM packages.
  463. .. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION
  464. CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION
  465. .. versionadded:: 3.3
  466. Removal of default install prefix from relocation paths list.
  467. :Mandatory: No
  468. :Default: :variable:`CPACK_PACKAGING_INSTALL_PREFIX` or
  469. :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX`
  470. are treated as one of relocation paths
  471. May be used to remove :variable:`CPACK_PACKAGING_INSTALL_PREFIX` and
  472. :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX`
  473. from relocatable RPM prefix paths.
  474. .. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS
  475. .. versionadded:: 3.3
  476. :Mandatory: No
  477. :Default:
  478. Regular expressions that are added by default were taken from ``brp-compress`` RPM macro:
  479. - ``/usr/man/man.*``
  480. - ``/usr/man/.*/man.*``
  481. - ``/usr/info.*``
  482. - ``/usr/share/man/man.*``
  483. - ``/usr/share/man/.*/man.*``
  484. - ``/usr/share/info.*``
  485. - ``/usr/kerberos/man.*``
  486. - ``/usr/X11R6/man/man.*``
  487. - ``/usr/lib/perl5/man/man.*``
  488. - ``/usr/share/doc/.*/man/man.*``
  489. - ``/usr/lib/.*/man/man.*``
  490. May be used to set additional man dirs that could potentially be compressed
  491. by brp-compress RPM macro. Variable content must be a list of regular
  492. expressions that point to directories containing man files or to man files
  493. directly. Note that in order to compress man pages a path must also be
  494. present in brp-compress RPM script and that brp-compress script must be
  495. added to RPM configuration by the operating system.
  496. .. variable:: CPACK_RPM_DEFAULT_USER
  497. CPACK_RPM_<compName>_DEFAULT_USER
  498. .. versionadded:: 3.6
  499. default user ownership of RPM content
  500. :Mandatory: No
  501. :Default: ``root``
  502. Value should be user name and not UID.
  503. Note that ``<compName>`` must be in upper-case.
  504. .. variable:: CPACK_RPM_DEFAULT_GROUP
  505. CPACK_RPM_<compName>_DEFAULT_GROUP
  506. .. versionadded:: 3.6
  507. default group ownership of RPM content
  508. :Mandatory: No
  509. :Default: root
  510. Value should be group name and not GID.
  511. Note that ``<compName>`` must be in upper-case.
  512. .. variable:: CPACK_RPM_DEFAULT_FILE_PERMISSIONS
  513. CPACK_RPM_<compName>_DEFAULT_FILE_PERMISSIONS
  514. .. versionadded:: 3.6
  515. default permissions used for packaged files
  516. :Mandatory: No
  517. :Default: (system default)
  518. Accepted values are lists with PERMISSIONS. Valid permissions
  519. are:
  520. - ``OWNER_READ``
  521. - ``OWNER_WRITE``
  522. - ``OWNER_EXECUTE``
  523. - ``GROUP_READ``
  524. - ``GROUP_WRITE``
  525. - ``GROUP_EXECUTE``
  526. - ``WORLD_READ``
  527. - ``WORLD_WRITE``
  528. - ``WORLD_EXECUTE``
  529. Note that ``<compName>`` must be in upper-case.
  530. .. variable:: CPACK_RPM_DEFAULT_DIR_PERMISSIONS
  531. CPACK_RPM_<compName>_DEFAULT_DIR_PERMISSIONS
  532. .. versionadded:: 3.6
  533. default permissions used for packaged directories
  534. :Mandatory: No
  535. :Default: (system default)
  536. Accepted values are lists with PERMISSIONS. Valid permissions
  537. are the same as for :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`.
  538. Note that ``<compName>`` must be in upper-case.
  539. .. variable:: CPACK_RPM_INSTALL_WITH_EXEC
  540. .. versionadded:: 3.11
  541. force execute permissions on programs and shared libraries
  542. :Mandatory: No
  543. :Default: (system default)
  544. Force set owner, group and world execute permissions on programs and shared
  545. libraries. This can be used for creating valid rpm packages on systems such
  546. as Debian where shared libraries do not have execute permissions set.
  547. .. note::
  548. Programs and shared libraries without execute permissions are ignored during
  549. separation of debug symbols from the binary for debuginfo packages.
  550. Packaging of Symbolic Links
  551. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  552. .. versionadded:: 3.3
  553. The CPack RPM generator supports packaging of symbolic links:
  554. .. code-block:: cmake
  555. execute_process(COMMAND ${CMAKE_COMMAND}
  556. -E create_symlink <relative_path_location> <symlink_name>)
  557. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/<symlink_name>
  558. DESTINATION <symlink_location> COMPONENT libraries)
  559. Symbolic links will be optimized (paths will be shortened if possible)
  560. before being added to the package or if multiple relocation paths are
  561. detected, a post install symlink relocation script will be generated.
  562. Symbolic links may point to locations that are not packaged by the same
  563. package (either a different component or even not packaged at all) but
  564. those locations will be treated as if they were a part of the package
  565. while determining if symlink should be either created or present in a
  566. post install script - depending on relocation paths.
  567. .. versionchanged:: 3.6
  568. Symbolic links that point to locations outside packaging path produce a
  569. warning and are treated as non relocatable permanent symbolic links.
  570. Previous versions of CMake produced an error in this case.
  571. Currently there are a few limitations though:
  572. * For component based packaging component interdependency is not checked
  573. when processing symbolic links. Symbolic links pointing to content of
  574. a different component are treated the same way as if pointing to location
  575. that will not be packaged.
  576. * Symbolic links pointing to a location through one or more intermediate
  577. symbolic links will not be handled differently - if the intermediate
  578. symbolic link(s) is also on a relocatable path, relocating it during
  579. package installation may cause initial symbolic link to point to an
  580. invalid location.
  581. Packaging of debug information
  582. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  583. .. versionadded:: 3.7
  584. Debuginfo packages contain debug symbols and sources for debugging packaged
  585. binaries.
  586. Debuginfo RPM packaging has its own set of variables:
  587. .. variable:: CPACK_RPM_DEBUGINFO_PACKAGE
  588. CPACK_RPM_<component>_DEBUGINFO_PACKAGE
  589. Enable generation of debuginfo RPM package(s).
  590. :Mandatory: No
  591. :Default: ``OFF``
  592. .. note::
  593. Binaries must contain debug symbols before packaging so use either ``Debug``
  594. or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value.
  595. Additionally, if :variable:`CPACK_STRIP_FILES` is set, the files will be stripped before
  596. they get to the RPM generator, so will not contain debug symbols and
  597. a debuginfo package will not get built. Do not use with :variable:`CPACK_STRIP_FILES`.
  598. .. note::
  599. Packages generated from packages without binary files, with binary files but
  600. without execute permissions or without debug symbols will cause packaging
  601. termination.
  602. .. variable:: CPACK_BUILD_SOURCE_DIRS
  603. Provides locations of root directories of source files from which binaries
  604. were built.
  605. :Mandatory: Yes if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
  606. :Default:
  607. .. note::
  608. For CMake project :variable:`CPACK_BUILD_SOURCE_DIRS` is set by default to
  609. point to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR` paths.
  610. .. note::
  611. Sources with path prefixes that do not fall under any location provided with
  612. :variable:`CPACK_BUILD_SOURCE_DIRS` will not be present in debuginfo package.
  613. .. variable:: CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
  614. CPACK_RPM_<component>_BUILD_SOURCE_DIRS_PREFIX
  615. Prefix of location where sources will be placed during package installation.
  616. :Mandatory: Yes if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
  617. :Default: ``/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}`` and
  618. for component packaging ``/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}-<component>``
  619. .. note::
  620. Each source path prefix is additionally suffixed by ``src_<index>`` where
  621. index is index of the path used from :variable:`CPACK_BUILD_SOURCE_DIRS`
  622. variable. This produces ``${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_<index>``
  623. replacement path.
  624. Limitation is that replaced path part must be shorter or of equal
  625. length than the length of its replacement. If that is not the case either
  626. :variable:`CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX` variable has to be set to
  627. a shorter path or source directories must be placed on a longer path.
  628. .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS
  629. Directories containing sources that should be excluded from debuginfo packages.
  630. :Mandatory: No
  631. :Default:
  632. The following paths are excluded by default:
  633. - ``/usr``
  634. - ``/usr/src``
  635. - ``/usr/src/debug``
  636. Listed paths are owned by other RPM packages and should therefore not be
  637. deleted on debuginfo package uninstallation.
  638. .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION
  639. Paths that should be appended to :variable:`CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS`
  640. for exclusion.
  641. :Mandatory: No
  642. :Default:
  643. .. variable:: CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE
  644. .. versionadded:: 3.8
  645. Create a single debuginfo package even if components packaging is set.
  646. :Mandatory: No
  647. :Default: ``OFF``
  648. When this variable is enabled it produces a single debuginfo package even if
  649. component packaging is enabled.
  650. When using this feature in combination with components packaging and there is
  651. more than one component this variable requires :variable:`CPACK_RPM_MAIN_COMPONENT`
  652. to be set.
  653. .. note::
  654. If none of the :variable:`CPACK_RPM_<component>_DEBUGINFO_PACKAGE` variables
  655. is set then :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is automatically set to
  656. ``ON`` when :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` is set.
  657. .. variable:: CPACK_RPM_DEBUGINFO_FILE_NAME
  658. CPACK_RPM_<component>_DEBUGINFO_FILE_NAME
  659. .. versionadded:: 3.9
  660. Debuginfo package file name.
  661. :Mandatory: No
  662. :Default: rpmbuild tool generated package file name
  663. Alternatively provided debuginfo package file name must end with ``.rpm``
  664. suffix and should differ from file names of other generated packages.
  665. Variable may contain ``@cpack_component@`` placeholder which will be
  666. replaced by component name if component packaging is enabled otherwise it
  667. deletes the placeholder.
  668. Setting the variable to ``RPM-DEFAULT`` may be used to explicitly set
  669. filename generation to default.
  670. .. note::
  671. :variable:`CPACK_RPM_FILE_NAME` also supports rpmbuild tool generated package
  672. file name - disabled by default but can be enabled by setting the variable to
  673. ``RPM-DEFAULT``.
  674. Packaging of sources (SRPM)
  675. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  676. .. versionadded:: 3.7
  677. SRPM packaging is enabled by setting :variable:`CPACK_RPM_PACKAGE_SOURCES`
  678. variable while usually using :variable:`CPACK_INSTALLED_DIRECTORIES` variable
  679. to provide directory containing CMakeLists.txt and source files.
  680. For CMake projects SRPM package would be produced by executing::
  681. cpack -G RPM --config ./CPackSourceConfig.cmake
  682. .. note::
  683. Produced SRPM package is expected to be built with :manual:`cmake(1)` executable
  684. and packaged with :manual:`cpack(1)` executable so CMakeLists.txt has to be
  685. located in root source directory and must be able to generate binary rpm
  686. packages by executing :option:`cpack -G` command. The two executables as well as
  687. rpmbuild must also be present when generating binary rpm packages from the
  688. produced SRPM package.
  689. Once the SRPM package is generated it can be used to generate binary packages
  690. by creating a directory structure for rpm generation and executing rpmbuild
  691. tool::
  692. mkdir -p build_dir/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
  693. rpmbuild --define "_topdir <path_to_build_dir>" --rebuild <SRPM_file_name>
  694. Generated packages will be located in build_dir/RPMS directory or its sub
  695. directories.
  696. .. note::
  697. SRPM package internally uses CPack/RPM generator to generate binary packages
  698. so CMakeScripts.txt can decide during the SRPM to binary rpm generation step
  699. what content the package(s) should have as well as how they should be packaged
  700. (monolithic or components). CMake can decide this for e.g. by reading environment
  701. variables set by the package manager before starting the process of generating
  702. binary rpm packages. This way a single SRPM package can be used to produce
  703. different binary rpm packages on different platforms depending on the platform's
  704. packaging rules.
  705. Source RPM packaging has its own set of variables:
  706. .. variable:: CPACK_RPM_PACKAGE_SOURCES
  707. Should the content be packaged as a source rpm (default is binary rpm).
  708. :Mandatory: No
  709. :Default: ``OFF``
  710. .. note::
  711. For cmake projects :variable:`CPACK_RPM_PACKAGE_SOURCES` variable is set
  712. to ``OFF`` in CPackConfig.cmake and ``ON`` in CPackSourceConfig.cmake
  713. generated files.
  714. .. variable:: CPACK_RPM_SOURCE_PKG_BUILD_PARAMS
  715. Additional command-line parameters provided to :manual:`cmake(1)` executable.
  716. :Mandatory: No
  717. :Default:
  718. .. variable:: CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX
  719. Packaging install prefix that would be provided in :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
  720. variable for producing binary RPM packages.
  721. :Mandatory: Yes
  722. :Default: ``/``
  723. .. variable:: CPACK_RPM_BUILDREQUIRES
  724. List of source rpm build dependencies.
  725. :Mandatory: No
  726. :Default:
  727. May be used to set source RPM build dependencies (BuildRequires). Note that
  728. you must enclose the complete build requirements string between quotes, for
  729. example:
  730. .. code-block:: cmake
  731. set(CPACK_RPM_BUILDREQUIRES "python >= 2.5.0, cmake >= 2.8")
  732. .. variable:: CPACK_RPM_REQUIRES_EXCLUDE_FROM
  733. .. versionadded:: 3.22
  734. :Mandatory: No
  735. :Default:
  736. May be used to keep the dependency generator from scanning specific files
  737. or directories for dependencies. Note that you can use a regular
  738. expression that matches all of the directories or files, for example:
  739. .. code-block:: cmake
  740. set(CPACK_RPM_REQUIRES_EXCLUDE_FROM "bin/libqsqloci.*\\.so.*")