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