rpm.rst 33 KB

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