CPackRPM.cmake 109 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #.rst:
  4. # CPackRPM
  5. # --------
  6. #
  7. # The built in (binary) CPack RPM generator (Unix only)
  8. #
  9. # Variables specific to CPack RPM generator
  10. # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  11. #
  12. # CPackRPM may be used to create RPM packages using :module:`CPack`.
  13. # CPackRPM is a :module:`CPack` generator thus it uses the ``CPACK_XXX``
  14. # variables used by :module:`CPack`.
  15. #
  16. # CPackRPM has specific features which are controlled by the specifics
  17. # :code:`CPACK_RPM_XXX` variables.
  18. #
  19. # :code:`CPACK_RPM_<COMPONENT>_XXXX` variables may be used in order to have
  20. # **component** specific values. Note however that ``<COMPONENT>`` refers to the
  21. # **grouping name** written in upper case. It may be either a component name or
  22. # a component GROUP name. Usually those variables correspond to RPM spec file
  23. # entities. One may find information about spec files here
  24. # http://www.rpm.org/wiki/Docs
  25. #
  26. # .. note::
  27. #
  28. # `<COMPONENT>` part of variables is preferred to be in upper case (for e.g. if
  29. # component is named `foo` then use `CPACK_RPM_FOO_XXXX` variable name format)
  30. # as is with other `CPACK_<COMPONENT>_XXXX` variables.
  31. # For the purposes of back compatibility (CMake/CPack version 3.5 and lower)
  32. # support for same cased component (e.g. `fOo` would be used as
  33. # `CPACK_RPM_fOo_XXXX`) is still supported for variables defined in older
  34. # versions of CMake/CPack but is not guaranteed for variables that
  35. # will be added in the future. For the sake of back compatibility same cased
  36. # component variables also override upper cased versions where both are
  37. # present.
  38. #
  39. # Here are some CPackRPM wiki resources that are here for historic reasons and
  40. # are no longer maintained but may still prove useful:
  41. #
  42. # - https://cmake.org/Wiki/CMake:CPackConfiguration
  43. # - https://cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29
  44. #
  45. # List of CPackRPM specific variables:
  46. #
  47. # .. variable:: CPACK_RPM_COMPONENT_INSTALL
  48. #
  49. # Enable component packaging for CPackRPM
  50. #
  51. # * Mandatory : NO
  52. # * Default : OFF
  53. #
  54. # If enabled (ON) multiple packages are generated. By default a single package
  55. # containing files of all components is generated.
  56. #
  57. # .. variable:: CPACK_RPM_PACKAGE_SUMMARY
  58. # CPACK_RPM_<component>_PACKAGE_SUMMARY
  59. #
  60. # The RPM package summary.
  61. #
  62. # * Mandatory : YES
  63. # * Default : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
  64. #
  65. # .. variable:: CPACK_RPM_PACKAGE_NAME
  66. # CPACK_RPM_<component>_PACKAGE_NAME
  67. #
  68. # The RPM package name.
  69. #
  70. # * Mandatory : YES
  71. # * Default : :variable:`CPACK_PACKAGE_NAME`
  72. #
  73. # .. variable:: CPACK_RPM_FILE_NAME
  74. # CPACK_RPM_<component>_FILE_NAME
  75. #
  76. # Package file name.
  77. #
  78. # * Mandatory : YES
  79. # * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].rpm`` with spaces
  80. # replaced by '-'
  81. #
  82. # This may be set to ``RPM-DEFAULT`` to allow rpmbuild tool to generate package
  83. # file name by itself.
  84. # Alternatively provided package file name must end with ``.rpm`` suffix.
  85. #
  86. # .. note::
  87. #
  88. # By using user provided spec file, rpm macro extensions such as for
  89. # generating debuginfo packages or by simply using multiple components more
  90. # than one rpm file may be generated, either from a single spec file or from
  91. # multiple spec files (each component execution produces it's own spec file).
  92. # In such cases duplicate file names may occur as a result of this variable
  93. # setting or spec file content structure. Duplicate files get overwritten
  94. # and it is up to the packager to set the variables in a manner that will
  95. # prevent such errors.
  96. #
  97. # .. variable:: CPACK_RPM_MAIN_COMPONENT
  98. #
  99. # Main component that is packaged without component suffix.
  100. #
  101. # * Mandatory : NO
  102. # * Default : -
  103. #
  104. # This variable can be set to any component or group name so that component or
  105. # group rpm package is generated without component suffix in filename and
  106. # package name.
  107. #
  108. # .. variable:: CPACK_RPM_PACKAGE_EPOCH
  109. #
  110. # The RPM package epoch
  111. #
  112. # * Mandatory : No
  113. # * Default : -
  114. #
  115. # Optional number that should be incremented when changing versioning schemas
  116. # or fixing mistakes in the version numbers of older packages.
  117. #
  118. # .. variable:: CPACK_RPM_PACKAGE_VERSION
  119. #
  120. # The RPM package version.
  121. #
  122. # * Mandatory : YES
  123. # * Default : :variable:`CPACK_PACKAGE_VERSION`
  124. #
  125. # .. variable:: CPACK_RPM_PACKAGE_ARCHITECTURE
  126. # CPACK_RPM_<component>_PACKAGE_ARCHITECTURE
  127. #
  128. # The RPM package architecture.
  129. #
  130. # * Mandatory : YES
  131. # * Default : Native architecture output by ``uname -m``
  132. #
  133. # This may be set to ``noarch`` if you know you are building a noarch package.
  134. #
  135. # .. variable:: CPACK_RPM_PACKAGE_RELEASE
  136. #
  137. # The RPM package release.
  138. #
  139. # * Mandatory : YES
  140. # * Default : 1
  141. #
  142. # This is the numbering of the RPM package itself, i.e. the version of the
  143. # packaging and not the version of the content (see
  144. # :variable:`CPACK_RPM_PACKAGE_VERSION`). One may change the default value if
  145. # the previous packaging was buggy and/or you want to put here a fancy Linux
  146. # distro specific numbering.
  147. #
  148. # .. note::
  149. #
  150. # This is the string that goes into the RPM ``Release:`` field. Some distros
  151. # (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a number.
  152. # ``%{?dist}`` part can be added by setting :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.
  153. #
  154. # .. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST
  155. #
  156. # The dist tag that is added RPM ``Release:`` field.
  157. #
  158. # * Mandatory : NO
  159. # * Default : OFF
  160. #
  161. # This is the reported ``%{dist}`` tag from the current distribution or empty
  162. # ``%{dist}`` if RPM macro is not set. If this variable is set then RPM
  163. # ``Release:`` field value is set to ``${CPACK_RPM_PACKAGE_RELEASE}%{?dist}``.
  164. #
  165. # .. variable:: CPACK_RPM_PACKAGE_LICENSE
  166. #
  167. # The RPM package license policy.
  168. #
  169. # * Mandatory : YES
  170. # * Default : "unknown"
  171. #
  172. # .. variable:: CPACK_RPM_PACKAGE_GROUP
  173. # CPACK_RPM_<component>_PACKAGE_GROUP
  174. #
  175. # The RPM package group.
  176. #
  177. # * Mandatory : YES
  178. # * Default : "unknown"
  179. #
  180. # .. variable:: CPACK_RPM_PACKAGE_VENDOR
  181. #
  182. # The RPM package vendor.
  183. #
  184. # * Mandatory : YES
  185. # * Default : CPACK_PACKAGE_VENDOR if set or "unknown"
  186. #
  187. # .. variable:: CPACK_RPM_PACKAGE_URL
  188. # CPACK_RPM_<component>_PACKAGE_URL
  189. #
  190. # The projects URL.
  191. #
  192. # * Mandatory : NO
  193. # * Default : -
  194. #
  195. # .. variable:: CPACK_RPM_PACKAGE_DESCRIPTION
  196. # CPACK_RPM_<component>_PACKAGE_DESCRIPTION
  197. #
  198. # RPM package description.
  199. #
  200. # * Mandatory : YES
  201. # * Default : :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component
  202. # based installers only) if set, :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`
  203. # if set or "no package description available"
  204. #
  205. # .. variable:: CPACK_RPM_COMPRESSION_TYPE
  206. #
  207. # RPM compression type.
  208. #
  209. # * Mandatory : NO
  210. # * Default : -
  211. #
  212. # May be used to override RPM compression type to be used to build the
  213. # RPM. For example some Linux distribution now default to lzma or xz
  214. # compression whereas older cannot use such RPM. Using this one can enforce
  215. # compression type to be used.
  216. #
  217. # Possible values are:
  218. #
  219. # - lzma
  220. # - xz
  221. # - bzip2
  222. # - gzip
  223. #
  224. # .. variable:: CPACK_RPM_PACKAGE_AUTOREQ
  225. # CPACK_RPM_<component>_PACKAGE_AUTOREQ
  226. #
  227. # RPM spec autoreq field.
  228. #
  229. # * Mandatory : NO
  230. # * Default : -
  231. #
  232. # May be used to enable (1, yes) or disable (0, no) automatic shared libraries
  233. # dependency detection. Dependencies are added to requires list.
  234. #
  235. # .. note::
  236. #
  237. # By default automatic dependency detection is enabled by rpm generator.
  238. #
  239. # .. variable:: CPACK_RPM_PACKAGE_AUTOPROV
  240. # CPACK_RPM_<component>_PACKAGE_AUTOPROV
  241. #
  242. # RPM spec autoprov field.
  243. #
  244. # * Mandatory : NO
  245. # * Default : -
  246. #
  247. # May be used to enable (1, yes) or disable (0, no) automatic listing of shared
  248. # libraries that are provided by the package. Shared libraries are added to
  249. # provides list.
  250. #
  251. # .. note::
  252. #
  253. # By default automatic provides detection is enabled by rpm generator.
  254. #
  255. # .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV
  256. # CPACK_RPM_<component>_PACKAGE_AUTOREQPROV
  257. #
  258. # RPM spec autoreqprov field.
  259. #
  260. # * Mandatory : NO
  261. # * Default : -
  262. #
  263. # Variable enables/disables autoreq and autoprov at the same time.
  264. # See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and :variable:`CPACK_RPM_PACKAGE_AUTOPROV`
  265. # for more details.
  266. #
  267. # .. note::
  268. #
  269. # By default automatic detection feature is enabled by rpm.
  270. #
  271. # .. variable:: CPACK_RPM_PACKAGE_REQUIRES
  272. # CPACK_RPM_<component>_PACKAGE_REQUIRES
  273. #
  274. # RPM spec requires field.
  275. #
  276. # * Mandatory : NO
  277. # * Default : -
  278. #
  279. # May be used to set RPM dependencies (requires). Note that you must enclose
  280. # the complete requires string between quotes, for example::
  281. #
  282. # set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8")
  283. #
  284. # The required package list of an RPM file could be printed with::
  285. #
  286. # rpm -qp --requires file.rpm
  287. #
  288. # .. variable:: CPACK_RPM_PACKAGE_CONFLICTS
  289. # CPACK_RPM_<component>_PACKAGE_CONFLICTS
  290. #
  291. # RPM spec conflicts field.
  292. #
  293. # * Mandatory : NO
  294. # * Default : -
  295. #
  296. # May be used to set negative RPM dependencies (conflicts). Note that you must
  297. # enclose the complete requires string between quotes, for example::
  298. #
  299. # set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2")
  300. #
  301. # The conflicting package list of an RPM file could be printed with::
  302. #
  303. # rpm -qp --conflicts file.rpm
  304. #
  305. # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
  306. # CPACK_RPM_<component>_PACKAGE_REQUIRES_PRE
  307. #
  308. # RPM spec requires(pre) field.
  309. #
  310. # * Mandatory : NO
  311. # * Default : -
  312. #
  313. # May be used to set RPM preinstall dependencies (requires(pre)). Note that
  314. # you must enclose the complete requires string between quotes, for example::
  315. #
  316. # set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
  317. #
  318. # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
  319. # CPACK_RPM_<component>_PACKAGE_REQUIRES_POST
  320. #
  321. # RPM spec requires(post) field.
  322. #
  323. # * Mandatory : NO
  324. # * Default : -
  325. #
  326. # May be used to set RPM postinstall dependencies (requires(post)). Note that
  327. # you must enclose the complete requires string between quotes, for example::
  328. #
  329. # set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts")
  330. #
  331. # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
  332. # CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN
  333. #
  334. # RPM spec requires(postun) field.
  335. #
  336. # * Mandatory : NO
  337. # * Default : -
  338. #
  339. # May be used to set RPM postuninstall dependencies (requires(postun)). Note
  340. # that you must enclose the complete requires string between quotes, for
  341. # example::
  342. #
  343. # set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "shadow-utils, initscripts")
  344. #
  345. # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
  346. # CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN
  347. #
  348. # RPM spec requires(preun) field.
  349. #
  350. # * Mandatory : NO
  351. # * Default : -
  352. #
  353. # May be used to set RPM preuninstall dependencies (requires(preun)). Note that
  354. # you must enclose the complete requires string between quotes, for example::
  355. #
  356. # set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts")
  357. #
  358. # .. variable:: CPACK_RPM_PACKAGE_SUGGESTS
  359. # CPACK_RPM_<component>_PACKAGE_SUGGESTS
  360. #
  361. # RPM spec suggest field.
  362. #
  363. # * Mandatory : NO
  364. # * Default : -
  365. #
  366. # May be used to set weak RPM dependencies (suggests). Note that you must
  367. # enclose the complete requires string between quotes.
  368. #
  369. # .. variable:: CPACK_RPM_PACKAGE_PROVIDES
  370. # CPACK_RPM_<component>_PACKAGE_PROVIDES
  371. #
  372. # RPM spec provides field.
  373. #
  374. # * Mandatory : NO
  375. # * Default : -
  376. #
  377. # May be used to set RPM dependencies (provides). The provided package list
  378. # of an RPM file could be printed with::
  379. #
  380. # rpm -qp --provides file.rpm
  381. #
  382. # .. variable:: CPACK_RPM_PACKAGE_OBSOLETES
  383. # CPACK_RPM_<component>_PACKAGE_OBSOLETES
  384. #
  385. # RPM spec obsoletes field.
  386. #
  387. # * Mandatory : NO
  388. # * Default : -
  389. #
  390. # May be used to set RPM packages that are obsoleted by this one.
  391. #
  392. # .. variable:: CPACK_RPM_PACKAGE_RELOCATABLE
  393. #
  394. # build a relocatable RPM.
  395. #
  396. # * Mandatory : NO
  397. # * Default : CPACK_PACKAGE_RELOCATABLE
  398. #
  399. # If this variable is set to TRUE or ON CPackRPM will try
  400. # to build a relocatable RPM package. A relocatable RPM may
  401. # be installed using::
  402. #
  403. # rpm --prefix or --relocate
  404. #
  405. # in order to install it at an alternate place see rpm(8). Note that
  406. # currently this may fail if :variable:`CPACK_SET_DESTDIR` is set to ``ON``. If
  407. # :variable:`CPACK_SET_DESTDIR` is set then you will get a warning message but
  408. # if there is file installed with absolute path you'll get unexpected behavior.
  409. #
  410. # .. variable:: CPACK_RPM_SPEC_INSTALL_POST
  411. #
  412. # Deprecated - use :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE` instead.
  413. #
  414. # * Mandatory : NO
  415. # * Default : -
  416. # * Deprecated: YES
  417. #
  418. # This way of specifying post-install script is deprecated, use
  419. # :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE`.
  420. # May be used to set an RPM post-install command inside the spec file.
  421. # For example setting it to ``/bin/true`` may be used to prevent
  422. # rpmbuild to strip binaries.
  423. #
  424. # .. variable:: CPACK_RPM_SPEC_MORE_DEFINE
  425. #
  426. # RPM extended spec definitions lines.
  427. #
  428. # * Mandatory : NO
  429. # * Default : -
  430. #
  431. # May be used to add any ``%define`` lines to the generated spec file.
  432. #
  433. # .. variable:: CPACK_RPM_PACKAGE_DEBUG
  434. #
  435. # Toggle CPackRPM debug output.
  436. #
  437. # * Mandatory : NO
  438. # * Default : -
  439. #
  440. # May be set when invoking cpack in order to trace debug information
  441. # during CPack RPM run. For example you may launch CPack like this::
  442. #
  443. # cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM
  444. #
  445. # .. variable:: CPACK_RPM_USER_BINARY_SPECFILE
  446. # CPACK_RPM_<componentName>_USER_BINARY_SPECFILE
  447. #
  448. # A user provided spec file.
  449. #
  450. # * Mandatory : NO
  451. # * Default : -
  452. #
  453. # May be set by the user in order to specify a USER binary spec file
  454. # to be used by CPackRPM instead of generating the file.
  455. # The specified file will be processed by configure_file( @ONLY).
  456. #
  457. # .. variable:: CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
  458. #
  459. # Spec file template.
  460. #
  461. # * Mandatory : NO
  462. # * Default : -
  463. #
  464. # If set CPack will generate a template for USER specified binary
  465. # spec file and stop with an error. For example launch CPack like this::
  466. #
  467. # cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM
  468. #
  469. # The user may then use this file in order to hand-craft is own
  470. # binary spec file which may be used with
  471. # :variable:`CPACK_RPM_USER_BINARY_SPECFILE`.
  472. #
  473. # .. variable:: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
  474. # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
  475. #
  476. # Path to file containing pre (un)install script.
  477. #
  478. # * Mandatory : NO
  479. # * Default : -
  480. #
  481. # May be used to embed a pre (un)installation script in the spec file.
  482. # The referred script file (or both) will be read and directly
  483. # put after the ``%pre`` or ``%preun`` section
  484. # If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the (un)install
  485. # script for each component can be overridden with
  486. # ``CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE`` and
  487. # ``CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE``.
  488. # One may verify which scriptlet has been included with::
  489. #
  490. # rpm -qp --scripts package.rpm
  491. #
  492. # .. variable:: CPACK_RPM_POST_INSTALL_SCRIPT_FILE
  493. # CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
  494. #
  495. # Path to file containing post (un)install script.
  496. #
  497. # * Mandatory : NO
  498. # * Default : -
  499. #
  500. # May be used to embed a post (un)installation script in the spec file.
  501. # The referred script file (or both) will be read and directly
  502. # put after the ``%post`` or ``%postun`` section.
  503. # If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the (un)install
  504. # script for each component can be overridden with
  505. # ``CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE`` and
  506. # ``CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE``.
  507. # One may verify which scriptlet has been included with::
  508. #
  509. # rpm -qp --scripts package.rpm
  510. #
  511. # .. variable:: CPACK_RPM_USER_FILELIST
  512. # CPACK_RPM_<COMPONENT>_USER_FILELIST
  513. #
  514. # * Mandatory : NO
  515. # * Default : -
  516. #
  517. # May be used to explicitly specify ``%(<directive>)`` file line
  518. # in the spec file. Like ``%config(noreplace)`` or any other directive
  519. # that be found in the ``%files`` section. You can have multiple directives
  520. # per line, as in ``%attr(600,root,root) %config(noreplace)``. Since
  521. # CPackRPM is generating the list of files (and directories) the user
  522. # specified files of the ``CPACK_RPM_<COMPONENT>_USER_FILELIST`` list will
  523. # be removed from the generated list. If referring to directories do
  524. # not add a trailing slash.
  525. #
  526. # .. variable:: CPACK_RPM_CHANGELOG_FILE
  527. #
  528. # RPM changelog file.
  529. #
  530. # * Mandatory : NO
  531. # * Default : -
  532. #
  533. # May be used to embed a changelog in the spec file.
  534. # The referred file will be read and directly put after the ``%changelog``
  535. # section.
  536. #
  537. # .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
  538. #
  539. # list of path to be excluded.
  540. #
  541. # * Mandatory : NO
  542. # * Default : /etc /etc/init.d /usr /usr/bin /usr/include /usr/lib
  543. # /usr/libx32 /usr/lib64 /usr/share /usr/share/aclocal
  544. # /usr/share/doc
  545. #
  546. # May be used to exclude path (directories or files) from the auto-generated
  547. # list of paths discovered by CPack RPM. The default value contains a
  548. # reasonable set of values if the variable is not defined by the user. If the
  549. # variable is defined by the user then CPackRPM will NOT any of the default
  550. # path. If you want to add some path to the default list then you can use
  551. # :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` variable.
  552. #
  553. # .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
  554. #
  555. # additional list of path to be excluded.
  556. #
  557. # * Mandatory : NO
  558. # * Default : -
  559. #
  560. # May be used to add more exclude path (directories or files) from the initial
  561. # default list of excluded paths. See
  562. # :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST`.
  563. #
  564. # .. variable:: CPACK_RPM_RELOCATION_PATHS
  565. #
  566. # Packages relocation paths list.
  567. #
  568. # * Mandatory : NO
  569. # * Default : -
  570. #
  571. # May be used to specify more than one relocation path per relocatable RPM.
  572. # Variable contains a list of relocation paths that if relative are prefixed
  573. # by the value of :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX` or by the
  574. # value of :variable:`CPACK_PACKAGING_INSTALL_PREFIX` if the component version
  575. # is not provided.
  576. # Variable is not component based as its content can be used to set a different
  577. # path prefix for e.g. binary dir and documentation dir at the same time.
  578. # Only prefixes that are required by a certain component are added to that
  579. # component - component must contain at least one file/directory/symbolic link
  580. # with :variable:`CPACK_RPM_RELOCATION_PATHS` prefix for a certain relocation
  581. # path to be added. Package will not contain any relocation paths if there are
  582. # no files/directories/symbolic links on any of the provided prefix locations.
  583. # Packages that either do not contain any relocation paths or contain
  584. # files/directories/symbolic links that are outside relocation paths print
  585. # out an ``AUTHOR_WARNING`` that RPM will be partially relocatable.
  586. #
  587. # .. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
  588. #
  589. # Per component relocation path install prefix.
  590. #
  591. # * Mandatory : NO
  592. # * Default : CPACK_PACKAGING_INSTALL_PREFIX
  593. #
  594. # May be used to set per component :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
  595. # for relocatable RPM packages.
  596. #
  597. # .. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION
  598. # CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION
  599. #
  600. # Removal of default install prefix from relocation paths list.
  601. #
  602. # * Mandatory : NO
  603. # * Default : CPACK_PACKAGING_INSTALL_PREFIX or CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
  604. # are treated as one of relocation paths
  605. #
  606. # May be used to remove CPACK_PACKAGING_INSTALL_PREFIX and CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
  607. # from relocatable RPM prefix paths.
  608. #
  609. # .. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS
  610. #
  611. # * Mandatory : NO
  612. # * Default : -
  613. #
  614. # May be used to set additional man dirs that could potentially be compressed
  615. # by brp-compress RPM macro. Variable content must be a list of regular
  616. # expressions that point to directories containing man files or to man files
  617. # directly. Note that in order to compress man pages a path must also be
  618. # present in brp-compress RPM script and that brp-compress script must be
  619. # added to RPM configuration by the operating system.
  620. #
  621. # Regular expressions that are added by default were taken from brp-compress
  622. # RPM macro:
  623. #
  624. # - /usr/man/man.*
  625. # - /usr/man/.*/man.*
  626. # - /usr/info.*
  627. # - /usr/share/man/man.*
  628. # - /usr/share/man/.*/man.*
  629. # - /usr/share/info.*
  630. # - /usr/kerberos/man.*
  631. # - /usr/X11R6/man/man.*
  632. # - /usr/lib/perl5/man/man.*
  633. # - /usr/share/doc/.*/man/man.*
  634. # - /usr/lib/.*/man/man.*
  635. #
  636. # .. variable:: CPACK_RPM_DEFAULT_USER
  637. # CPACK_RPM_<compName>_DEFAULT_USER
  638. #
  639. # default user ownership of RPM content
  640. #
  641. # * Mandatory : NO
  642. # * Default : root
  643. #
  644. # Value should be user name and not UID.
  645. # Note that <compName> must be in upper-case.
  646. #
  647. # .. variable:: CPACK_RPM_DEFAULT_GROUP
  648. # CPACK_RPM_<compName>_DEFAULT_GROUP
  649. #
  650. # default group ownership of RPM content
  651. #
  652. # * Mandatory : NO
  653. # * Default : root
  654. #
  655. # Value should be group name and not GID.
  656. # Note that <compName> must be in upper-case.
  657. #
  658. # .. variable:: CPACK_RPM_DEFAULT_FILE_PERMISSIONS
  659. # CPACK_RPM_<compName>_DEFAULT_FILE_PERMISSIONS
  660. #
  661. # default permissions used for packaged files
  662. #
  663. # * Mandatory : NO
  664. # * Default : - (system default)
  665. #
  666. # Accepted values are lists with ``PERMISSIONS``. Valid permissions
  667. # are:
  668. #
  669. # - OWNER_READ
  670. # - OWNER_WRITE
  671. # - OWNER_EXECUTE
  672. # - GROUP_READ
  673. # - GROUP_WRITE
  674. # - GROUP_EXECUTE
  675. # - WORLD_READ
  676. # - WORLD_WRITE
  677. # - WORLD_EXECUTE
  678. #
  679. # Note that <compName> must be in upper-case.
  680. #
  681. # .. variable:: CPACK_RPM_DEFAULT_DIR_PERMISSIONS
  682. # CPACK_RPM_<compName>_DEFAULT_DIR_PERMISSIONS
  683. #
  684. # default permissions used for packaged directories
  685. #
  686. # * Mandatory : NO
  687. # * Default : - (system default)
  688. #
  689. # Accepted values are lists with PERMISSIONS. Valid permissions
  690. # are the same as for :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`.
  691. # Note that <compName> must be in upper-case.
  692. #
  693. # .. variable:: CPACK_RPM_INSTALL_WITH_EXEC
  694. #
  695. # force execute permissions on programs and shared libraries
  696. #
  697. # * Mandatory : NO
  698. # * Default : - (system default)
  699. #
  700. # Force set owner, group and world execute permissions on programs and shared
  701. # libraries. This can be used for creating valid rpm packages on systems such
  702. # as Debian where shared libraries do not have execute permissions set.
  703. #
  704. # .. note::
  705. #
  706. # Programs and shared libraries without execute permissions are ignored during
  707. # separation of debug symbols from the binary for debuginfo packages.
  708. #
  709. # Packaging of Symbolic Links
  710. # ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  711. #
  712. # CPackRPM supports packaging of symbolic links::
  713. #
  714. # execute_process(COMMAND ${CMAKE_COMMAND}
  715. # -E create_symlink <relative_path_location> <symlink_name>)
  716. # install(FILES ${CMAKE_CURRENT_BINARY_DIR}/<symlink_name>
  717. # DESTINATION <symlink_location> COMPONENT libraries)
  718. #
  719. # Symbolic links will be optimized (paths will be shortened if possible)
  720. # before being added to the package or if multiple relocation paths are
  721. # detected, a post install symlink relocation script will be generated.
  722. #
  723. # Symbolic links may point to locations that are not packaged by the same
  724. # package (either a different component or even not packaged at all) but
  725. # those locations will be treated as if they were a part of the package
  726. # while determining if symlink should be either created or present in a
  727. # post install script - depending on relocation paths.
  728. #
  729. # Symbolic links that point to locations outside packaging path produce a
  730. # warning and are treated as non relocatable permanent symbolic links.
  731. #
  732. # Currently there are a few limitations though:
  733. #
  734. # * For component based packaging component interdependency is not checked
  735. # when processing symbolic links. Symbolic links pointing to content of
  736. # a different component are treated the same way as if pointing to location
  737. # that will not be packaged.
  738. #
  739. # * Symbolic links pointing to a location through one or more intermediate
  740. # symbolic links will not be handled differently - if the intermediate
  741. # symbolic link(s) is also on a relocatable path, relocating it during
  742. # package installation may cause initial symbolic link to point to an
  743. # invalid location.
  744. #
  745. # Packaging of debug information
  746. # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  747. #
  748. # Debuginfo packages contain debug symbols and sources for debugging packaged
  749. # binaries.
  750. #
  751. # Debuginfo RPM packaging has it's own set of variables:
  752. #
  753. # .. variable:: CPACK_RPM_DEBUGINFO_PACKAGE
  754. # CPACK_RPM_<component>_DEBUGINFO_PACKAGE
  755. #
  756. # Enable generation of debuginfo RPM package(s).
  757. #
  758. # * Mandatory : NO
  759. # * Default : OFF
  760. #
  761. # .. note::
  762. #
  763. # Binaries must contain debug symbols before packaging so use either ``Debug``
  764. # or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value.
  765. #
  766. # .. note::
  767. #
  768. # Packages generated from packages without binary files, with binary files but
  769. # without execute permissions or without debug symbols will cause packaging
  770. # termination.
  771. #
  772. # .. variable:: CPACK_BUILD_SOURCE_DIRS
  773. #
  774. # Provides locations of root directories of source files from which binaries
  775. # were built.
  776. #
  777. # * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
  778. # * Default : -
  779. #
  780. # .. note::
  781. #
  782. # For CMake project :variable:`CPACK_BUILD_SOURCE_DIRS` is set by default to
  783. # point to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR` paths.
  784. #
  785. # .. note::
  786. #
  787. # Sources with path prefixes that do not fall under any location provided with
  788. # :variable:`CPACK_BUILD_SOURCE_DIRS` will not be present in debuginfo package.
  789. #
  790. # .. variable:: CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
  791. # CPACK_RPM_<component>_BUILD_SOURCE_DIRS_PREFIX
  792. #
  793. # Prefix of location where sources will be placed during package installation.
  794. #
  795. # * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
  796. # * Default : "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>" and
  797. # for component packaging "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>-<component>"
  798. #
  799. # .. note::
  800. #
  801. # Each source path prefix is additionally suffixed by ``src_<index>`` where
  802. # index is index of the path used from :variable:`CPACK_BUILD_SOURCE_DIRS`
  803. # variable. This produces ``<CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX>/src_<index>``
  804. # replacement path.
  805. # Limitation is that replaced path part must be shorter or of equal
  806. # length than the length of its replacement. If that is not the case either
  807. # :variable:`CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX` variable has to be set to
  808. # a shorter path or source directories must be placed on a longer path.
  809. #
  810. # .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS
  811. #
  812. # Directories containing sources that should be excluded from debuginfo packages.
  813. #
  814. # * Mandatory : NO
  815. # * Default : "/usr /usr/src /usr/src/debug"
  816. #
  817. # Listed paths are owned by other RPM packages and should therefore not be
  818. # deleted on debuginfo package uninstallation.
  819. #
  820. # .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION
  821. #
  822. # Paths that should be appended to :variable:`CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS`
  823. # for exclusion.
  824. #
  825. # * Mandatory : NO
  826. # * Default : -
  827. #
  828. # .. variable:: CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE
  829. #
  830. # Create a single debuginfo package even if components packaging is set.
  831. #
  832. # * Mandatory : NO
  833. # * Default : OFF
  834. #
  835. # When this variable is enabled it produces a single debuginfo package even if
  836. # component packaging is enabled.
  837. #
  838. # When using this feature in combination with components packaging and there is
  839. # more than one component this variable requires :variable:`CPACK_RPM_MAIN_COMPONENT`
  840. # to be set.
  841. #
  842. # .. note::
  843. #
  844. # If none of the :variable:`CPACK_RPM_<component>_DEBUGINFO_PACKAGE` variables
  845. # is set then :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is automatically set to
  846. # ``ON`` when :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` is set.
  847. #
  848. # .. variable:: CPACK_RPM_DEBUGINFO_FILE_NAME
  849. # CPACK_RPM_<component>_DEBUGINFO_FILE_NAME
  850. #
  851. # Debuginfo package file name.
  852. #
  853. # * Mandatory : NO
  854. # * Default : rpmbuild tool generated package file name
  855. #
  856. # Alternatively provided debuginfo package file name must end with ``.rpm``
  857. # suffix and should differ from file names of other generated packages.
  858. #
  859. # Variable may contain ``@cpack_component@`` placeholder which will be
  860. # replaced by component name if component packaging is enabled otherwise it
  861. # deletes the placeholder.
  862. #
  863. # Setting the variable to ``RPM-DEFAULT`` may be used to explicitly set
  864. # filename generation to default.
  865. #
  866. # .. note::
  867. #
  868. # :variable:`CPACK_RPM_FILE_NAME` also supports rpmbuild tool generated package
  869. # file name - disabled by default but can be enabled by setting the variable to
  870. # ``RPM-DEFAULT``.
  871. #
  872. # Packaging of sources (SRPM)
  873. # ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  874. #
  875. # SRPM packaging is enabled by setting :variable:`CPACK_RPM_PACKAGE_SOURCES`
  876. # variable while usually using :variable:`CPACK_INSTALLED_DIRECTORIES` variable
  877. # to provide directory containing CMakeLists.txt and source files.
  878. #
  879. # For CMake projects SRPM package would be product by executing:
  880. #
  881. # ``cpack -G RPM --config ./CPackSourceConfig.cmake``
  882. #
  883. # .. note::
  884. #
  885. # Produced SRPM package is expected to be built with :manual:`cmake(1)` executable
  886. # and packaged with :manual:`cpack(1)` executable so CMakeLists.txt has to be
  887. # located in root source directory and must be able to generate binary rpm
  888. # packages by executing ``cpack -G`` command. The two executables as well as
  889. # rpmbuild must also be present when generating binary rpm packages from the
  890. # produced SRPM package.
  891. #
  892. # Once the SRPM package is generated it can be used to generate binary packages
  893. # by creating a directory structure for rpm generation and executing rpmbuild
  894. # tool:
  895. #
  896. # ``mkdir -p build_dir/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}``
  897. # ``rpmbuild --define "_topdir <path_to_build_dir>" --rebuild <SRPM_file_name>``
  898. #
  899. # Generated packages will be located in build_dir/RPMS directory or its sub
  900. # directories.
  901. #
  902. # .. note::
  903. #
  904. # SRPM package internally uses CPack/RPM generator to generate binary packages
  905. # so CMakeScripts.txt can decide during the SRPM to binary rpm generation step
  906. # what content the package(s) should have as well as how they should be packaged
  907. # (monolithic or components). CMake can decide this for e.g. by reading environment
  908. # variables set by the package manager before starting the process of generating
  909. # binary rpm packages. This way a single SRPM package can be used to produce
  910. # different binary rpm packages on different platforms depending on the platform's
  911. # packaging rules.
  912. #
  913. # Source RPM packaging has it's own set of variables:
  914. #
  915. # .. variable:: CPACK_RPM_PACKAGE_SOURCES
  916. #
  917. # Should the content be packaged as a source rpm (default is binary rpm).
  918. #
  919. # * Mandatory : NO
  920. # * Default : OFF
  921. #
  922. # .. note::
  923. #
  924. # For cmake projects :variable:`CPACK_RPM_PACKAGE_SOURCES` variable is set
  925. # to ``OFF`` in CPackConfig.cmake and ``ON`` in CPackSourceConfig.cmake
  926. # generated files.
  927. #
  928. # .. variable:: CPACK_RPM_SOURCE_PKG_BUILD_PARAMS
  929. #
  930. # Additional command-line parameters provided to :manual:`cmake(1)` executable.
  931. #
  932. # * Mandatory : NO
  933. # * Default : -
  934. #
  935. # .. variable:: CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX
  936. #
  937. # Packaging install prefix that would be provided in :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
  938. # variable for producing binary RPM packages.
  939. #
  940. # * Mandatory : YES
  941. # * Default : "/"
  942. #
  943. # .. VARIABLE:: CPACK_RPM_BUILDREQUIRES
  944. #
  945. # List of source rpm build dependencies.
  946. #
  947. # * Mandatory : NO
  948. # * Default : -
  949. #
  950. # May be used to set source RPM build dependencies (BuildRequires). Note that
  951. # you must enclose the complete build requirements string between quotes, for
  952. # example::
  953. #
  954. # set(CPACK_RPM_BUILDREQUIRES "python >= 2.5.0, cmake >= 2.8")
  955. # Author: Eric Noulard with the help of Alexander Neundorf.
  956. function(get_file_permissions FILE RETURN_VAR)
  957. execute_process(COMMAND ls -l ${FILE}
  958. OUTPUT_VARIABLE permissions_
  959. ERROR_QUIET
  960. OUTPUT_STRIP_TRAILING_WHITESPACE)
  961. cmake_policy(SET CMP0007 NEW)
  962. string(REPLACE " " ";" permissions_ "${permissions_}")
  963. list(GET permissions_ 0 permissions_)
  964. unset(text_notation_)
  965. set(any_chars_ ".")
  966. foreach(PERMISSION_TYPE "OWNER" "GROUP" "WORLD")
  967. if(permissions_ MATCHES "${any_chars_}r.*")
  968. list(APPEND text_notation_ "${PERMISSION_TYPE}_READ")
  969. endif()
  970. string(APPEND any_chars_ ".")
  971. if(permissions_ MATCHES "${any_chars_}w.*")
  972. list(APPEND text_notation_ "${PERMISSION_TYPE}_WRITE")
  973. endif()
  974. string(APPEND any_chars_ ".")
  975. if(permissions_ MATCHES "${any_chars_}x.*")
  976. list(APPEND text_notation_ "${PERMISSION_TYPE}_EXECUTE")
  977. endif()
  978. endforeach()
  979. set(${RETURN_VAR} "${text_notation_}" PARENT_SCOPE)
  980. endfunction()
  981. function(get_unix_permissions_octal_notation PERMISSIONS_VAR RETURN_VAR)
  982. set(PERMISSIONS ${${PERMISSIONS_VAR}})
  983. list(LENGTH PERMISSIONS PERM_LEN_PRE)
  984. list(REMOVE_DUPLICATES PERMISSIONS)
  985. list(LENGTH PERMISSIONS PERM_LEN_POST)
  986. if(NOT ${PERM_LEN_PRE} EQUAL ${PERM_LEN_POST})
  987. message(FATAL_ERROR "${PERMISSIONS_VAR} contains duplicate values.")
  988. endif()
  989. foreach(PERMISSION_TYPE "OWNER" "GROUP" "WORLD")
  990. set(${PERMISSION_TYPE}_PERMISSIONS 0)
  991. foreach(PERMISSION ${PERMISSIONS})
  992. if("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_READ")
  993. math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 4")
  994. elseif("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_WRITE")
  995. math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 2")
  996. elseif("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_EXECUTE")
  997. math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 1")
  998. elseif(PERMISSION MATCHES "${PERMISSION_TYPE}.*")
  999. message(FATAL_ERROR "${PERMISSIONS_VAR} contains invalid values.")
  1000. endif()
  1001. endforeach()
  1002. endforeach()
  1003. set(${RETURN_VAR} "${OWNER_PERMISSIONS}${GROUP_PERMISSIONS}${WORLD_PERMISSIONS}" PARENT_SCOPE)
  1004. endfunction()
  1005. function(cpack_rpm_prepare_relocation_paths)
  1006. # set appropriate prefix, remove possible trailing slash and convert backslashes to slashes
  1007. if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX)
  1008. file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX}" PATH_PREFIX)
  1009. elseif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX)
  1010. file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX}" PATH_PREFIX)
  1011. else()
  1012. file(TO_CMAKE_PATH "${CPACK_PACKAGING_INSTALL_PREFIX}" PATH_PREFIX)
  1013. endif()
  1014. set(RPM_RELOCATION_PATHS "${CPACK_RPM_RELOCATION_PATHS}")
  1015. list(REMOVE_DUPLICATES RPM_RELOCATION_PATHS)
  1016. # set base path prefix
  1017. if(EXISTS "${WDIR}/${PATH_PREFIX}")
  1018. if(NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND
  1019. NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION AND
  1020. NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_INSTALL_PREFIX_RELOCATION)
  1021. string(APPEND TMP_RPM_PREFIXES "Prefix: ${PATH_PREFIX}\n")
  1022. list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}")
  1023. if(CPACK_RPM_PACKAGE_DEBUG)
  1024. message("CPackRPM:Debug: removing '${PATH_PREFIX}' from relocation paths")
  1025. endif()
  1026. endif()
  1027. endif()
  1028. # set other path prefixes
  1029. foreach(RELOCATION_PATH ${RPM_RELOCATION_PATHS})
  1030. if(IS_ABSOLUTE "${RELOCATION_PATH}")
  1031. set(PREPARED_RELOCATION_PATH "${RELOCATION_PATH}")
  1032. elseif(PATH_PREFIX STREQUAL "/")
  1033. # don't prefix path with a second slash as "//" is treated as network path
  1034. # by get_filename_component() so it remains in path even inside rpm
  1035. # package where it may cause problems with relocation
  1036. set(PREPARED_RELOCATION_PATH "/${RELOCATION_PATH}")
  1037. else()
  1038. set(PREPARED_RELOCATION_PATH "${PATH_PREFIX}/${RELOCATION_PATH}")
  1039. endif()
  1040. # handle cases where path contains extra slashes (e.g. /a//b/ instead of
  1041. # /a/b)
  1042. get_filename_component(PREPARED_RELOCATION_PATH
  1043. "${PREPARED_RELOCATION_PATH}" ABSOLUTE)
  1044. if(EXISTS "${WDIR}/${PREPARED_RELOCATION_PATH}")
  1045. string(APPEND TMP_RPM_PREFIXES "Prefix: ${PREPARED_RELOCATION_PATH}\n")
  1046. list(APPEND RPM_USED_PACKAGE_PREFIXES "${PREPARED_RELOCATION_PATH}")
  1047. endif()
  1048. endforeach()
  1049. # warn about all the paths that are not relocatable
  1050. cmake_policy(PUSH)
  1051. # Tell file(GLOB_RECURSE) not to follow directory symlinks
  1052. # even if the project does not set this policy to NEW.
  1053. cmake_policy(SET CMP0009 NEW)
  1054. file(GLOB_RECURSE FILE_PATHS_ "${WDIR}/*")
  1055. cmake_policy(POP)
  1056. foreach(TMP_PATH ${FILE_PATHS_})
  1057. string(LENGTH "${WDIR}" WDIR_LEN)
  1058. string(SUBSTRING "${TMP_PATH}" ${WDIR_LEN} -1 TMP_PATH)
  1059. unset(TMP_PATH_FOUND_)
  1060. foreach(RELOCATION_PATH ${RPM_USED_PACKAGE_PREFIXES})
  1061. file(RELATIVE_PATH REL_PATH_ "${RELOCATION_PATH}" "${TMP_PATH}")
  1062. string(SUBSTRING "${REL_PATH_}" 0 2 PREFIX_)
  1063. if(NOT "${PREFIX_}" STREQUAL "..")
  1064. set(TPM_PATH_FOUND_ TRUE)
  1065. break()
  1066. endif()
  1067. endforeach()
  1068. if(NOT TPM_PATH_FOUND_)
  1069. message(AUTHOR_WARNING "CPackRPM:Warning: Path ${TMP_PATH} is not on one of the relocatable paths! Package will be partially relocatable.")
  1070. endif()
  1071. endforeach()
  1072. set(RPM_USED_PACKAGE_PREFIXES "${RPM_USED_PACKAGE_PREFIXES}" PARENT_SCOPE)
  1073. set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}" PARENT_SCOPE)
  1074. endfunction()
  1075. function(cpack_rpm_prepare_content_list)
  1076. # get files list
  1077. cmake_policy(PUSH)
  1078. cmake_policy(SET CMP0009 NEW)
  1079. file(GLOB_RECURSE CPACK_RPM_INSTALL_FILES LIST_DIRECTORIES true RELATIVE "${WDIR}" "${WDIR}/*")
  1080. cmake_policy(POP)
  1081. set(CPACK_RPM_INSTALL_FILES "/${CPACK_RPM_INSTALL_FILES}")
  1082. string(REPLACE ";" ";/" CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}")
  1083. # if we are creating a relocatable package, omit parent directories of
  1084. # CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list"
  1085. # which is passed to the find command that generates the content-list
  1086. if(CPACK_RPM_PACKAGE_RELOCATABLE)
  1087. # get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are
  1088. # destinct parent paths of other relocation paths and remove the
  1089. # final element (so the install-prefix dir itself is not omitted
  1090. # from the RPM's content-list)
  1091. list(SORT RPM_USED_PACKAGE_PREFIXES)
  1092. set(_DISTINCT_PATH "NOT_SET")
  1093. foreach(_RPM_RELOCATION_PREFIX ${RPM_USED_PACKAGE_PREFIXES})
  1094. if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*")
  1095. set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}")
  1096. string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS " ${_RPM_RELOCATION_PREFIX}")
  1097. cmake_policy(PUSH)
  1098. cmake_policy(SET CMP0007 NEW)
  1099. list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1)
  1100. cmake_policy(POP)
  1101. unset(_TMP_LIST)
  1102. # Now generate all of the parent dirs of the relocation path
  1103. foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS})
  1104. list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}")
  1105. string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}")
  1106. separate_arguments(_OMIT_DIR)
  1107. list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR})
  1108. endforeach()
  1109. endif()
  1110. endforeach()
  1111. endif()
  1112. if(CPACK_RPM_PACKAGE_DEBUG)
  1113. message("CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}")
  1114. endif()
  1115. if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
  1116. set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/bin
  1117. /usr/include /usr/lib /usr/libx32 /usr/lib64
  1118. /usr/share /usr/share/aclocal /usr/share/doc )
  1119. if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION)
  1120. if(CPACK_RPM_PACKAGE_DEBUG)
  1121. message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.")
  1122. endif()
  1123. list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}")
  1124. endif()
  1125. endif()
  1126. if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
  1127. if(CPACK_RPM_PACKAGE_DEBUG)
  1128. message("CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}")
  1129. endif()
  1130. list(APPEND _RPM_DIRS_TO_OMIT ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST})
  1131. endif()
  1132. if(CPACK_RPM_PACKAGE_DEBUG)
  1133. message("CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}")
  1134. endif()
  1135. list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES ${_RPM_DIRS_TO_OMIT})
  1136. # add man paths that will be compressed
  1137. # (copied from /usr/lib/rpm/brp-compress - script that does the actual
  1138. # compressing)
  1139. list(APPEND MAN_LOCATIONS "/usr/man/man.*" "/usr/man/.*/man.*" "/usr/info.*"
  1140. "/usr/share/man/man.*" "/usr/share/man/.*/man.*" "/usr/share/info.*"
  1141. "/usr/kerberos/man.*" "/usr/X11R6/man/man.*" "/usr/lib/perl5/man/man.*"
  1142. "/usr/share/doc/.*/man/man.*" "/usr/lib/.*/man/man.*")
  1143. if(CPACK_RPM_ADDITIONAL_MAN_DIRS)
  1144. if(CPACK_RPM_PACKAGE_DEBUG)
  1145. message("CPackRPM:Debug: CPACK_RPM_ADDITIONAL_MAN_DIRS= ${CPACK_RPM_ADDITIONAL_MAN_DIRS}")
  1146. endif()
  1147. list(APPEND MAN_LOCATIONS ${CPACK_RPM_ADDITIONAL_MAN_DIRS})
  1148. endif()
  1149. foreach(PACK_LOCATION IN LISTS CPACK_RPM_INSTALL_FILES)
  1150. foreach(MAN_LOCATION IN LISTS MAN_LOCATIONS)
  1151. # man pages are files inside a certain location
  1152. if(PACK_LOCATION MATCHES "${MAN_LOCATION}/"
  1153. AND NOT IS_DIRECTORY "${WDIR}${PACK_LOCATION}"
  1154. AND NOT IS_SYMLINK "${WDIR}${PACK_LOCATION}")
  1155. list(FIND CPACK_RPM_INSTALL_FILES "${PACK_LOCATION}" INDEX)
  1156. # insert file location that covers compressed man pages
  1157. # even if using a wildcard causes duplicates as those are
  1158. # handled by RPM and we still keep the same file list
  1159. # in spec file - wildcard only represents file type (e.g. .gz)
  1160. list(INSERT CPACK_RPM_INSTALL_FILES ${INDEX} "${PACK_LOCATION}*")
  1161. # remove file location that doesn't cover compressed man pages
  1162. math(EXPR INDEX ${INDEX}+1)
  1163. list(REMOVE_AT CPACK_RPM_INSTALL_FILES ${INDEX})
  1164. break()
  1165. endif()
  1166. endforeach()
  1167. endforeach()
  1168. set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}" PARENT_SCOPE)
  1169. endfunction()
  1170. function(cpack_rpm_symlink_get_relocation_prefixes LOCATION PACKAGE_PREFIXES RETURN_VARIABLE)
  1171. foreach(PKG_PREFIX IN LISTS PACKAGE_PREFIXES)
  1172. string(REGEX MATCH "^${PKG_PREFIX}/.*" FOUND_ "${LOCATION}")
  1173. if(FOUND_)
  1174. list(APPEND TMP_PREFIXES "${PKG_PREFIX}")
  1175. endif()
  1176. endforeach()
  1177. set(${RETURN_VARIABLE} "${TMP_PREFIXES}" PARENT_SCOPE)
  1178. endfunction()
  1179. function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES)
  1180. list(LENGTH PACKAGE_PREFIXES LAST_INDEX)
  1181. set(SORTED_PACKAGE_PREFIXES "${PACKAGE_PREFIXES}")
  1182. list(SORT SORTED_PACKAGE_PREFIXES)
  1183. list(REVERSE SORTED_PACKAGE_PREFIXES)
  1184. math(EXPR LAST_INDEX ${LAST_INDEX}-1)
  1185. foreach(SYMLINK_INDEX RANGE ${LAST_INDEX})
  1186. list(GET SORTED_PACKAGE_PREFIXES ${SYMLINK_INDEX} SRC_PATH)
  1187. list(FIND PACKAGE_PREFIXES "${SRC_PATH}" SYMLINK_INDEX) # reverse magic
  1188. string(LENGTH "${SRC_PATH}" SRC_PATH_LEN)
  1189. set(PARTS_CNT 0)
  1190. set(SCRIPT_PART "if [ \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}\" != \"${SRC_PATH}\" ]; then\n")
  1191. # both paths relocated
  1192. foreach(POINT_INDEX RANGE ${LAST_INDEX})
  1193. list(GET SORTED_PACKAGE_PREFIXES ${POINT_INDEX} POINT_PATH)
  1194. list(FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX) # reverse magic
  1195. string(LENGTH "${POINT_PATH}" POINT_PATH_LEN)
  1196. if(_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX})
  1197. if("${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}")
  1198. set(INDENT "")
  1199. else()
  1200. string(APPEND SCRIPT_PART " if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n")
  1201. set(INDENT " ")
  1202. endif()
  1203. foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX})
  1204. math(EXPR PARTS_CNT ${PARTS_CNT}+1)
  1205. math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
  1206. list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
  1207. string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
  1208. math(EXPR SRC_PATH_END ${SPLIT_INDEX}-${SRC_PATH_LEN})
  1209. string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${SRC_PATH_LEN} ${SRC_PATH_END} SYMLINK_)
  1210. math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN})
  1211. string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
  1212. string(APPEND SCRIPT_PART " ${INDENT}if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
  1213. string(APPEND SCRIPT_PART " ${INDENT}ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n")
  1214. string(APPEND SCRIPT_PART " ${INDENT}CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n")
  1215. string(APPEND SCRIPT_PART " ${INDENT}fi\n")
  1216. endforeach()
  1217. if(NOT "${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}")
  1218. string(APPEND SCRIPT_PART " fi\n")
  1219. endif()
  1220. endif()
  1221. endforeach()
  1222. # source path relocated
  1223. if(_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X)
  1224. foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X)
  1225. math(EXPR PARTS_CNT ${PARTS_CNT}+1)
  1226. math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
  1227. list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
  1228. string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
  1229. math(EXPR SRC_PATH_END ${SPLIT_INDEX}-${SRC_PATH_LEN})
  1230. string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${SRC_PATH_LEN} ${SRC_PATH_END} SYMLINK_)
  1231. math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1)
  1232. string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
  1233. string(APPEND SCRIPT_PART " if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
  1234. string(APPEND SCRIPT_PART " ln -s \"${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n")
  1235. string(APPEND SCRIPT_PART " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n")
  1236. string(APPEND SCRIPT_PART " fi\n")
  1237. endforeach()
  1238. endif()
  1239. if(PARTS_CNT)
  1240. set(SCRIPT "${SCRIPT_PART}")
  1241. string(APPEND SCRIPT "fi\n")
  1242. endif()
  1243. endforeach()
  1244. # point path relocated
  1245. foreach(POINT_INDEX RANGE ${LAST_INDEX})
  1246. list(GET SORTED_PACKAGE_PREFIXES ${POINT_INDEX} POINT_PATH)
  1247. list(FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX) # reverse magic
  1248. string(LENGTH "${POINT_PATH}" POINT_PATH_LEN)
  1249. if(_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX})
  1250. string(APPEND SCRIPT "if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n")
  1251. foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX})
  1252. math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
  1253. list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
  1254. string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
  1255. string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} 0 ${SPLIT_INDEX} SYMLINK_)
  1256. math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN})
  1257. string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
  1258. string(APPEND SCRIPT " if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
  1259. string(APPEND SCRIPT " ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"${SYMLINK_}\"\n")
  1260. string(APPEND SCRIPT " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n")
  1261. string(APPEND SCRIPT " fi\n")
  1262. endforeach()
  1263. string(APPEND SCRIPT "fi\n")
  1264. endif()
  1265. endforeach()
  1266. # no path relocated
  1267. if(_RPM_RELOCATION_SCRIPT_X_X)
  1268. foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_X)
  1269. math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
  1270. list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
  1271. string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
  1272. string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} 0 ${SPLIT_INDEX} SYMLINK_)
  1273. math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1)
  1274. string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
  1275. string(APPEND SCRIPT "if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
  1276. string(APPEND SCRIPT " ln -s \"${POINT_}\" \"${SYMLINK_}\"\n")
  1277. string(APPEND SCRIPT "fi\n")
  1278. endforeach()
  1279. endif()
  1280. set(RPM_SYMLINK_POSTINSTALL "${SCRIPT}" PARENT_SCOPE)
  1281. endfunction()
  1282. function(cpack_rpm_symlink_add_for_relocation_script PACKAGE_PREFIXES SYMLINK SYMLINK_RELOCATION_PATHS POINT POINT_RELOCATION_PATHS)
  1283. list(LENGTH SYMLINK_RELOCATION_PATHS SYMLINK_PATHS_COUTN)
  1284. list(LENGTH POINT_RELOCATION_PATHS POINT_PATHS_COUNT)
  1285. list(APPEND _RPM_RELOCATION_SCRIPT_PAIRS "${SYMLINK}:${POINT}")
  1286. list(LENGTH _RPM_RELOCATION_SCRIPT_PAIRS PAIR_NO)
  1287. if(SYMLINK_PATHS_COUTN)
  1288. foreach(SYMLINK_RELOC_PATH IN LISTS SYMLINK_RELOCATION_PATHS)
  1289. list(FIND PACKAGE_PREFIXES "${SYMLINK_RELOC_PATH}" SYMLINK_INDEX)
  1290. # source path relocated
  1291. list(APPEND _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X "${PAIR_NO}")
  1292. list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X")
  1293. foreach(POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS)
  1294. list(FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX)
  1295. # both paths relocated
  1296. list(APPEND _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX} "${PAIR_NO}")
  1297. list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX}")
  1298. # point path relocated
  1299. list(APPEND _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX} "${PAIR_NO}")
  1300. list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}")
  1301. endforeach()
  1302. endforeach()
  1303. elseif(POINT_PATHS_COUNT)
  1304. foreach(POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS)
  1305. list(FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX)
  1306. # point path relocated
  1307. list(APPEND _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX} "${PAIR_NO}")
  1308. list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}")
  1309. endforeach()
  1310. endif()
  1311. # no path relocated
  1312. list(APPEND _RPM_RELOCATION_SCRIPT_X_X "${PAIR_NO}")
  1313. list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_X")
  1314. # place variables into parent scope
  1315. foreach(VAR IN LISTS RELOCATION_VARS)
  1316. set(${VAR} "${${VAR}}" PARENT_SCOPE)
  1317. endforeach()
  1318. set(_RPM_RELOCATION_SCRIPT_PAIRS "${_RPM_RELOCATION_SCRIPT_PAIRS}" PARENT_SCOPE)
  1319. set(REQUIRES_SYMLINK_RELOCATION_SCRIPT "true" PARENT_SCOPE)
  1320. set(DIRECTIVE "%ghost " PARENT_SCOPE)
  1321. endfunction()
  1322. function(cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXES IS_RELOCATABLE)
  1323. # Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir
  1324. # This is necessary to avoid duplicate files since rpmbuild does
  1325. # recursion on its own when encountering a pathname which is a directory
  1326. # which is not flagged as %dir
  1327. string(STRIP "${INSTALL_FILES_LIST}" INSTALL_FILES_LIST)
  1328. string(REPLACE "\n" ";" INSTALL_FILES_LIST
  1329. "${INSTALL_FILES_LIST}")
  1330. string(REPLACE "\"" "" INSTALL_FILES_LIST
  1331. "${INSTALL_FILES_LIST}")
  1332. string(LENGTH "${WDIR}" WDR_LEN_)
  1333. list(SORT INSTALL_FILES_LIST) # make file order consistent on all platforms
  1334. foreach(F IN LISTS INSTALL_FILES_LIST)
  1335. unset(DIRECTIVE)
  1336. if(IS_SYMLINK "${WDIR}/${F}")
  1337. if(IS_RELOCATABLE)
  1338. # check that symlink has relocatable format
  1339. get_filename_component(SYMLINK_LOCATION_ "${WDIR}/${F}" DIRECTORY)
  1340. execute_process(COMMAND ls -la "${WDIR}/${F}"
  1341. WORKING_DIRECTORY "${WDIR}"
  1342. OUTPUT_VARIABLE SYMLINK_POINT_
  1343. OUTPUT_STRIP_TRAILING_WHITESPACE)
  1344. string(FIND "${SYMLINK_POINT_}" "->" SYMLINK_POINT_INDEX_ REVERSE)
  1345. math(EXPR SYMLINK_POINT_INDEX_ ${SYMLINK_POINT_INDEX_}+3)
  1346. string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_)
  1347. # get destination path
  1348. string(SUBSTRING "${SYMLINK_POINT_}" ${SYMLINK_POINT_INDEX_} ${SYMLINK_POINT_LENGTH_} SYMLINK_POINT_)
  1349. # check if path is relative or absolute
  1350. string(SUBSTRING "${SYMLINK_POINT_}" 0 1 SYMLINK_IS_ABSOLUTE_)
  1351. if(${SYMLINK_IS_ABSOLUTE_} STREQUAL "/")
  1352. # prevent absolute paths from having /../ or /./ section inside of them
  1353. get_filename_component(SYMLINK_POINT_ "${SYMLINK_POINT_}" ABSOLUTE)
  1354. else()
  1355. # handle relative path
  1356. get_filename_component(SYMLINK_POINT_ "${SYMLINK_LOCATION_}/${SYMLINK_POINT_}" ABSOLUTE)
  1357. endif()
  1358. # recalculate path length after conversion to canonical form
  1359. string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_)
  1360. if(SYMLINK_POINT_ MATCHES "${WDIR}/.*")
  1361. # only symlinks that are pointing inside the packaging structure should be checked for relocation
  1362. string(SUBSTRING "${SYMLINK_POINT_}" ${WDR_LEN_} -1 SYMLINK_POINT_WD_)
  1363. cpack_rpm_symlink_get_relocation_prefixes("${F}" "${PACKAGE_PREFIXES}" "SYMLINK_RELOCATIONS")
  1364. cpack_rpm_symlink_get_relocation_prefixes("${SYMLINK_POINT_WD_}" "${PACKAGE_PREFIXES}" "POINT_RELOCATIONS")
  1365. list(LENGTH SYMLINK_RELOCATIONS SYMLINK_RELOCATIONS_COUNT)
  1366. list(LENGTH POINT_RELOCATIONS POINT_RELOCATIONS_COUNT)
  1367. else()
  1368. # location pointed to is ouside WDR so it should be treated as a permanent symlink
  1369. set(SYMLINK_POINT_WD_ "${SYMLINK_POINT_}")
  1370. unset(SYMLINK_RELOCATIONS)
  1371. unset(POINT_RELOCATIONS)
  1372. unset(SYMLINK_RELOCATIONS_COUNT)
  1373. unset(POINT_RELOCATIONS_COUNT)
  1374. message(AUTHOR_WARNING "CPackRPM:Warning: Symbolic link '${F}' points to location that is outside packaging path! Link will possibly not be relocatable.")
  1375. endif()
  1376. if(SYMLINK_RELOCATIONS_COUNT AND POINT_RELOCATIONS_COUNT)
  1377. # find matching
  1378. foreach(SYMLINK_RELOCATION_PREFIX IN LISTS SYMLINK_RELOCATIONS)
  1379. list(FIND POINT_RELOCATIONS "${SYMLINK_RELOCATION_PREFIX}" FOUND_INDEX)
  1380. if(NOT ${FOUND_INDEX} EQUAL -1)
  1381. break()
  1382. endif()
  1383. endforeach()
  1384. if(NOT ${FOUND_INDEX} EQUAL -1)
  1385. # symlinks have the same subpath
  1386. if(${SYMLINK_RELOCATIONS_COUNT} EQUAL 1 AND ${POINT_RELOCATIONS_COUNT} EQUAL 1)
  1387. # permanent symlink
  1388. get_filename_component(SYMLINK_LOCATION_ "${F}" DIRECTORY)
  1389. file(RELATIVE_PATH FINAL_PATH_ ${SYMLINK_LOCATION_} ${SYMLINK_POINT_WD_})
  1390. execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${FINAL_PATH_}" "${WDIR}/${F}")
  1391. else()
  1392. # relocation subpaths
  1393. cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
  1394. "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}")
  1395. endif()
  1396. else()
  1397. # not on the same relocation path
  1398. cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
  1399. "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}")
  1400. endif()
  1401. elseif(POINT_RELOCATIONS_COUNT)
  1402. # point is relocatable
  1403. cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
  1404. "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}")
  1405. else()
  1406. # is not relocatable or points to non relocatable path - permanent symlink
  1407. execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${SYMLINK_POINT_WD_}" "${WDIR}/${F}")
  1408. endif()
  1409. endif()
  1410. elseif(IS_DIRECTORY "${WDIR}/${F}")
  1411. set(DIRECTIVE "%dir ")
  1412. endif()
  1413. string(APPEND INSTALL_FILES "${DIRECTIVE}\"${F}\"\n")
  1414. endforeach()
  1415. if(REQUIRES_SYMLINK_RELOCATION_SCRIPT)
  1416. cpack_rpm_symlink_create_relocation_script("${PACKAGE_PREFIXES}")
  1417. endif()
  1418. set(RPM_SYMLINK_POSTINSTALL "${RPM_SYMLINK_POSTINSTALL}" PARENT_SCOPE)
  1419. set(CPACK_RPM_INSTALL_FILES "${INSTALL_FILES}" PARENT_SCOPE)
  1420. endfunction()
  1421. if(CMAKE_BINARY_DIR)
  1422. message(FATAL_ERROR "CPackRPM.cmake may only be used by CPack internally.")
  1423. endif()
  1424. if(NOT UNIX)
  1425. message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.")
  1426. endif()
  1427. # We need to check if the binaries were compiled with debug symbols
  1428. # because without them the package will be useless
  1429. function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR)
  1430. if(NOT CPACK_BUILD_SOURCE_DIRS)
  1431. message(FATAL_ERROR "CPackRPM: CPACK_BUILD_SOURCE_DIRS variable is not set!"
  1432. " Required for debuginfo packaging. See documentation of"
  1433. " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
  1434. endif()
  1435. # With objdump we should check the debug symbols
  1436. find_program(OBJDUMP_EXECUTABLE objdump)
  1437. if(NOT OBJDUMP_EXECUTABLE)
  1438. message(FATAL_ERROR "CPackRPM: objdump binary could not be found!"
  1439. " Required for debuginfo packaging. See documentation of"
  1440. " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
  1441. endif()
  1442. # With debugedit we prepare source files list
  1443. find_program(DEBUGEDIT_EXECUTABLE debugedit "/usr/lib/rpm/")
  1444. if(NOT DEBUGEDIT_EXECUTABLE)
  1445. message(FATAL_ERROR "CPackRPM: debugedit binary could not be found!"
  1446. " Required for debuginfo packaging. See documentation of"
  1447. " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
  1448. endif()
  1449. unset(mkdir_list_)
  1450. unset(cp_list_)
  1451. unset(additional_sources_)
  1452. foreach(F IN LISTS INSTALL_FILES)
  1453. if(IS_DIRECTORY "${WORKING_DIR}/${F}" OR IS_SYMLINK "${WORKING_DIR}/${F}")
  1454. continue()
  1455. endif()
  1456. execute_process(COMMAND "${OBJDUMP_EXECUTABLE}" -h ${WORKING_DIR}/${F}
  1457. WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}"
  1458. RESULT_VARIABLE OBJDUMP_EXEC_RESULT
  1459. OUTPUT_VARIABLE OBJDUMP_OUT
  1460. ERROR_QUIET)
  1461. # Check if the given file is an executable or not
  1462. if(NOT OBJDUMP_EXEC_RESULT)
  1463. string(FIND "${OBJDUMP_OUT}" "debug" FIND_RESULT)
  1464. if(FIND_RESULT GREATER -1)
  1465. set(index_ 0)
  1466. foreach(source_dir_ IN LISTS CPACK_BUILD_SOURCE_DIRS)
  1467. string(LENGTH "${source_dir_}" source_dir_len_)
  1468. string(LENGTH "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}" debuginfo_dir_len)
  1469. if(source_dir_len_ LESS debuginfo_dir_len)
  1470. message(FATAL_ERROR "CPackRPM: source dir path '${source_dir_}' is"
  1471. " shorter than debuginfo sources dir path '${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}'!"
  1472. " Source dir path must be longer than debuginfo sources dir path."
  1473. " Set CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX variable to a shorter value"
  1474. " or make source dir path longer."
  1475. " Required for debuginfo packaging. See documentation of"
  1476. " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
  1477. endif()
  1478. file(REMOVE "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list")
  1479. execute_process(COMMAND "${DEBUGEDIT_EXECUTABLE}" -b "${source_dir_}" -d "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}" -i -l "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list" "${WORKING_DIR}/${F}"
  1480. RESULT_VARIABLE res_
  1481. OUTPUT_VARIABLE opt_
  1482. ERROR_VARIABLE err_
  1483. )
  1484. file(STRINGS
  1485. "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list"
  1486. sources_)
  1487. list(REMOVE_DUPLICATES sources_)
  1488. foreach(source_ IN LISTS sources_)
  1489. if(EXISTS "${source_dir_}/${source_}" AND NOT IS_DIRECTORY "${source_dir_}/${source_}")
  1490. get_filename_component(path_part_ "${source_}" DIRECTORY)
  1491. list(APPEND mkdir_list_ "%{buildroot}${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${path_part_}")
  1492. list(APPEND cp_list_ "cp \"${source_dir_}/${source_}\" \"%{buildroot}${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${path_part_}\"")
  1493. list(APPEND additional_sources_ "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${source_}")
  1494. endif()
  1495. endforeach()
  1496. math(EXPR index_ "${index_} + 1")
  1497. endforeach()
  1498. else()
  1499. message(WARNING "CPackRPM: File: ${F} does not contain debug symbols. They will possibly be missing from debuginfo package!")
  1500. endif()
  1501. get_file_permissions("${WORKING_DIR}/${F}" permissions_)
  1502. cmake_policy(SET CMP0057 NEW)
  1503. if(NOT "USER_EXECUTE" IN_LIST permissions_ AND
  1504. NOT "GROUP_EXECUTE" IN_LIST permissions_ AND
  1505. NOT "WORLD_EXECUTE" IN_LIST permissions_)
  1506. if(CPACK_RPM_INSTALL_WITH_EXEC)
  1507. execute_process(COMMAND chmod a+x ${WORKING_DIR}/${F}
  1508. RESULT_VARIABLE res_
  1509. ERROR_VARIABLE err_
  1510. OUTPUT_QUIET)
  1511. if(res_)
  1512. message(FATAL_ERROR "CPackRPM: could not apply execute permissions "
  1513. "requested by CPACK_RPM_INSTALL_WITH_EXEC variable on "
  1514. "'${WORKING_DIR}/${F}'! Reason: '${err_}'")
  1515. endif()
  1516. else()
  1517. message(AUTHOR_WARNING "CPackRPM: File: ${WORKING_DIR}/${F} does not "
  1518. "have execute permissions. Debuginfo symbols will not be extracted"
  1519. "! Missing debuginfo may cause packaging failure. Consider setting "
  1520. "execute permissions or setting 'CPACK_RPM_INSTALL_WITH_EXEC' "
  1521. "variable.")
  1522. endif()
  1523. endif()
  1524. endif()
  1525. endforeach()
  1526. list(LENGTH mkdir_list_ len_)
  1527. if(len_)
  1528. list(REMOVE_DUPLICATES mkdir_list_)
  1529. unset(TMP_RPM_DEBUGINFO_INSTALL)
  1530. foreach(part_ IN LISTS mkdir_list_)
  1531. string(APPEND TMP_RPM_DEBUGINFO_INSTALL "mkdir -p \"${part_}\"\n")
  1532. endforeach()
  1533. endif()
  1534. list(LENGTH cp_list_ len_)
  1535. if(len_)
  1536. list(REMOVE_DUPLICATES cp_list_)
  1537. foreach(part_ IN LISTS cp_list_)
  1538. string(APPEND TMP_RPM_DEBUGINFO_INSTALL "${part_}\n")
  1539. endforeach()
  1540. endif()
  1541. if(NOT DEFINED CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS)
  1542. set(CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS /usr /usr/src /usr/src/debug)
  1543. if(CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION)
  1544. if(CPACK_RPM_PACKAGE_DEBUG)
  1545. message("CPackRPM:Debug: Adding ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION} to builtin omit list.")
  1546. endif()
  1547. list(APPEND CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS "${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION}")
  1548. endif()
  1549. endif()
  1550. if(CPACK_RPM_PACKAGE_DEBUG)
  1551. message("CPackRPM:Debug: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS= ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS}")
  1552. endif()
  1553. list(LENGTH additional_sources_ len_)
  1554. if(len_)
  1555. list(REMOVE_DUPLICATES additional_sources_)
  1556. unset(additional_sources_all_)
  1557. foreach(source_ IN LISTS additional_sources_)
  1558. string(REPLACE "/" ";" split_source_ " ${source_}")
  1559. list(REMOVE_AT split_source_ 0)
  1560. unset(tmp_path_)
  1561. # Now generate all segments of the path
  1562. foreach(segment_ IN LISTS split_source_)
  1563. string(APPEND tmp_path_ "/${segment_}")
  1564. list(APPEND additional_sources_all_ "${tmp_path_}")
  1565. endforeach()
  1566. endforeach()
  1567. list(REMOVE_DUPLICATES additional_sources_all_)
  1568. list(REMOVE_ITEM additional_sources_all_
  1569. ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS})
  1570. unset(TMP_DEBUGINFO_ADDITIONAL_SOURCES)
  1571. foreach(source_ IN LISTS additional_sources_all_)
  1572. string(APPEND TMP_DEBUGINFO_ADDITIONAL_SOURCES "${source_}\n")
  1573. endforeach()
  1574. endif()
  1575. set(TMP_RPM_DEBUGINFO_INSTALL "${TMP_RPM_DEBUGINFO_INSTALL}" PARENT_SCOPE)
  1576. set(TMP_DEBUGINFO_ADDITIONAL_SOURCES "${TMP_DEBUGINFO_ADDITIONAL_SOURCES}"
  1577. PARENT_SCOPE)
  1578. endfunction()
  1579. function(cpack_rpm_variable_fallback OUTPUT_VAR_NAME)
  1580. set(FALLBACK_VAR_NAMES ${ARGN})
  1581. foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
  1582. if(${variable_name})
  1583. set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
  1584. break()
  1585. endif()
  1586. endforeach()
  1587. endfunction()
  1588. function(cpack_rpm_generate_package)
  1589. # rpmbuild is the basic command for building RPM package
  1590. # it may be a simple (symbolic) link to rpm command.
  1591. find_program(RPMBUILD_EXECUTABLE rpmbuild)
  1592. # Check version of the rpmbuild tool this would be easier to
  1593. # track bugs with users and CPackRPM debug mode.
  1594. # We may use RPM version in order to check for available version dependent features
  1595. if(RPMBUILD_EXECUTABLE)
  1596. execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --version
  1597. OUTPUT_VARIABLE _TMP_VERSION
  1598. ERROR_QUIET
  1599. OUTPUT_STRIP_TRAILING_WHITESPACE)
  1600. string(REGEX REPLACE "^.* " ""
  1601. RPMBUILD_EXECUTABLE_VERSION
  1602. ${_TMP_VERSION})
  1603. if(CPACK_RPM_PACKAGE_DEBUG)
  1604. message("CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>")
  1605. endif()
  1606. endif()
  1607. if(NOT RPMBUILD_EXECUTABLE)
  1608. message(FATAL_ERROR "RPM package requires rpmbuild executable")
  1609. endif()
  1610. # Display lsb_release output if DEBUG mode enable
  1611. # This will help to diagnose problem with CPackRPM
  1612. # because we will know on which kind of Linux we are
  1613. if(CPACK_RPM_PACKAGE_DEBUG)
  1614. find_program(LSB_RELEASE_EXECUTABLE lsb_release)
  1615. if(LSB_RELEASE_EXECUTABLE)
  1616. execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -a
  1617. OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
  1618. ERROR_QUIET
  1619. OUTPUT_STRIP_TRAILING_WHITESPACE)
  1620. string(REGEX REPLACE "\n" ", "
  1621. LSB_RELEASE_OUTPUT
  1622. ${_TMP_LSB_RELEASE_OUTPUT})
  1623. else ()
  1624. set(LSB_RELEASE_OUTPUT "lsb_release not installed/found!")
  1625. endif()
  1626. message("CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}")
  1627. endif()
  1628. # We may use RPM version in the future in order
  1629. # to shut down warning about space in buildtree
  1630. # some recent RPM version should support space in different places.
  1631. # not checked [yet].
  1632. if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*")
  1633. message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.")
  1634. endif()
  1635. # If rpmbuild is found
  1636. # we try to discover alien since we may be on non RPM distro like Debian.
  1637. # In this case we may try to to use more advanced features
  1638. # like generating RPM directly from DEB using alien.
  1639. # FIXME feature not finished (yet)
  1640. find_program(ALIEN_EXECUTABLE alien)
  1641. if(ALIEN_EXECUTABLE)
  1642. message(STATUS "alien found, we may be on a Debian based distro.")
  1643. endif()
  1644. # Are we packaging components ?
  1645. if(CPACK_RPM_PACKAGE_COMPONENT)
  1646. string(TOUPPER ${CPACK_RPM_PACKAGE_COMPONENT} CPACK_RPM_PACKAGE_COMPONENT_UPPER)
  1647. endif()
  1648. set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}")
  1649. #
  1650. # Use user-defined RPM specific variables value
  1651. # or generate reasonable default value from
  1652. # CPACK_xxx generic values.
  1653. # The variables comes from the needed (mandatory or not)
  1654. # values found in the RPM specification file aka ".spec" file.
  1655. # The variables which may/should be defined are:
  1656. #
  1657. # CPACK_RPM_PACKAGE_SUMMARY (mandatory)
  1658. if(CPACK_RPM_PACKAGE_COMPONENT)
  1659. cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_SUMMARY"
  1660. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY"
  1661. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_SUMMARY")
  1662. endif()
  1663. if(NOT CPACK_RPM_PACKAGE_SUMMARY)
  1664. if(CPACK_PACKAGE_DESCRIPTION_SUMMARY)
  1665. set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  1666. else()
  1667. # if neither var is defined lets use the name as summary
  1668. string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY)
  1669. endif()
  1670. endif()
  1671. # CPACK_RPM_PACKAGE_NAME (mandatory)
  1672. if(NOT CPACK_RPM_PACKAGE_NAME)
  1673. string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME)
  1674. endif()
  1675. if(CPACK_RPM_PACKAGE_COMPONENT)
  1676. string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}"
  1677. CPACK_RPM_MAIN_COMPONENT_UPPER)
  1678. if(NOT CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
  1679. string(APPEND CPACK_RPM_PACKAGE_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}")
  1680. cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME"
  1681. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME"
  1682. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME")
  1683. endif()
  1684. endif()
  1685. # CPACK_RPM_PACKAGE_VERSION (mandatory)
  1686. if(NOT CPACK_RPM_PACKAGE_VERSION)
  1687. if(NOT CPACK_PACKAGE_VERSION)
  1688. message(FATAL_ERROR "RPM package requires a package version")
  1689. endif()
  1690. set(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
  1691. endif()
  1692. # Replace '-' in version with '_'
  1693. # '-' character is an Illegal RPM version character
  1694. # it is illegal because it is used to separate
  1695. # RPM "Version" from RPM "Release"
  1696. string(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION})
  1697. # CPACK_RPM_PACKAGE_ARCHITECTURE (mandatory)
  1698. if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
  1699. execute_process(COMMAND uname "-m"
  1700. OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
  1701. OUTPUT_STRIP_TRAILING_WHITESPACE)
  1702. else()
  1703. if(CPACK_RPM_PACKAGE_DEBUG)
  1704. message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
  1705. endif()
  1706. endif()
  1707. if(CPACK_RPM_PACKAGE_COMPONENT)
  1708. cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_ARCHITECTURE"
  1709. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE"
  1710. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_ARCHITECTURE")
  1711. if(CPACK_RPM_PACKAGE_DEBUG)
  1712. message("CPackRPM:Debug: using component build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
  1713. endif()
  1714. endif()
  1715. if(${CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch")
  1716. set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
  1717. else()
  1718. set(TMP_RPM_BUILDARCH "")
  1719. endif()
  1720. # CPACK_RPM_PACKAGE_RELEASE
  1721. # The RPM release is the numbering of the RPM package ITSELF
  1722. # this is the version of the PACKAGING and NOT the version
  1723. # of the CONTENT of the package.
  1724. # You may well need to generate a new RPM package release
  1725. # without changing the version of the packaged software.
  1726. # This is the case when the packaging is buggy (not) the software :=)
  1727. # If not set, 1 is a good candidate
  1728. if(NOT CPACK_RPM_PACKAGE_RELEASE)
  1729. set(CPACK_RPM_PACKAGE_RELEASE "1")
  1730. endif()
  1731. if(CPACK_RPM_PACKAGE_RELEASE_DIST)
  1732. string(APPEND CPACK_RPM_PACKAGE_RELEASE "%{?dist}")
  1733. endif()
  1734. # CPACK_RPM_PACKAGE_LICENSE
  1735. if(NOT CPACK_RPM_PACKAGE_LICENSE)
  1736. set(CPACK_RPM_PACKAGE_LICENSE "unknown")
  1737. endif()
  1738. # CPACK_RPM_PACKAGE_GROUP
  1739. if(CPACK_RPM_PACKAGE_COMPONENT)
  1740. cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_GROUP"
  1741. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP"
  1742. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_GROUP")
  1743. endif()
  1744. if(NOT CPACK_RPM_PACKAGE_GROUP)
  1745. set(CPACK_RPM_PACKAGE_GROUP "unknown")
  1746. endif()
  1747. # CPACK_RPM_PACKAGE_VENDOR
  1748. if(NOT CPACK_RPM_PACKAGE_VENDOR)
  1749. if(CPACK_PACKAGE_VENDOR)
  1750. set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}")
  1751. else()
  1752. set(CPACK_RPM_PACKAGE_VENDOR "unknown")
  1753. endif()
  1754. endif()
  1755. # CPACK_RPM_PACKAGE_SOURCE
  1756. # The name of the source tarball in case we generate a source RPM
  1757. # CPACK_RPM_PACKAGE_DESCRIPTION
  1758. # The variable content may be either
  1759. # - explicitly given by the user or
  1760. # - filled with the content of CPACK_PACKAGE_DESCRIPTION_FILE
  1761. # if it is defined
  1762. # - set to a default value
  1763. #
  1764. if(CPACK_RPM_PACKAGE_COMPONENT)
  1765. cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_DESCRIPTION"
  1766. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION"
  1767. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_DESCRIPTION"
  1768. "CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION")
  1769. endif()
  1770. if(NOT CPACK_RPM_PACKAGE_DESCRIPTION)
  1771. if(CPACK_PACKAGE_DESCRIPTION_FILE)
  1772. file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION)
  1773. else ()
  1774. set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available")
  1775. endif ()
  1776. endif ()
  1777. # CPACK_RPM_COMPRESSION_TYPE
  1778. #
  1779. if (CPACK_RPM_COMPRESSION_TYPE)
  1780. if(CPACK_RPM_PACKAGE_DEBUG)
  1781. message("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}")
  1782. endif()
  1783. if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma")
  1784. set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio")
  1785. endif()
  1786. if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz")
  1787. set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7.xzdio")
  1788. endif()
  1789. if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2")
  1790. set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio")
  1791. endif()
  1792. if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip")
  1793. set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio")
  1794. endif()
  1795. else()
  1796. set(CPACK_RPM_COMPRESSION_TYPE_TMP "")
  1797. endif()
  1798. if(NOT CPACK_RPM_PACKAGE_SOURCES)
  1799. if(CPACK_PACKAGE_RELOCATABLE OR CPACK_RPM_PACKAGE_RELOCATABLE)
  1800. if(CPACK_RPM_PACKAGE_DEBUG)
  1801. message("CPackRPM:Debug: Trying to build a relocatable package")
  1802. endif()
  1803. if(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON"))
  1804. message("CPackRPM:Warning: CPACK_SET_DESTDIR is set (=${CPACK_SET_DESTDIR}) while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.")
  1805. set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE)
  1806. else()
  1807. set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) # kept for back compatibility (provided external RPM spec files)
  1808. cpack_rpm_prepare_relocation_paths()
  1809. set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE)
  1810. endif()
  1811. endif()
  1812. else()
  1813. if(CPACK_RPM_PACKAGE_COMPONENT)
  1814. message(FATAL_ERROR "CPACK_RPM_PACKAGE_SOURCES parameter can not be used"
  1815. " in combination with CPACK_RPM_PACKAGE_COMPONENT parameter!")
  1816. endif()
  1817. set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) # disable relocatable option if building source RPM
  1818. endif()
  1819. execute_process(
  1820. COMMAND "${RPMBUILD_EXECUTABLE}" --querytags
  1821. OUTPUT_VARIABLE RPMBUILD_TAG_LIST
  1822. OUTPUT_STRIP_TRAILING_WHITESPACE)
  1823. string(REPLACE "\n" ";" RPMBUILD_TAG_LIST "${RPMBUILD_TAG_LIST}")
  1824. if(CPACK_RPM_PACKAGE_EPOCH)
  1825. set(TMP_RPM_EPOCH "Epoch: ${CPACK_RPM_PACKAGE_EPOCH}")
  1826. endif()
  1827. # Check if additional fields for RPM spec header are given
  1828. # There may be some COMPONENT specific variables as well
  1829. # If component specific var is not provided we use the global one
  1830. # for each component
  1831. foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
  1832. if(CPACK_RPM_PACKAGE_DEBUG)
  1833. message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}")
  1834. endif()
  1835. if(CPACK_RPM_PACKAGE_COMPONENT)
  1836. cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}"
  1837. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}"
  1838. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_${_RPM_SPEC_HEADER}")
  1839. endif()
  1840. if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER})
  1841. cmake_policy(PUSH)
  1842. cmake_policy(SET CMP0057 NEW)
  1843. # Prefix can be replaced by Prefixes but the old version stil works so we'll ignore it for now
  1844. # Requires* is a special case because it gets transformed to Requires(pre/post/preun/postun)
  1845. # Auto* is a special case because the tags can not be queried by querytags rpmbuild flag
  1846. set(special_case_tags_ PREFIX REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN AUTOPROV AUTOREQ AUTOREQPROV)
  1847. if(NOT _RPM_SPEC_HEADER IN_LIST RPMBUILD_TAG_LIST AND NOT _RPM_SPEC_HEADER IN_LIST special_case_tags_)
  1848. cmake_policy(POP)
  1849. message(AUTHOR_WARNING "CPackRPM:Warning: ${_RPM_SPEC_HEADER} not "
  1850. "supported in provided rpmbuild. Tag will not be used.")
  1851. continue()
  1852. endif()
  1853. cmake_policy(POP)
  1854. if(CPACK_RPM_PACKAGE_DEBUG)
  1855. message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}")
  1856. endif()
  1857. set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}})
  1858. endif()
  1859. # Treat the RPM Spec keyword iff it has been properly defined
  1860. if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)
  1861. # Transform NAME --> Name e.g. PROVIDES --> Provides
  1862. # The Upper-case first letter and lowercase tail is the
  1863. # appropriate value required in the final RPM spec file.
  1864. string(SUBSTRING ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL)
  1865. string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL)
  1866. string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME)
  1867. string(APPEND _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_TAIL}")
  1868. # The following keywords require parentheses around the "pre" or "post" suffix in the final RPM spec file.
  1869. set(SCRIPTS_REQUIREMENTS_LIST REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
  1870. list(FIND SCRIPTS_REQUIREMENTS_LIST ${_RPM_SPEC_HEADER} IS_SCRIPTS_REQUIREMENT_FOUND)
  1871. if(NOT ${IS_SCRIPTS_REQUIREMENT_FOUND} EQUAL -1)
  1872. string(REPLACE "_" "(" _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}")
  1873. string(APPEND _PACKAGE_HEADER_NAME ")")
  1874. endif()
  1875. if(CPACK_RPM_PACKAGE_DEBUG)
  1876. message("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}")
  1877. endif()
  1878. set(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}")
  1879. unset(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)
  1880. endif()
  1881. endforeach()
  1882. # CPACK_RPM_SPEC_INSTALL_POST
  1883. # May be used to define a RPM post intallation script
  1884. # for example setting it to "/bin/true" may prevent
  1885. # rpmbuild from stripping binaries.
  1886. if(CPACK_RPM_SPEC_INSTALL_POST)
  1887. if(CPACK_RPM_PACKAGE_DEBUG)
  1888. message("CPackRPM:Debug: User defined CPACK_RPM_SPEC_INSTALL_POST = ${CPACK_RPM_SPEC_INSTALL_POST}")
  1889. endif()
  1890. set(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}")
  1891. endif()
  1892. # CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE)
  1893. # CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE)
  1894. # May be used to embed a post (un)installation script in the spec file.
  1895. # The referred script file(s) will be read and directly
  1896. # put after the %post or %postun section
  1897. # ----------------------------------------------------------------
  1898. # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE)
  1899. # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE)
  1900. # May be used to embed a pre (un)installation script in the spec file.
  1901. # The referred script file(s) will be read and directly
  1902. # put after the %pre or %preun section
  1903. foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL")
  1904. foreach(RPM_SCRIPT_FILE_TIME_ "PRE" "POST")
  1905. set("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
  1906. "${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE}")
  1907. if(CPACK_RPM_PACKAGE_COMPONENT)
  1908. cpack_rpm_variable_fallback("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
  1909. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE"
  1910. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE")
  1911. endif()
  1912. # Handle file if it has been specified
  1913. if(CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE)
  1914. if(EXISTS ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE})
  1915. file(READ ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}
  1916. "CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}")
  1917. else()
  1918. message("CPackRPM:Warning: CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE <${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}> does not exists - ignoring")
  1919. endif()
  1920. else()
  1921. # reset SPEC var value if no file has been specified
  1922. # (either globally or component-wise)
  1923. set("CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}" "")
  1924. endif()
  1925. endforeach()
  1926. endforeach()
  1927. # CPACK_RPM_CHANGELOG_FILE
  1928. # May be used to embed a changelog in the spec file.
  1929. # The referred file will be read and directly put after the %changelog section
  1930. if(CPACK_RPM_CHANGELOG_FILE)
  1931. if(EXISTS ${CPACK_RPM_CHANGELOG_FILE})
  1932. file(READ ${CPACK_RPM_CHANGELOG_FILE} CPACK_RPM_SPEC_CHANGELOG)
  1933. else()
  1934. message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring")
  1935. endif()
  1936. else()
  1937. set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Eric Noulard <[email protected]> - ${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n Generated by CPack RPM (no Changelog file were provided)")
  1938. endif()
  1939. # CPACK_RPM_SPEC_MORE_DEFINE
  1940. # This is a generated spec rpm file spaceholder
  1941. if(CPACK_RPM_SPEC_MORE_DEFINE)
  1942. if(CPACK_RPM_PACKAGE_DEBUG)
  1943. message("CPackRPM:Debug: User defined more define spec line specified:\n ${CPACK_RPM_SPEC_MORE_DEFINE}")
  1944. endif()
  1945. endif()
  1946. # Now we may create the RPM build tree structure
  1947. set(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}")
  1948. message(STATUS "CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}")
  1949. # Prepare RPM build tree
  1950. file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR})
  1951. file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/tmp)
  1952. file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/BUILD)
  1953. file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/RPMS)
  1954. file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SOURCES)
  1955. file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS)
  1956. file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS)
  1957. # it seems rpmbuild can't handle spaces in the path
  1958. # neither escaping (as below) nor putting quotes around the path seem to help
  1959. #string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
  1960. set(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
  1961. cpack_rpm_prepare_content_list()
  1962. # In component case, put CPACK_ABSOLUTE_DESTINATION_FILES_<COMPONENT>
  1963. # into CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
  1964. # otherwise, put CPACK_ABSOLUTE_DESTINATION_FILES
  1965. # This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling
  1966. if(CPACK_RPM_PACKAGE_COMPONENT)
  1967. if(CPACK_ABSOLUTE_DESTINATION_FILES)
  1968. cpack_rpm_variable_fallback("COMPONENT_FILES_TAG"
  1969. "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}"
  1970. "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}")
  1971. set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}")
  1972. if(CPACK_RPM_PACKAGE_DEBUG)
  1973. message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>")
  1974. message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
  1975. endif()
  1976. endif()
  1977. else()
  1978. if(CPACK_ABSOLUTE_DESTINATION_FILES)
  1979. set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${CPACK_ABSOLUTE_DESTINATION_FILES}")
  1980. endif()
  1981. endif()
  1982. # In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST.
  1983. set(CPACK_RPM_USER_FILELIST_INTERNAL "")
  1984. if(CPACK_RPM_PACKAGE_COMPONENT)
  1985. cpack_rpm_variable_fallback("CPACK_RPM_USER_FILELIST_INTERNAL"
  1986. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST"
  1987. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_FILELIST")
  1988. if(CPACK_RPM_PACKAGE_DEBUG AND CPACK_RPM_USER_FILELIST_INTERNAL)
  1989. message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>")
  1990. message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
  1991. endif()
  1992. elseif(CPACK_RPM_USER_FILELIST)
  1993. set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}")
  1994. endif()
  1995. # Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL
  1996. # Remove those files from CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
  1997. # or CPACK_RPM_INSTALL_FILES,
  1998. # hence it must be done before these auto-generated lists are processed.
  1999. if(CPACK_RPM_USER_FILELIST_INTERNAL)
  2000. if(CPACK_RPM_PACKAGE_DEBUG)
  2001. message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>")
  2002. endif()
  2003. # Create CMake list from CPACK_RPM_INSTALL_FILES
  2004. string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST)
  2005. string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST
  2006. "${CPACK_RPM_INSTALL_FILES_LIST}")
  2007. string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST
  2008. "${CPACK_RPM_INSTALL_FILES_LIST}")
  2009. set(CPACK_RPM_USER_INSTALL_FILES "")
  2010. foreach(F IN LISTS CPACK_RPM_USER_FILELIST_INTERNAL)
  2011. string(REGEX REPLACE "%[A-Za-z]+(\\([^()]*\\))? " "" F_PATH ${F})
  2012. string(REGEX MATCH "(%[A-Za-z]+(\\([^()]*\\))? )*" F_PREFIX ${F})
  2013. string(STRIP ${F_PREFIX} F_PREFIX)
  2014. if(CPACK_RPM_PACKAGE_DEBUG)
  2015. message("CPackRPM:Debug: F_PREFIX=<${F_PREFIX}>, F_PATH=<${F_PATH}>")
  2016. endif()
  2017. if(F_PREFIX)
  2018. string(APPEND F_PREFIX " ")
  2019. endif()
  2020. # Rebuild the user list file
  2021. string(APPEND CPACK_RPM_USER_INSTALL_FILES "${F_PREFIX}\"${F_PATH}\"\n")
  2022. # Remove from CPACK_RPM_INSTALL_FILES and CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
  2023. list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${F_PATH})
  2024. # ABSOLUTE destination files list may not exists at all
  2025. if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
  2026. list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH})
  2027. endif()
  2028. endforeach()
  2029. # Rebuild CPACK_RPM_INSTALL_FILES
  2030. set(CPACK_RPM_INSTALL_FILES "")
  2031. foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST)
  2032. string(APPEND CPACK_RPM_INSTALL_FILES "\"${F}\"\n")
  2033. endforeach()
  2034. else()
  2035. set(CPACK_RPM_USER_INSTALL_FILES "")
  2036. endif()
  2037. if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
  2038. if(CPACK_RPM_PACKAGE_DEBUG)
  2039. message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}")
  2040. endif()
  2041. # Remove trailing space
  2042. string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST)
  2043. # Transform endline separated - string into CMake List
  2044. string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}")
  2045. # Remove unnecessary quotes
  2046. string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}")
  2047. # Remove ABSOLUTE install file from INSTALL FILE LIST
  2048. list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL})
  2049. # Rebuild INSTALL_FILES
  2050. set(CPACK_RPM_INSTALL_FILES "")
  2051. foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST)
  2052. string(APPEND CPACK_RPM_INSTALL_FILES "\"${F}\"\n")
  2053. endforeach()
  2054. # Build ABSOLUTE_INSTALL_FILES
  2055. set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "")
  2056. foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
  2057. string(APPEND CPACK_RPM_ABSOLUTE_INSTALL_FILES "%config \"${F}\"\n")
  2058. endforeach()
  2059. if(CPACK_RPM_PACKAGE_DEBUG)
  2060. message("CPackRPM:Debug: CPACK_RPM_ABSOLUTE_INSTALL_FILES=${CPACK_RPM_ABSOLUTE_INSTALL_FILES}")
  2061. message("CPackRPM:Debug: CPACK_RPM_INSTALL_FILES=${CPACK_RPM_INSTALL_FILES}")
  2062. endif()
  2063. else()
  2064. # reset vars in order to avoid leakage of value(s) from one component to another
  2065. set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "")
  2066. endif()
  2067. cpack_rpm_variable_fallback("CPACK_RPM_DEBUGINFO_PACKAGE"
  2068. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_DEBUGINFO_PACKAGE"
  2069. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEBUGINFO_PACKAGE"
  2070. "CPACK_RPM_DEBUGINFO_PACKAGE")
  2071. if(CPACK_RPM_DEBUGINFO_PACKAGE OR (CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND NOT GENERATE_SPEC_PARTS))
  2072. cpack_rpm_variable_fallback("CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX"
  2073. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_BUILD_SOURCE_DIRS_PREFIX"
  2074. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_BUILD_SOURCE_DIRS_PREFIX"
  2075. "CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX")
  2076. if(NOT CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX)
  2077. set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}")
  2078. endif()
  2079. # handle cases where path contains extra slashes (e.g. /a//b/ instead of
  2080. # /a/b)
  2081. get_filename_component(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
  2082. "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}" ABSOLUTE)
  2083. if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS)
  2084. file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.files"
  2085. "${CPACK_RPM_INSTALL_FILES}")
  2086. else()
  2087. if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND CPACK_RPM_PACKAGE_COMPONENT)
  2088. # this part is only required by components packaging - with monolithic
  2089. # packages we can be certain that there are no other components present
  2090. # so CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE is a noop
  2091. if(CPACK_RPM_DEBUGINFO_PACKAGE)
  2092. # only add current package files to debuginfo list if debuginfo
  2093. # generation is enabled for current package
  2094. string(STRIP "${CPACK_RPM_INSTALL_FILES}" install_files_)
  2095. string(REPLACE "\n" ";" install_files_ "${install_files_}")
  2096. string(REPLACE "\"" "" install_files_ "${install_files_}")
  2097. else()
  2098. unset(install_files_)
  2099. endif()
  2100. file(GLOB files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.files")
  2101. foreach(f_ IN LISTS files_)
  2102. file(READ "${f_}" tmp_)
  2103. string(APPEND install_files_ ";${tmp_}")
  2104. endforeach()
  2105. # if there were other components/groups so we need to move files from them
  2106. # to current component otherwise those files won't be found
  2107. file(GLOB components_ LIST_DIRECTORIES true RELATIVE
  2108. "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}"
  2109. "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/*")
  2110. foreach(component_ IN LISTS components_)
  2111. string(TOUPPER "${component_}" component_dir_upper_)
  2112. if(component_dir_upper_ STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
  2113. # skip current component
  2114. continue()
  2115. endif()
  2116. cmake_policy(PUSH)
  2117. cmake_policy(SET CMP0009 NEW)
  2118. file(GLOB_RECURSE files_for_move_ LIST_DIRECTORIES false RELATIVE
  2119. "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}"
  2120. "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/*")
  2121. cmake_policy(POP)
  2122. foreach(f_ IN LISTS files_for_move_)
  2123. get_filename_component(dir_path_ "${f_}" DIRECTORY)
  2124. set(src_file_
  2125. "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/${f_}")
  2126. # check that we are not overriding an existing file that doesn't
  2127. # match the file that we want to copy
  2128. if(EXISTS "${src_file_}" AND EXISTS "${WDIR}/${f_}")
  2129. execute_process(
  2130. COMMAND ${CMAKE_COMMAND} -E compare_files "${src_file_}" "${WDIR}/${f_}"
  2131. RESULT_VARIABLE res_
  2132. )
  2133. if(res_)
  2134. message(FATAL_ERROR "CPackRPM:Error: File on path '${WDIR}/${f_}'"
  2135. " already exists but is a different than the one in component"
  2136. " '${component_}'! Packages will not be generated.")
  2137. endif()
  2138. endif()
  2139. file(MAKE_DIRECTORY "${WDIR}/${dir_path_}")
  2140. file(RENAME "${src_file_}"
  2141. "${WDIR}/${f_}")
  2142. endforeach()
  2143. endforeach()
  2144. cpack_rpm_debugsymbol_check("${install_files_}" "${WDIR}")
  2145. else()
  2146. string(STRIP "${CPACK_RPM_INSTALL_FILES}" install_files_)
  2147. string(REPLACE "\n" ";" install_files_ "${install_files_}")
  2148. string(REPLACE "\"" "" install_files_ "${install_files_}")
  2149. cpack_rpm_debugsymbol_check("${install_files_}" "${WDIR}")
  2150. endif()
  2151. if(TMP_DEBUGINFO_ADDITIONAL_SOURCES)
  2152. set(TMP_RPM_DEBUGINFO "
  2153. # Modified version of %%debug_package macro
  2154. # defined in /usr/lib/rpm/macros as that one
  2155. # can't handle injection of extra source files.
  2156. %ifnarch noarch
  2157. %global __debug_package 1
  2158. %package debuginfo
  2159. Summary: Debug information for package %{name}
  2160. Group: Development/Debug
  2161. AutoReqProv: 0
  2162. %description debuginfo
  2163. This package provides debug information for package %{name}.
  2164. Debug information is useful when developing applications that use this
  2165. package or when debugging this package.
  2166. %files debuginfo -f debugfiles.list
  2167. %defattr(-,root,root)
  2168. ${TMP_DEBUGINFO_ADDITIONAL_SOURCES}
  2169. %endif
  2170. ")
  2171. elseif(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE)
  2172. message(AUTHOR_WARNING "CPackRPM:Warning: debuginfo package was requested"
  2173. " but will not be generated as no source files were found!")
  2174. else()
  2175. message(AUTHOR_WARNING "CPackRPM:Warning: debuginfo package was requested"
  2176. " but will not be generated as no source files were found! Component: '"
  2177. "${CPACK_RPM_PACKAGE_COMPONENT}'.")
  2178. endif()
  2179. endif()
  2180. endif()
  2181. # Prepare install files
  2182. cpack_rpm_prepare_install_files(
  2183. "${CPACK_RPM_INSTALL_FILES}"
  2184. "${WDIR}"
  2185. "${RPM_USED_PACKAGE_PREFIXES}"
  2186. "${CPACK_RPM_PACKAGE_RELOCATABLE}"
  2187. )
  2188. # set default user and group
  2189. foreach(_PERM_TYPE "USER" "GROUP")
  2190. if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE})
  2191. set(TMP_DEFAULT_${_PERM_TYPE} "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}}")
  2192. elseif(CPACK_RPM_DEFAULT_${_PERM_TYPE})
  2193. set(TMP_DEFAULT_${_PERM_TYPE} "${CPACK_RPM_DEFAULT_${_PERM_TYPE}}")
  2194. else()
  2195. set(TMP_DEFAULT_${_PERM_TYPE} "root")
  2196. endif()
  2197. endforeach()
  2198. # set default file and dir permissions
  2199. foreach(_PERM_TYPE "FILE" "DIR")
  2200. if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS)
  2201. get_unix_permissions_octal_notation("CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
  2202. set(_PERMISSIONS_VAR "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
  2203. elseif(CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS)
  2204. get_unix_permissions_octal_notation("CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
  2205. set(_PERMISSIONS_VAR "CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
  2206. else()
  2207. set(TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS "-")
  2208. endif()
  2209. endforeach()
  2210. # The name of the final spec file to be used by rpmbuild
  2211. set(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec")
  2212. # Print out some debug information if we were asked for that
  2213. if(CPACK_RPM_PACKAGE_DEBUG)
  2214. message("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}")
  2215. message("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}")
  2216. message("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}")
  2217. message("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}")
  2218. message("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}")
  2219. message("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}")
  2220. message("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}")
  2221. message("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  2222. message("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}")
  2223. endif()
  2224. #
  2225. # USER generated/provided spec file handling.
  2226. #
  2227. # We can have a component specific spec file.
  2228. if(CPACK_RPM_PACKAGE_COMPONENT)
  2229. cpack_rpm_variable_fallback("CPACK_RPM_USER_BINARY_SPECFILE"
  2230. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE"
  2231. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_BINARY_SPECFILE")
  2232. endif()
  2233. cpack_rpm_variable_fallback("CPACK_RPM_FILE_NAME"
  2234. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_FILE_NAME"
  2235. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_FILE_NAME"
  2236. "CPACK_RPM_FILE_NAME")
  2237. if(NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT")
  2238. if(CPACK_RPM_FILE_NAME)
  2239. cmake_policy(PUSH)
  2240. cmake_policy(SET CMP0010 NEW)
  2241. if(NOT CPACK_RPM_FILE_NAME MATCHES ".*\\.rpm")
  2242. cmake_policy(POP)
  2243. message(FATAL_ERROR "'${CPACK_RPM_FILE_NAME}' is not a valid RPM package file name as it must end with '.rpm'!")
  2244. endif()
  2245. cmake_policy(POP)
  2246. else()
  2247. # old file name format for back compatibility
  2248. string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}"
  2249. CPACK_RPM_MAIN_COMPONENT_UPPER)
  2250. if(CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
  2251. # this is the main component so ignore the component filename part
  2252. set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.rpm")
  2253. else()
  2254. set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
  2255. endif()
  2256. endif()
  2257. # else example:
  2258. #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
  2259. if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS)
  2260. string(TOLOWER "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm" expected_filename_)
  2261. file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.rpm_name"
  2262. "${expected_filename_};${CPACK_RPM_FILE_NAME}")
  2263. elseif(NOT CPACK_RPM_DEBUGINFO_PACKAGE)
  2264. set(FILE_NAME_DEFINE "%define _rpmfilename ${CPACK_RPM_FILE_NAME}")
  2265. endif()
  2266. endif()
  2267. if(CPACK_RPM_PACKAGE_SOURCES) # source rpm
  2268. set(archive_name_ "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}")
  2269. execute_process(
  2270. COMMAND ${CMAKE_COMMAND} -E tar "cfvz" "${CPACK_RPM_DIRECTORY}/SOURCES/${archive_name_}.tar.gz" "${CPACK_PACKAGE_FILE_NAME}"
  2271. WORKING_DIRECTORY ${CPACK_RPM_DIRECTORY}
  2272. )
  2273. set(TMP_RPM_SOURCE "Source: ${archive_name_}.tar.gz")
  2274. if(CPACK_RPM_BUILDREQUIRES)
  2275. set(TMP_RPM_BUILD_REQUIRES "BuildRequires: ${CPACK_RPM_BUILDREQUIRES}")
  2276. endif()
  2277. # Disable debuginfo packages - srpm generates invalid packages due to
  2278. # releasing control to cpack to generate binary packages.
  2279. # Note however that this doesn't prevent cpack to generate debuginfo
  2280. # packages when run from srpm with --rebuild.
  2281. set(TMP_RPM_DISABLE_DEBUGINFO "%define debug_package %{nil}")
  2282. if(NOT CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX)
  2283. set(CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX "/")
  2284. endif()
  2285. set(TMP_RPM_BUILD
  2286. "
  2287. %build
  2288. mkdir cpack_rpm_build_dir
  2289. cd cpack_rpm_build_dir
  2290. cmake ${CPACK_RPM_SOURCE_PKG_BUILD_PARAMS} -DCPACK_PACKAGING_INSTALL_PREFIX=${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX} ../${CPACK_PACKAGE_FILE_NAME}
  2291. make %{?_smp_mflags}" # %{?_smp_mflags} -> -j option
  2292. )
  2293. set(TMP_RPM_INSTALL
  2294. "
  2295. cd cpack_rpm_build_dir
  2296. cpack -G RPM
  2297. mv *.rpm %_rpmdir"
  2298. )
  2299. set(TMP_RPM_PREP "%setup -c")
  2300. set(RPMBUILD_FLAGS "-bs")
  2301. file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in
  2302. "# Restore old style debuginfo creation for rpm >= 4.14.
  2303. %undefine _debugsource_packages
  2304. %undefine _debuginfo_subpackages
  2305. # -*- rpm-spec -*-
  2306. BuildRoot: %_topdir/\@CPACK_PACKAGE_FILE_NAME\@
  2307. Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@
  2308. Name: \@CPACK_RPM_PACKAGE_NAME\@
  2309. Version: \@CPACK_RPM_PACKAGE_VERSION\@
  2310. Release: \@CPACK_RPM_PACKAGE_RELEASE\@
  2311. License: \@CPACK_RPM_PACKAGE_LICENSE\@
  2312. Group: \@CPACK_RPM_PACKAGE_GROUP\@
  2313. Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@
  2314. \@TMP_RPM_SOURCE\@
  2315. \@TMP_RPM_BUILD_REQUIRES\@
  2316. \@TMP_RPM_BUILDARCH\@
  2317. \@TMP_RPM_PREFIXES\@
  2318. \@TMP_RPM_DISABLE_DEBUGINFO\@
  2319. %define _rpmdir %_topdir/RPMS
  2320. %define _srcrpmdir %_topdir/SRPMS
  2321. \@FILE_NAME_DEFINE\@
  2322. %define _unpackaged_files_terminate_build 0
  2323. \@TMP_RPM_SPEC_INSTALL_POST\@
  2324. \@CPACK_RPM_SPEC_MORE_DEFINE\@
  2325. \@CPACK_RPM_COMPRESSION_TYPE_TMP\@
  2326. %description
  2327. \@CPACK_RPM_PACKAGE_DESCRIPTION\@
  2328. # This is a shortcutted spec file generated by CMake RPM generator
  2329. # we skip _install step because CPack does that for us.
  2330. # We do only save CPack installed tree in _prepr
  2331. # and then restore it in build.
  2332. %prep
  2333. \@TMP_RPM_PREP\@
  2334. \@TMP_RPM_BUILD\@
  2335. #p build
  2336. %install
  2337. \@TMP_RPM_INSTALL\@
  2338. %clean
  2339. %changelog
  2340. \@CPACK_RPM_SPEC_CHANGELOG\@
  2341. "
  2342. )
  2343. elseif(GENERATE_SPEC_PARTS) # binary rpm with single debuginfo package
  2344. file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in
  2345. "# -*- rpm-spec -*-
  2346. %package -n \@CPACK_RPM_PACKAGE_NAME\@
  2347. Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@
  2348. Version: \@CPACK_RPM_PACKAGE_VERSION\@
  2349. Release: \@CPACK_RPM_PACKAGE_RELEASE\@
  2350. License: \@CPACK_RPM_PACKAGE_LICENSE\@
  2351. Group: \@CPACK_RPM_PACKAGE_GROUP\@
  2352. Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@
  2353. \@TMP_RPM_URL\@
  2354. \@TMP_RPM_REQUIRES\@
  2355. \@TMP_RPM_REQUIRES_PRE\@
  2356. \@TMP_RPM_REQUIRES_POST\@
  2357. \@TMP_RPM_REQUIRES_PREUN\@
  2358. \@TMP_RPM_REQUIRES_POSTUN\@
  2359. \@TMP_RPM_PROVIDES\@
  2360. \@TMP_RPM_OBSOLETES\@
  2361. \@TMP_RPM_CONFLICTS\@
  2362. \@TMP_RPM_SUGGESTS\@
  2363. \@TMP_RPM_AUTOPROV\@
  2364. \@TMP_RPM_AUTOREQ\@
  2365. \@TMP_RPM_AUTOREQPROV\@
  2366. \@TMP_RPM_BUILDARCH\@
  2367. \@TMP_RPM_PREFIXES\@
  2368. \@TMP_RPM_EPOCH\@
  2369. %description -n \@CPACK_RPM_PACKAGE_NAME\@
  2370. \@CPACK_RPM_PACKAGE_DESCRIPTION\@
  2371. %files -n \@CPACK_RPM_PACKAGE_NAME\@
  2372. %defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@)
  2373. \@CPACK_RPM_INSTALL_FILES\@
  2374. \@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@
  2375. \@CPACK_RPM_USER_INSTALL_FILES\@
  2376. "
  2377. )
  2378. else() # binary rpm
  2379. if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE)
  2380. # find generated spec file and take its name
  2381. file(GLOB spec_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.spec")
  2382. foreach(f_ IN LISTS spec_files_)
  2383. file(READ "${f_}" tmp_)
  2384. string(APPEND TMP_OTHER_COMPONENTS "\n${tmp_}\n")
  2385. endforeach()
  2386. endif()
  2387. # We should generate a USER spec file template:
  2388. # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
  2389. # - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE
  2390. set(RPMBUILD_FLAGS "-bb")
  2391. if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE)
  2392. file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in
  2393. "# Restore old style debuginfo creation for rpm >= 4.14.
  2394. %undefine _debugsource_packages
  2395. %undefine _debuginfo_subpackages
  2396. # -*- rpm-spec -*-
  2397. BuildRoot: %_topdir/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@
  2398. Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@
  2399. Name: \@CPACK_RPM_PACKAGE_NAME\@
  2400. Version: \@CPACK_RPM_PACKAGE_VERSION\@
  2401. Release: \@CPACK_RPM_PACKAGE_RELEASE\@
  2402. License: \@CPACK_RPM_PACKAGE_LICENSE\@
  2403. Group: \@CPACK_RPM_PACKAGE_GROUP\@
  2404. Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@
  2405. \@TMP_RPM_URL\@
  2406. \@TMP_RPM_REQUIRES\@
  2407. \@TMP_RPM_REQUIRES_PRE\@
  2408. \@TMP_RPM_REQUIRES_POST\@
  2409. \@TMP_RPM_REQUIRES_PREUN\@
  2410. \@TMP_RPM_REQUIRES_POSTUN\@
  2411. \@TMP_RPM_PROVIDES\@
  2412. \@TMP_RPM_OBSOLETES\@
  2413. \@TMP_RPM_CONFLICTS\@
  2414. \@TMP_RPM_SUGGESTS\@
  2415. \@TMP_RPM_AUTOPROV\@
  2416. \@TMP_RPM_AUTOREQ\@
  2417. \@TMP_RPM_AUTOREQPROV\@
  2418. \@TMP_RPM_BUILDARCH\@
  2419. \@TMP_RPM_PREFIXES\@
  2420. \@TMP_RPM_EPOCH\@
  2421. \@TMP_RPM_DEBUGINFO\@
  2422. %define _rpmdir %_topdir/RPMS
  2423. %define _srcrpmdir %_topdir/SRPMS
  2424. \@FILE_NAME_DEFINE\@
  2425. %define _unpackaged_files_terminate_build 0
  2426. \@TMP_RPM_SPEC_INSTALL_POST\@
  2427. \@CPACK_RPM_SPEC_MORE_DEFINE\@
  2428. \@CPACK_RPM_COMPRESSION_TYPE_TMP\@
  2429. %description
  2430. \@CPACK_RPM_PACKAGE_DESCRIPTION\@
  2431. # This is a shortcutted spec file generated by CMake RPM generator
  2432. # we skip _install step because CPack does that for us.
  2433. # We do only save CPack installed tree in _prepr
  2434. # and then restore it in build.
  2435. %prep
  2436. mv $RPM_BUILD_ROOT %_topdir/tmpBBroot
  2437. %install
  2438. if [ -e $RPM_BUILD_ROOT ];
  2439. then
  2440. rm -rf $RPM_BUILD_ROOT
  2441. fi
  2442. mv %_topdir/tmpBBroot $RPM_BUILD_ROOT
  2443. \@TMP_RPM_DEBUGINFO_INSTALL\@
  2444. %clean
  2445. %post
  2446. \@RPM_SYMLINK_POSTINSTALL\@
  2447. \@CPACK_RPM_SPEC_POSTINSTALL\@
  2448. %postun
  2449. \@CPACK_RPM_SPEC_POSTUNINSTALL\@
  2450. %pre
  2451. \@CPACK_RPM_SPEC_PREINSTALL\@
  2452. %preun
  2453. \@CPACK_RPM_SPEC_PREUNINSTALL\@
  2454. %files
  2455. %defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@)
  2456. \@CPACK_RPM_INSTALL_FILES\@
  2457. \@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@
  2458. \@CPACK_RPM_USER_INSTALL_FILES\@
  2459. %changelog
  2460. \@CPACK_RPM_SPEC_CHANGELOG\@
  2461. \@TMP_OTHER_COMPONENTS\@
  2462. "
  2463. )
  2464. endif()
  2465. # Stop here if we were asked to only generate a template USER spec file
  2466. # The generated file may then be used as a template by user who wants
  2467. # to customize their own spec file.
  2468. if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE)
  2469. message(FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file template is: ${CPACK_RPM_BINARY_SPECFILE}.in")
  2470. endif()
  2471. endif()
  2472. # After that we may either use a user provided spec file
  2473. # or generate one using appropriate variables value.
  2474. if(CPACK_RPM_USER_BINARY_SPECFILE)
  2475. # User may have specified SPECFILE just use it
  2476. message("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}")
  2477. # The user provided file is processed for @var replacement
  2478. configure_file(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
  2479. else()
  2480. # No User specified spec file, will use the generated spec file
  2481. message("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}")
  2482. # Note the just created file is processed for @var replacement
  2483. configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
  2484. endif()
  2485. if(NOT GENERATE_SPEC_PARTS) # generate package
  2486. if(RPMBUILD_EXECUTABLE)
  2487. # Now call rpmbuild using the SPECFILE
  2488. execute_process(
  2489. COMMAND "${RPMBUILD_EXECUTABLE}" ${RPMBUILD_FLAGS}
  2490. --define "_topdir ${CPACK_RPM_DIRECTORY}"
  2491. --buildroot "%_topdir/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
  2492. --target "${CPACK_RPM_PACKAGE_ARCHITECTURE}"
  2493. "${CPACK_RPM_BINARY_SPECFILE}"
  2494. WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
  2495. RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT
  2496. ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err"
  2497. OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out")
  2498. if(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT)
  2499. file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err RPMBUILDERR)
  2500. file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out RPMBUILDOUT)
  2501. message("CPackRPM:Debug: You may consult rpmbuild logs in: ")
  2502. message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err")
  2503. message("CPackRPM:Debug: *** ${RPMBUILDERR} ***")
  2504. message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out")
  2505. message("CPackRPM:Debug: *** ${RPMBUILDOUT} ***")
  2506. endif()
  2507. else()
  2508. if(ALIEN_EXECUTABLE)
  2509. message(FATAL_ERROR "RPM packaging through alien not done (yet)")
  2510. endif()
  2511. endif()
  2512. # find generated rpm files and take their names
  2513. cmake_policy(PUSH)
  2514. # Tell file(GLOB_RECURSE) not to follow directory symlinks
  2515. # even if the project does not set this policy to NEW.
  2516. cmake_policy(SET CMP0009 NEW)
  2517. file(GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/RPMS/*.rpm"
  2518. "${CPACK_RPM_DIRECTORY}/SRPMS/*.rpm")
  2519. cmake_policy(POP)
  2520. if(NOT GENERATED_FILES)
  2521. message(FATAL_ERROR "RPM package was not generated! ${CPACK_RPM_DIRECTORY}")
  2522. endif()
  2523. unset(expected_filenames_)
  2524. unset(filenames_)
  2525. if(CPACK_RPM_DEBUGINFO_PACKAGE AND NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT")
  2526. list(APPEND expected_filenames_
  2527. "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm")
  2528. list(APPEND filenames_ "${CPACK_RPM_FILE_NAME}")
  2529. endif()
  2530. if(CPACK_RPM_DEBUGINFO_PACKAGE)
  2531. cpack_rpm_variable_fallback("CPACK_RPM_DEBUGINFO_FILE_NAME"
  2532. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_DEBUGINFO_FILE_NAME"
  2533. "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEBUGINFO_FILE_NAME"
  2534. "CPACK_RPM_DEBUGINFO_FILE_NAME")
  2535. if(CPACK_RPM_DEBUGINFO_FILE_NAME AND
  2536. NOT CPACK_RPM_DEBUGINFO_FILE_NAME STREQUAL "RPM-DEFAULT")
  2537. list(APPEND expected_filenames_
  2538. "${CPACK_RPM_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}.*\\.rpm")
  2539. string(REPLACE "@cpack_component@" "${CPACK_RPM_PACKAGE_COMPONENT}"
  2540. CPACK_RPM_DEBUGINFO_FILE_NAME "${CPACK_RPM_DEBUGINFO_FILE_NAME}")
  2541. list(APPEND filenames_ "${CPACK_RPM_DEBUGINFO_FILE_NAME}")
  2542. endif()
  2543. endif()
  2544. # check if other files have to be renamed
  2545. file(GLOB rename_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.rpm_name")
  2546. if(rename_files_)
  2547. foreach(f_ IN LISTS rename_files_)
  2548. file(READ "${f_}" tmp_)
  2549. list(GET tmp_ 0 efn_)
  2550. list(APPEND expected_filenames_ "${efn_}")
  2551. list(GET tmp_ 1 fn_)
  2552. list(APPEND filenames_ "${fn_}")
  2553. endforeach()
  2554. endif()
  2555. if(expected_filenames_)
  2556. foreach(F IN LISTS GENERATED_FILES)
  2557. unset(matched_)
  2558. foreach(expected_ IN LISTS expected_filenames_)
  2559. if(F MATCHES ".*/${expected_}")
  2560. list(FIND expected_filenames_ "${expected_}" idx_)
  2561. list(GET filenames_ ${idx_} filename_)
  2562. get_filename_component(FILE_PATH "${F}" DIRECTORY)
  2563. file(RENAME "${F}" "${FILE_PATH}/${filename_}")
  2564. list(APPEND new_files_list_ "${FILE_PATH}/${filename_}")
  2565. set(matched_ "YES")
  2566. break()
  2567. endif()
  2568. endforeach()
  2569. if(NOT matched_)
  2570. list(APPEND new_files_list_ "${F}")
  2571. endif()
  2572. endforeach()
  2573. set(GENERATED_FILES "${new_files_list_}")
  2574. endif()
  2575. endif()
  2576. set(GEN_CPACK_OUTPUT_FILES "${GENERATED_FILES}" PARENT_SCOPE)
  2577. if(CPACK_RPM_PACKAGE_DEBUG)
  2578. message("CPackRPM:Debug: GEN_CPACK_OUTPUT_FILES = ${GENERATED_FILES}")
  2579. endif()
  2580. endfunction()
  2581. cpack_rpm_generate_package()