RunCPackVerifyResult.cmake 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. # prevent older policies from interfearing with this script
  2. cmake_policy(PUSH)
  3. cmake_policy(VERSION ${CMAKE_VERSION})
  4. message(STATUS "=============================================================================")
  5. message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
  6. message(STATUS "")
  7. if(NOT CPackComponentsForAll_BINARY_DIR)
  8. message(FATAL_ERROR "CPackComponentsForAll_BINARY_DIR not set")
  9. endif()
  10. if(NOT CPackGen)
  11. message(FATAL_ERROR "CPackGen not set")
  12. endif()
  13. message("CMAKE_CPACK_COMMAND = ${CMAKE_CPACK_COMMAND}")
  14. if(NOT CMAKE_CPACK_COMMAND)
  15. message(FATAL_ERROR "CMAKE_CPACK_COMMAND not set")
  16. endif()
  17. if(NOT CPackComponentWay)
  18. message(FATAL_ERROR "CPackComponentWay not set")
  19. endif()
  20. set(expected_file_mask "")
  21. # The usual default behavior is to expect a single file
  22. # Then some specific generators (Archive, RPM, ...)
  23. # May produce several numbers of files depending on
  24. # CPACK_COMPONENT_xxx values
  25. set(expected_count 1)
  26. set(config_type $ENV{CMAKE_CONFIG_TYPE})
  27. set(config_args )
  28. if(config_type)
  29. set(config_args -C ${config_type})
  30. endif()
  31. set(config_verbose )
  32. if(CPackGen MATCHES "ZIP")
  33. set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip")
  34. if(${CPackComponentWay} STREQUAL "default")
  35. set(expected_count 1)
  36. elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup")
  37. set(expected_count 3)
  38. elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
  39. set(expected_count 4)
  40. elseif(${CPackComponentWay} STREQUAL "AllInOne")
  41. set(expected_count 1)
  42. endif()
  43. elseif(CPackGen MATCHES "RPM")
  44. set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1")
  45. set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm")
  46. if(${CPackComponentWay} STREQUAL "default")
  47. set(expected_count 1)
  48. elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup")
  49. set(expected_count 3)
  50. elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
  51. set(expected_count 4)
  52. elseif(${CPackComponentWay} STREQUAL "AllInOne")
  53. set(expected_count 1)
  54. endif()
  55. elseif(CPackGen MATCHES "DEB")
  56. set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2_*.deb")
  57. if(${CPackComponentWay} STREQUAL "default")
  58. set(expected_count 1)
  59. elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup")
  60. set(expected_count 3)
  61. elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
  62. set(expected_count 4)
  63. elseif(${CPackComponentWay} STREQUAL "AllInOne")
  64. set(expected_count 1)
  65. endif()
  66. elseif(CPackGen MATCHES "NuGet")
  67. set(config_verbose -D "CPACK_NUGET_PACKAGE_DEBUG=1")
  68. set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib*1.0.2.nupkg")
  69. if(${CPackComponentWay} STREQUAL "default")
  70. set(expected_count 1)
  71. elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup")
  72. set(expected_count 3)
  73. elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
  74. set(expected_count 4)
  75. elseif(${CPackComponentWay} STREQUAL "AllInOne")
  76. set(expected_count 1)
  77. endif()
  78. endif()
  79. if(CPackGen MATCHES "DragNDrop")
  80. set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.dmg")
  81. if(${CPackComponentWay} STREQUAL "default")
  82. set(expected_count 1)
  83. set(expect_dmg_sla 1)
  84. elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup")
  85. set(expected_count 3)
  86. elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
  87. set(expected_count 4)
  88. elseif(${CPackComponentWay} STREQUAL "AllInOne")
  89. set(expected_count 1)
  90. set(expect_dmg_sla 1)
  91. endif()
  92. endif()
  93. # clean-up previously CPack generated files
  94. if(expected_file_mask)
  95. file(GLOB expected_file "${expected_file_mask}")
  96. if(expected_file)
  97. file(REMOVE ${expected_file})
  98. endif()
  99. endif()
  100. message("config_args = ${config_args}")
  101. message("config_verbose = ${config_verbose}")
  102. execute_process(COMMAND ${CMAKE_CPACK_COMMAND} ${config_verbose} -G ${CPackGen} ${config_args}
  103. RESULT_VARIABLE CPack_result
  104. OUTPUT_VARIABLE CPack_output
  105. ERROR_VARIABLE CPack_error
  106. WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR})
  107. if(CPack_result)
  108. message(FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}")
  109. else ()
  110. message(STATUS "CPack_output=${CPack_output}")
  111. endif()
  112. # Now verify if the number of expected file is OK
  113. # - using expected_file_mask and
  114. # - expected_count
  115. if(expected_file_mask)
  116. file(GLOB expected_file "${expected_file_mask}")
  117. message(STATUS "expected_count='${expected_count}'")
  118. message(STATUS "expected_file='${expected_file}'")
  119. message(STATUS "expected_file_mask='${expected_file_mask}'")
  120. if(NOT expected_file)
  121. message(FATAL_ERROR "error: expected_file does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}")
  122. endif()
  123. list(LENGTH expected_file actual_count)
  124. message(STATUS "actual_count='${actual_count}'")
  125. if(NOT actual_count EQUAL expected_count)
  126. message(FATAL_ERROR "error: expected_count=${expected_count} does not match actual_count=${actual_count}: CPackComponents test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error})")
  127. endif()
  128. if(expect_dmg_sla)
  129. execute_process(COMMAND hdiutil udifderez -xml "${expected_file}" OUTPUT_VARIABLE out ERROR_VARIABLE err RESULT_VARIABLE res)
  130. if(NOT res EQUAL 0)
  131. string(REPLACE "\n" "\n " err " ${err}")
  132. message(FATAL_ERROR "error: running 'hdiutil udifderez -xml' on\n ${expected_file}\nfailed with:\n${err}")
  133. endif()
  134. foreach(key "LPic" "STR#" "TEXT")
  135. if(NOT out MATCHES "<key>${key}</key>")
  136. string(REPLACE "\n" "\n " out " ${out}")
  137. message(FATAL_ERROR "error: running 'hdiutil udifderez -xml' on\n ${expected_file}\ndid not show '${key}' key:\n${out}")
  138. endif()
  139. endforeach()
  140. endif()
  141. endif()
  142. # Validate content
  143. if(CPackGen MATCHES "RPM")
  144. find_program(RPM_EXECUTABLE rpm)
  145. if(NOT RPM_EXECUTABLE)
  146. message(FATAL_ERROR "error: missing rpm executable required by the test")
  147. endif()
  148. set(CPACK_RPM_PACKAGE_SUMMARY "default summary")
  149. set(CPACK_RPM_HEADERS_PACKAGE_SUMMARY "headers summary")
  150. set(CPACK_RPM_HEADERS_PACKAGE_DESCRIPTION "headers description")
  151. set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
  152. "An extremely useful application that makes use of MyLib")
  153. set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
  154. "Static libraries used to build programs with MyLib")
  155. set(LIB_SUFFIX "6?4?")
  156. # test package info
  157. if(${CPackComponentWay} STREQUAL "IgnoreGroup")
  158. # set gnu install prefixes to what they are set during rpm creation
  159. # CMAKE_SIZEOF_VOID_P is not set here but lib is prefix of lib64 so
  160. # relocation path test won't fail on OSes with lib64 library location
  161. include(GNUInstallDirs)
  162. set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/foo/bar")
  163. foreach(check_file ${expected_file})
  164. string(REGEX MATCH ".*libraries.*" check_file_libraries_match ${check_file})
  165. string(REGEX MATCH ".*headers.*" check_file_headers_match ${check_file})
  166. string(REGEX MATCH ".*applications.*" check_file_applications_match ${check_file})
  167. string(REGEX MATCH ".*Unspecified.*" check_file_Unspecified_match ${check_file})
  168. execute_process(COMMAND ${RPM_EXECUTABLE} -pqi ${check_file}
  169. OUTPUT_VARIABLE check_file_content
  170. ERROR_QUIET
  171. OUTPUT_STRIP_TRAILING_WHITESPACE)
  172. execute_process(COMMAND ${RPM_EXECUTABLE} -pqa ${check_file}
  173. RESULT_VARIABLE check_package_architecture_result
  174. OUTPUT_VARIABLE check_package_architecture
  175. ERROR_QUIET
  176. OUTPUT_STRIP_TRAILING_WHITESPACE)
  177. execute_process(COMMAND ${RPM_EXECUTABLE} -pql ${check_file}
  178. OUTPUT_VARIABLE check_package_content
  179. ERROR_QUIET
  180. OUTPUT_STRIP_TRAILING_WHITESPACE)
  181. set(whitespaces "[\\t\\n\\r ]*")
  182. if(check_file_libraries_match)
  183. set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
  184. set(check_file_match_expected_description ".*${CPACK_COMPONENT_LIBRARIES_DESCRIPTION}.*")
  185. set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/other_relocatable${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX}/inside_relocatable_two/depth_two/different_relocatable")
  186. set(check_file_match_expected_architecture "") # we don't explicitly set this value so it is different on each platform - ignore it
  187. set(spec_regex "*libraries*")
  188. set(check_content_list "^/usr/foo/bar/lib${LIB_SUFFIX}
  189. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one
  190. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two
  191. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/depth_three
  192. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/depth_three/symlink_parentdir_path
  193. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_outside_package
  194. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_outside_wdr
  195. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_relocatable_subpath
  196. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_samedir_path
  197. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_samedir_path_current_dir
  198. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_samedir_path_longer
  199. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/symlink_subdir_path
  200. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two
  201. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two/depth_two
  202. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two/depth_two/different_relocatable
  203. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two/depth_two/different_relocatable/bar
  204. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two/depth_two/symlink_other_relocatable_path
  205. /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_two/depth_two/symlink_to_non_relocatable_path
  206. /usr/foo/bar/lib${LIB_SUFFIX}/libmylib.a
  207. /usr/foo/bar/non_relocatable
  208. /usr/foo/bar/non_relocatable/depth_two
  209. /usr/foo/bar/non_relocatable/depth_two/symlink_from_non_relocatable_path
  210. /usr/foo/bar/other_relocatable
  211. /usr/foo/bar/other_relocatable/depth_two(\n.*\.build-id.*)*$")
  212. elseif(check_file_headers_match)
  213. set(check_file_match_expected_summary ".*${CPACK_RPM_HEADERS_PACKAGE_SUMMARY}.*")
  214. set(check_file_match_expected_description ".*${CPACK_RPM_HEADERS_PACKAGE_DESCRIPTION}.*")
  215. set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
  216. set(check_file_match_expected_architecture "noarch")
  217. set(spec_regex "*headers*")
  218. set(check_content_list "^/usr/foo/bar\n/usr/foo/bar/include\n/usr/foo/bar/include/mylib.h(\n.*\.build-id.*)*$")
  219. elseif(check_file_applications_match)
  220. set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
  221. set(check_file_match_expected_description ".*${CPACK_COMPONENT_APPLICATIONS_DESCRIPTION}.*")
  222. set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
  223. set(check_file_match_expected_architecture "armv7hf")
  224. set(spec_regex "*applications*")
  225. set(check_content_list "^/usr/foo/bar
  226. /usr/foo/bar/bin
  227. /usr/foo/bar/bin/mylibapp(\n.*\.build-id.*)*$")
  228. elseif(check_file_Unspecified_match)
  229. set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
  230. set(check_file_match_expected_description ".*DESCRIPTION.*")
  231. set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
  232. set(check_file_match_expected_architecture "") # we don't explicitly set this value so it is different on each platform - ignore it
  233. set(spec_regex "*Unspecified*")
  234. set(check_content_list "^/usr/foo/bar
  235. /usr/foo/bar/bin
  236. /usr/foo/bar/bin/@in@_@path@@with
  237. /usr/foo/bar/bin/@in@_@path@@with/@and
  238. /usr/foo/bar/bin/@in@_@path@@with/@and/@
  239. /usr/foo/bar/bin/@in@_@path@@with/@and/@/@in_path@
  240. /usr/foo/bar/bin/@in@_@path@@with/@and/@/@in_path@/mylibapp2
  241. /usr/foo/bar/share
  242. /usr/foo/bar/share/man
  243. /usr/foo/bar/share/man/mylib
  244. /usr/foo/bar/share/man/mylib/man3
  245. /usr/foo/bar/share/man/mylib/man3/mylib.1
  246. /usr/foo/bar/share/man/mylib/man3/mylib.1/mylib
  247. /usr/foo/bar/share/man/mylib/man3/mylib.1/mylib2(\n.*\.build-id.*)*$")
  248. else()
  249. message(FATAL_ERROR "error: unexpected rpm package '${check_file}'")
  250. endif()
  251. #######################
  252. # test package info
  253. #######################
  254. string(REGEX MATCH ${check_file_match_expected_summary} check_file_match_summary ${check_file_content})
  255. if(NOT check_file_match_summary)
  256. message(FATAL_ERROR "error: '${check_file}' rpm package summary does not match expected value - regex '${check_file_match_expected_summary}'; RPM output: '${check_file_content}'")
  257. endif()
  258. string(REGEX MATCH ${check_file_match_expected_description} check_file_match_description ${check_file_content})
  259. if(NOT check_file_match_description)
  260. message(FATAL_ERROR "error: '${check_file}' rpm package description does not match expected value - regex '${check_file_match_expected_description}'; RPM output: '${check_file_content}'")
  261. endif()
  262. string(REGEX MATCH ${check_file_match_expected_relocation_path} check_file_match_relocation_path ${check_file_content})
  263. if(NOT check_file_match_relocation_path)
  264. file(GLOB_RECURSE spec_file "${CPackComponentsForAll_BINARY_DIR}/${spec_regex}.spec")
  265. if(spec_file)
  266. file(READ ${spec_file} spec_file_content)
  267. endif()
  268. message(FATAL_ERROR "error: '${check_file}' rpm package relocation path does not match expected value - regex '${check_file_match_expected_relocation_path}'; RPM output: '${check_file_content}'; generated spec file: '${spec_file_content}'")
  269. endif()
  270. #######################
  271. # test package architecture
  272. #######################
  273. string(REGEX MATCH "Architecture${whitespaces}:" check_info_contains_arch ${check_file_content})
  274. if(check_info_contains_arch) # test for rpm versions that contain architecture in package info (e.g. 4.11.x)
  275. string(REGEX MATCH "Architecture${whitespaces}:${whitespaces}${check_file_match_expected_architecture}" check_file_match_architecture ${check_file_content})
  276. if(NOT check_file_match_architecture)
  277. message(FATAL_ERROR "error: '${check_file}' Architecture does not match expected value - '${check_file_match_expected_architecture}'; RPM output: '${check_file_content}'; generated spec file: '${spec_file_content}'")
  278. endif()
  279. elseif(NOT check_package_architecture_result) # test result only on platforms that support -pqa rpm query
  280. # test for rpm versions that do not contain architecture in package info (e.g. 4.8.x)
  281. string(REGEX MATCH ".*${check_file_match_expected_architecture}" check_file_match_architecture "${check_package_architecture}")
  282. if(NOT check_file_match_architecture)
  283. message(FATAL_ERROR "error: '${check_file}' Architecture does not match expected value - '${check_file_match_expected_architecture}'; RPM output: '${check_package_architecture}'; generated spec file: '${spec_file_content}'")
  284. endif()
  285. # else rpm version too old (e.g. 4.4.x) - skip test
  286. endif()
  287. #######################
  288. # test package content
  289. #######################
  290. string(REGEX MATCH "${check_content_list}" expected_content_list "${check_package_content}")
  291. if(NOT expected_content_list)
  292. file(GLOB_RECURSE spec_file "${CPackComponentsForAll_BINARY_DIR}/${spec_regex}.spec")
  293. if(spec_file)
  294. file(READ ${spec_file} spec_file_content)
  295. endif()
  296. message(FATAL_ERROR "error: '${check_file}' rpm package content does not match expected value - regex '${check_content_list}'; RPM output: '${check_package_content}'; generated spec file: '${spec_file_content}'")
  297. endif()
  298. # validate permissions user and group
  299. execute_process(COMMAND ${RPM_EXECUTABLE} -pqlv ${check_file}
  300. OUTPUT_VARIABLE check_file_content
  301. ERROR_QUIET
  302. OUTPUT_STRIP_TRAILING_WHITESPACE)
  303. if(check_file_libraries_match)
  304. set(check_file_match_expected_permissions ".*-rwx------.*user.*defgrp.*")
  305. elseif(check_file_headers_match)
  306. set(check_file_match_expected_permissions ".*-rwxr--r--.*defusr.*defgrp.*")
  307. elseif(check_file_applications_match)
  308. set(check_file_match_expected_permissions ".*-rwxr--r--.*defusr.*group.*")
  309. elseif(check_file_Unspecified_match)
  310. set(check_file_match_expected_permissions ".*-rwxr--r--.*defusr.*defgrp.*")
  311. else()
  312. message(FATAL_ERROR "error: unexpected rpm package '${check_file}'")
  313. endif()
  314. string(REGEX MATCH "${check_file_match_expected_permissions}" check_file_match_permissions "${check_file_content}")
  315. if(NOT check_file_match_permissions)
  316. message(FATAL_ERROR "error: '${check_file}' rpm package permissions do not match expected value - regex '${check_file_match_expected_permissions}'")
  317. endif()
  318. endforeach()
  319. #######################
  320. # verify generated symbolic links
  321. #######################
  322. file(GLOB_RECURSE symlink_files RELATIVE "${CPackComponentsForAll_BINARY_DIR}" "${CPackComponentsForAll_BINARY_DIR}/*/symlink_*")
  323. foreach(check_symlink IN LISTS symlink_files)
  324. get_filename_component(symlink_name "${check_symlink}" NAME)
  325. execute_process(COMMAND ls -la "${check_symlink}"
  326. WORKING_DIRECTORY "${CPackComponentsForAll_BINARY_DIR}"
  327. OUTPUT_VARIABLE SYMLINK_POINT_
  328. OUTPUT_STRIP_TRAILING_WHITESPACE)
  329. if("${symlink_name}" STREQUAL "symlink_samedir_path"
  330. OR "${symlink_name}" STREQUAL "symlink_samedir_path_current_dir"
  331. OR "${symlink_name}" STREQUAL "symlink_samedir_path_longer")
  332. string(REGEX MATCH "^.*${whitespaces}->${whitespaces}depth_three$" check_symlink "${SYMLINK_POINT_}")
  333. elseif("${symlink_name}" STREQUAL "symlink_subdir_path")
  334. string(REGEX MATCH "^.*${whitespaces}->${whitespaces}depth_two/depth_three$" check_symlink "${SYMLINK_POINT_}")
  335. elseif("${symlink_name}" STREQUAL "symlink_parentdir_path")
  336. string(REGEX MATCH "^.*${whitespaces}->${whitespaces}../$" check_symlink "${SYMLINK_POINT_}")
  337. elseif("${symlink_name}" STREQUAL "symlink_to_non_relocatable_path")
  338. string(REGEX MATCH "^.*${whitespaces}->${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/non_relocatable/depth_two$" check_symlink "${SYMLINK_POINT_}")
  339. elseif("${symlink_name}" STREQUAL "symlink_outside_package")
  340. string(REGEX MATCH "^.*${whitespaces}->${whitespaces}outside_package$" check_symlink "${SYMLINK_POINT_}")
  341. elseif("${symlink_name}" STREQUAL "symlink_outside_wdr")
  342. string(REGEX MATCH "^.*${whitespaces}->${whitespaces}/outside_package_wdr$" check_symlink "${SYMLINK_POINT_}")
  343. elseif("${symlink_name}" STREQUAL "symlink_other_relocatable_path"
  344. OR "${symlink_name}" STREQUAL "symlink_from_non_relocatable_path"
  345. OR "${symlink_name}" STREQUAL "symlink_relocatable_subpath")
  346. # these links were not canged - post install script only - ignore them
  347. else()
  348. message(FATAL_ERROR "error: unexpected rpm symbolic link '${check_symlink}'")
  349. endif()
  350. if(NOT check_symlink)
  351. message(FATAL_ERROR "symlink points to unexpected location '${SYMLINK_POINT_}'")
  352. endif()
  353. endforeach()
  354. # verify post install symlink relocation script
  355. file(GLOB_RECURSE spec_file "${CPackComponentsForAll_BINARY_DIR}/*libraries*.spec")
  356. file(READ ${spec_file} spec_file_content)
  357. file(READ "${CMAKE_CURRENT_LIST_DIR}/symlink_postinstall_expected.txt" symlink_postinstall_expected)
  358. # prepare regex
  359. string(STRIP "${symlink_postinstall_expected}" symlink_postinstall_expected)
  360. string(REPLACE "[" "\\[" symlink_postinstall_expected "${symlink_postinstall_expected}")
  361. string(REPLACE "$" "\\$" symlink_postinstall_expected "${symlink_postinstall_expected}")
  362. string(REPLACE "lib" "lib${LIB_SUFFIX}" symlink_postinstall_expected "${symlink_postinstall_expected}")
  363. # compare
  364. string(REGEX MATCH ".*${symlink_postinstall_expected}.*" symlink_postinstall_expected_matches "${spec_file_content}")
  365. if(NOT symlink_postinstall_expected_matches)
  366. message(FATAL_ERROR "error: unexpected rpm symbolic link postinstall script! generated spec file: '${spec_file_content}'")
  367. endif()
  368. endif()
  369. endif()
  370. cmake_policy(POP)