2015-03-29 21:55:20 +03:00
# prevent older policies from interfearing with this script
cmake_policy ( PUSH )
cmake_policy ( VERSION ${ CMAKE_VERSION } )
2010-12-03 00:56:26 +03:00
message ( STATUS "=============================================================================" )
message ( STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" )
message ( STATUS "" )
if ( NOT CPackComponentsForAll_BINARY_DIR )
message ( FATAL_ERROR "CPackComponentsForAll_BINARY_DIR not set" )
2012-08-13 21:50:14 +04:00
endif ( )
2010-12-03 00:56:26 +03:00
if ( NOT CPackGen )
message ( FATAL_ERROR "CPackGen not set" )
2012-08-13 21:50:14 +04:00
endif ( )
2012-11-29 02:01:25 +04:00
message ( "CMAKE_CPACK_COMMAND = ${CMAKE_CPACK_COMMAND}" )
if ( NOT CMAKE_CPACK_COMMAND )
message ( FATAL_ERROR "CMAKE_CPACK_COMMAND not set" )
2012-08-13 21:50:14 +04:00
endif ( )
2010-12-11 13:59:02 +03:00
if ( NOT CPackComponentWay )
message ( FATAL_ERROR "CPackComponentWay not set" )
2012-08-13 21:50:14 +04:00
endif ( )
2010-12-11 13:59:02 +03:00
2010-12-03 00:56:26 +03:00
set ( expected_file_mask "" )
2010-12-11 13:59:02 +03:00
# The usual default behavior is to expect a single file
2010-12-12 14:19:50 +03:00
# Then some specific generators (Archive, RPM, ...)
# May produce several numbers of files depending on
# CPACK_COMPONENT_xxx values
2010-12-11 13:59:02 +03:00
set ( expected_count 1 )
2010-12-14 21:42:21 +03:00
set ( config_type $ENV{ CMAKE_CONFIG_TYPE } )
set ( config_args )
if ( config_type )
set ( config_args -C ${ config_type } )
2012-08-13 21:50:14 +04:00
endif ( )
2011-03-10 11:48:46 +03:00
set ( config_verbose )
2010-12-12 14:19:50 +03:00
2010-12-03 00:56:26 +03:00
if ( CPackGen MATCHES "ZIP" )
set ( expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip" )
2010-12-11 13:59:02 +03:00
if ( ${ CPackComponentWay } STREQUAL "default" )
set ( expected_count 1 )
2011-03-23 20:28:05 +03:00
elseif ( ${ CPackComponentWay } STREQUAL "OnePackPerGroup" )
2011-03-03 23:19:13 +03:00
set ( expected_count 3 )
2011-03-23 20:28:05 +03:00
elseif ( ${ CPackComponentWay } STREQUAL "IgnoreGroup" )
2011-01-30 15:11:25 +03:00
set ( expected_count 4 )
2011-03-23 20:28:05 +03:00
elseif ( ${ CPackComponentWay } STREQUAL "AllInOne" )
2011-03-03 22:45:43 +03:00
set ( expected_count 1 )
2011-03-23 20:28:05 +03:00
endif ( )
2011-03-03 22:45:43 +03:00
elseif ( CPackGen MATCHES "RPM" )
2011-03-10 11:48:46 +03:00
set ( config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1" )
2011-03-03 22:45:43 +03:00
set ( expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm" )
if ( ${ CPackComponentWay } STREQUAL "default" )
set ( expected_count 1 )
2011-03-23 20:28:05 +03:00
elseif ( ${ CPackComponentWay } STREQUAL "OnePackPerGroup" )
set ( expected_count 3 )
elseif ( ${ CPackComponentWay } STREQUAL "IgnoreGroup" )
2011-03-03 22:45:43 +03:00
set ( expected_count 4 )
2011-03-23 20:28:05 +03:00
elseif ( ${ CPackComponentWay } STREQUAL "AllInOne" )
set ( expected_count 1 )
endif ( )
elseif ( CPackGen MATCHES "DEB" )
2016-05-10 16:40:48 +03:00
set ( expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2-1_*.deb" )
2011-03-23 20:28:05 +03:00
if ( ${ CPackComponentWay } STREQUAL "default" )
2011-01-30 15:11:25 +03:00
set ( expected_count 1 )
2011-03-23 20:28:05 +03:00
elseif ( ${ CPackComponentWay } STREQUAL "OnePackPerGroup" )
set ( expected_count 3 )
elseif ( ${ CPackComponentWay } STREQUAL "IgnoreGroup" )
set ( expected_count 4 )
elseif ( ${ CPackComponentWay } STREQUAL "AllInOne" )
2011-01-30 15:11:25 +03:00
set ( expected_count 1 )
2011-03-23 20:28:05 +03:00
endif ( )
endif ( )
2010-12-03 00:56:26 +03:00
2011-03-28 19:11:27 +04:00
if ( CPackGen MATCHES "DragNDrop" )
set ( expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.dmg" )
if ( ${ CPackComponentWay } STREQUAL "default" )
set ( expected_count 1 )
elseif ( ${ CPackComponentWay } STREQUAL "OnePackPerGroup" )
set ( expected_count 3 )
elseif ( ${ CPackComponentWay } STREQUAL "IgnoreGroup" )
set ( expected_count 4 )
elseif ( ${ CPackComponentWay } STREQUAL "AllInOne" )
set ( expected_count 1 )
endif ( )
2012-08-13 21:50:14 +04:00
endif ( )
2011-03-28 19:11:27 +04:00
2011-02-24 02:43:29 +03:00
# clean-up previously CPack generated files
if ( expected_file_mask )
file ( GLOB expected_file "${expected_file_mask}" )
if ( expected_file )
file ( REMOVE ${ expected_file } )
2012-08-13 21:50:14 +04:00
endif ( )
endif ( )
2011-02-24 02:43:29 +03:00
2011-03-10 11:48:46 +03:00
message ( "config_args = ${config_args}" )
message ( "config_verbose = ${config_verbose}" )
2012-11-29 02:01:25 +04:00
execute_process ( COMMAND ${ CMAKE_CPACK_COMMAND } ${ config_verbose } -G ${ CPackGen } ${ config_args }
2011-02-24 02:43:29 +03:00
R E S U L T _ V A R I A B L E C P a c k _ r e s u l t
O U T P U T _ V A R I A B L E C P a c k _ o u t p u t
E R R O R _ V A R I A B L E C P a c k _ e r r o r
W O R K I N G _ D I R E C T O R Y $ { C P a c k C o m p o n e n t s F o r A l l _ B I N A R Y _ D I R } )
if ( CPack_result )
message ( FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}" )
2012-08-13 21:50:14 +04:00
else ( )
2011-02-24 02:43:29 +03:00
message ( STATUS "CPack_output=${CPack_output}" )
2012-08-13 21:50:14 +04:00
endif ( )
2011-02-24 02:43:29 +03:00
2010-12-11 13:59:02 +03:00
# Now verify if the number of expected file is OK
# - using expected_file_mask and
# - expected_count
2010-12-03 00:56:26 +03:00
if ( expected_file_mask )
file ( GLOB expected_file "${expected_file_mask}" )
message ( STATUS "expected_count='${expected_count}'" )
message ( STATUS "expected_file='${expected_file}'" )
message ( STATUS "expected_file_mask='${expected_file_mask}'" )
if ( NOT expected_file )
2016-05-15 04:01:34 +03:00
message ( FATAL_ERROR "error: expected_file does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}" )
2012-08-13 21:50:14 +04:00
endif ( )
2010-12-03 00:56:26 +03:00
list ( LENGTH expected_file actual_count )
message ( STATUS "actual_count='${actual_count}'" )
if ( NOT actual_count EQUAL expected_count )
2010-12-13 00:35:18 +03:00
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})" )
2012-08-13 21:50:14 +04:00
endif ( )
endif ( )
2014-10-14 09:57:11 +04:00
# Validate content
if ( CPackGen MATCHES "RPM" )
find_program ( RPM_EXECUTABLE rpm )
if ( NOT RPM_EXECUTABLE )
message ( FATAL_ERROR "error: missing rpm executable required by the test" )
endif ( )
set ( CPACK_RPM_PACKAGE_SUMMARY "default summary" )
2016-02-13 04:09:32 +03:00
set ( CPACK_RPM_HEADERS_PACKAGE_SUMMARY "headers summary" )
set ( CPACK_RPM_HEADERS_PACKAGE_DESCRIPTION "headers description" )
2014-10-14 09:57:11 +04:00
set ( CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
" A n e x t r e m e l y u s e f u l a p p l i c a t i o n t h a t m a k e s u s e o f M y L i b " )
2015-03-17 00:10:18 +03:00
set ( CPACK_COMPONENT_LIBRARIES_DESCRIPTION
" S t a t i c l i b r a r i e s u s e d t o b u i l d p r o g r a m s w i t h M y L i b " )
2015-03-29 21:55:20 +03:00
set ( LIB_SUFFIX "6?4?" )
2014-10-14 09:57:11 +04:00
2015-01-07 22:33:27 +03:00
# test package info
2014-10-14 09:57:11 +04:00
if ( ${ CPackComponentWay } STREQUAL "IgnoreGroup" )
2015-01-21 02:29:46 +03:00
# set gnu install prefixes to what they are set during rpm creation
# CMAKE_SIZEOF_VOID_P is not set here but lib is prefix of lib64 so
# relocation path test won't fail on OSes with lib64 library location
include ( GNUInstallDirs )
2015-02-27 02:33:48 +03:00
set ( CPACK_PACKAGING_INSTALL_PREFIX "/usr/foo/bar" )
2015-01-21 02:29:46 +03:00
2014-10-14 09:57:11 +04:00
foreach ( check_file ${ expected_file } )
string ( REGEX MATCH ".*libraries.*" check_file_libraries_match ${ check_file } )
string ( REGEX MATCH ".*headers.*" check_file_headers_match ${ check_file } )
string ( REGEX MATCH ".*applications.*" check_file_applications_match ${ check_file } )
string ( REGEX MATCH ".*Unspecified.*" check_file_Unspecified_match ${ check_file } )
execute_process ( COMMAND ${ RPM_EXECUTABLE } -pqi ${ check_file }
O U T P U T _ V A R I A B L E c h e c k _ f i l e _ c o n t e n t
E R R O R _ Q U I E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
2015-03-15 23:08:19 +03:00
execute_process ( COMMAND ${ RPM_EXECUTABLE } -pqa ${ check_file }
R E S U L T _ V A R I A B L E c h e c k _ p a c k a g e _ a r c h i t e c t u r e _ r e s u l t
O U T P U T _ V A R I A B L E c h e c k _ p a c k a g e _ a r c h i t e c t u r e
E R R O R _ Q U I E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
2015-02-27 02:33:48 +03:00
execute_process ( COMMAND ${ RPM_EXECUTABLE } -pql ${ check_file }
O U T P U T _ V A R I A B L E c h e c k _ p a c k a g e _ c o n t e n t
E R R O R _ Q U I E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
2015-03-15 22:37:16 +03:00
set ( whitespaces "[\\t\\n\\r ]*" )
2014-10-14 09:57:11 +04:00
if ( check_file_libraries_match )
2015-03-17 00:10:18 +03:00
set ( check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*" )
set ( check_file_match_expected_description ".*${CPACK_COMPONENT_LIBRARIES_DESCRIPTION}.*" )
2015-03-29 21:55:20 +03:00
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" )
2015-03-15 23:08:19 +03:00
set ( check_file_match_expected_architecture "" ) # we don't explicitly set this value so it is different on each platform - ignore it
2015-01-21 02:29:46 +03:00
set ( spec_regex "*libraries*" )
2015-03-29 21:55:20 +03:00
set ( check_content_list " ^/usr/foo/bar/lib ${ LIB_SUFFIX }
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e / d e p t h _ t w o
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e / d e p t h _ t w o / d e p t h _ t h r e e
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e / d e p t h _ t w o / d e p t h _ t h r e e / s y m l i n k _ p a r e n t d i r _ p a t h
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e / d e p t h _ t w o / s y m l i n k _ o u t s i d e _ p a c k a g e
2016-03-31 08:48:38 +03:00
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e / d e p t h _ t w o / s y m l i n k _ o u t s i d e _ w d r
2015-03-29 21:55:20 +03:00
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e / d e p t h _ t w o / s y m l i n k _ r e l o c a t a b l e _ s u b p a t h
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e / d e p t h _ t w o / s y m l i n k _ s a m e d i r _ p a t h
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e / d e p t h _ t w o / s y m l i n k _ s a m e d i r _ p a t h _ c u r r e n t _ d i r
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e / d e p t h _ t w o / s y m l i n k _ s a m e d i r _ p a t h _ l o n g e r
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ o n e / s y m l i n k _ s u b d i r _ p a t h
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ t w o
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ t w o / d e p t h _ t w o
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ t w o / d e p t h _ t w o / d i f f e r e n t _ r e l o c a t a b l e
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ t w o / d e p t h _ t w o / d i f f e r e n t _ r e l o c a t a b l e / b a r
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ t w o / d e p t h _ t w o / s y m l i n k _ o t h e r _ r e l o c a t a b l e _ p a t h
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / i n s i d e _ r e l o c a t a b l e _ t w o / d e p t h _ t w o / s y m l i n k _ t o _ n o n _ r e l o c a t a b l e _ p a t h
/ u s r / f o o / b a r / l i b $ { L I B _ S U F F I X } / l i b m y l i b . a
/ u s r / f o o / b a r / n o n _ r e l o c a t a b l e
/ u s r / f o o / b a r / n o n _ r e l o c a t a b l e / d e p t h _ t w o
/ u s r / f o o / b a r / n o n _ r e l o c a t a b l e / d e p t h _ t w o / s y m l i n k _ f r o m _ n o n _ r e l o c a t a b l e _ p a t h
/ u s r / f o o / b a r / o t h e r _ r e l o c a t a b l e
/ u s r / f o o / b a r / o t h e r _ r e l o c a t a b l e / d e p t h _ t w o $ " )
2014-10-14 09:57:11 +04:00
elseif ( check_file_headers_match )
2016-02-13 04:09:32 +03:00
set ( check_file_match_expected_summary ".*${CPACK_RPM_HEADERS_PACKAGE_SUMMARY}.*" )
set ( check_file_match_expected_description ".*${CPACK_RPM_HEADERS_PACKAGE_DESCRIPTION}.*" )
2015-03-15 22:37:16 +03:00
set ( check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}" )
2015-03-15 23:08:19 +03:00
set ( check_file_match_expected_architecture "noarch" )
2015-01-21 02:29:46 +03:00
set ( spec_regex "*headers*" )
2015-02-27 02:33:48 +03:00
set ( check_content_list "^/usr/foo/bar\n/usr/foo/bar/include\n/usr/foo/bar/include/mylib.h$" )
2014-10-14 09:57:11 +04:00
elseif ( check_file_applications_match )
set ( check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*" )
set ( check_file_match_expected_description ".*${CPACK_COMPONENT_APPLICATIONS_DESCRIPTION}.*" )
2015-03-29 21:55:20 +03:00
set ( check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" )
2015-03-15 23:08:19 +03:00
set ( check_file_match_expected_architecture "armv7hf" )
2015-01-21 02:29:46 +03:00
set ( spec_regex "*applications*" )
2015-03-29 21:55:20 +03:00
set ( check_content_list " ^/usr/foo/bar
/ u s r / f o o / b a r / b i n
/ u s r / f o o / b a r / b i n / m y l i b a p p $ " )
2014-10-14 09:57:11 +04:00
elseif ( check_file_Unspecified_match )
set ( check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*" )
set ( check_file_match_expected_description ".*DESCRIPTION.*" )
2015-03-15 22:37:16 +03:00
set ( check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" )
2015-03-15 23:08:19 +03:00
set ( check_file_match_expected_architecture "" ) # we don't explicitly set this value so it is different on each platform - ignore it
2015-01-21 02:29:46 +03:00
set ( spec_regex "*Unspecified*" )
2015-02-27 02:33:48 +03:00
set ( check_content_list " ^/usr/foo/bar
/ u s r / f o o / b a r / b i n
2015-02-27 02:36:25 +03:00
/ u s r / f o o / b a r / b i n / @ i n @ _ @ p a t h @ @ w i t h
/ u s r / f o o / b a r / b i n / @ i n @ _ @ p a t h @ @ w i t h / @ a n d
/ u s r / f o o / b a r / b i n / @ i n @ _ @ p a t h @ @ w i t h / @ a n d / @
/ u s r / f o o / b a r / b i n / @ i n @ _ @ p a t h @ @ w i t h / @ a n d / @ / @ i n _ p a t h @
2015-04-19 19:22:18 +03:00
/ u s r / f o o / b a r / b i n / @ i n @ _ @ p a t h @ @ w i t h / @ a n d / @ / @ i n _ p a t h @ / m y l i b a p p 2
/ u s r / f o o / b a r / s h a r e
/ u s r / f o o / b a r / s h a r e / m a n
/ u s r / f o o / b a r / s h a r e / m a n / m y l i b
/ u s r / f o o / b a r / s h a r e / m a n / m y l i b / m a n 3
/ u s r / f o o / b a r / s h a r e / m a n / m y l i b / m a n 3 / m y l i b . 1
/ u s r / f o o / b a r / s h a r e / m a n / m y l i b / m a n 3 / m y l i b . 1 / m y l i b
/ u s r / f o o / b a r / s h a r e / m a n / m y l i b / m a n 3 / m y l i b . 1 / m y l i b 2 $ " )
2014-10-14 09:57:11 +04:00
else ( )
message ( FATAL_ERROR "error: unexpected rpm package '${check_file}'" )
endif ( )
2015-02-27 02:33:48 +03:00
#######################
# test package info
#######################
2014-10-14 09:57:11 +04:00
string ( REGEX MATCH ${ check_file_match_expected_summary } check_file_match_summary ${ check_file_content } )
if ( NOT check_file_match_summary )
2015-01-21 02:29:46 +03:00
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}'" )
2014-10-14 09:57:11 +04:00
endif ( )
string ( REGEX MATCH ${ check_file_match_expected_description } check_file_match_description ${ check_file_content } )
if ( NOT check_file_match_description )
2015-01-21 02:29:46 +03:00
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}'" )
endif ( )
string ( REGEX MATCH ${ check_file_match_expected_relocation_path } check_file_match_relocation_path ${ check_file_content } )
if ( NOT check_file_match_relocation_path )
file ( GLOB_RECURSE spec_file "${CPackComponentsForAll_BINARY_DIR}/${spec_regex}.spec" )
if ( spec_file )
file ( READ ${ spec_file } spec_file_content )
endif ( )
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}'" )
2014-10-14 09:57:11 +04:00
endif ( )
2015-02-27 02:33:48 +03:00
2015-03-15 23:08:19 +03:00
#######################
# test package architecture
#######################
string ( REGEX MATCH "Architecture${whitespaces}:" check_info_contains_arch ${ check_file_content } )
if ( check_info_contains_arch ) # test for rpm versions that contain architecture in package info (e.g. 4.11.x)
string ( REGEX MATCH "Architecture${whitespaces}:${whitespaces}${check_file_match_expected_architecture}" check_file_match_architecture ${ check_file_content } )
if ( NOT check_file_match_architecture )
2015-02-19 11:01:16 +03:00
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}'" )
2015-03-15 23:08:19 +03:00
endif ( )
elseif ( NOT check_package_architecture_result ) # test result only on platforms that support -pqa rpm query
# test for rpm versions that do not contain architecture in package info (e.g. 4.8.x)
string ( REGEX MATCH ".*${check_file_match_expected_architecture}" check_file_match_architecture "${check_package_architecture}" )
if ( NOT check_file_match_architecture )
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}'" )
endif ( )
# else rpm version too old (e.g. 4.4.x) - skip test
2015-02-27 16:42:29 +03:00
endif ( )
2015-02-27 02:33:48 +03:00
#######################
# test package content
#######################
string ( REGEX MATCH "${check_content_list}" expected_content_list "${check_package_content}" )
if ( NOT expected_content_list )
file ( GLOB_RECURSE spec_file "${CPackComponentsForAll_BINARY_DIR}/${spec_regex}.spec" )
if ( spec_file )
file ( READ ${ spec_file } spec_file_content )
endif ( )
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}'" )
2015-02-19 11:01:16 +03:00
endif ( )
2016-03-29 01:51:18 +03:00
# validate permissions user and group
execute_process ( COMMAND ${ RPM_EXECUTABLE } -pqlv ${ check_file }
O U T P U T _ V A R I A B L E c h e c k _ f i l e _ c o n t e n t
E R R O R _ Q U I E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
if ( check_file_libraries_match )
set ( check_file_match_expected_permissions ".*-rwx------.*user.*defgrp.*" )
elseif ( check_file_headers_match )
set ( check_file_match_expected_permissions ".*-rwxr--r--.*defusr.*defgrp.*" )
elseif ( check_file_applications_match )
set ( check_file_match_expected_permissions ".*-rwxr--r--.*defusr.*group.*" )
elseif ( check_file_Unspecified_match )
set ( check_file_match_expected_permissions ".*-rwxr--r--.*defusr.*defgrp.*" )
else ( )
message ( FATAL_ERROR "error: unexpected rpm package '${check_file}'" )
endif ( )
string ( REGEX MATCH "${check_file_match_expected_permissions}" check_file_match_permissions "${check_file_content}" )
if ( NOT check_file_match_permissions )
message ( FATAL_ERROR "error: '${check_file}' rpm package permissions do not match expected value - regex '${check_file_match_expected_permissions}'" )
endif ( )
2014-10-14 09:57:11 +04:00
endforeach ( )
2015-03-29 21:55:20 +03:00
#######################
# verify generated symbolic links
#######################
file ( GLOB_RECURSE symlink_files RELATIVE "${CPackComponentsForAll_BINARY_DIR}" "${CPackComponentsForAll_BINARY_DIR}/*/symlink_*" )
foreach ( check_symlink IN LISTS symlink_files )
get_filename_component ( symlink_name "${check_symlink}" NAME )
execute_process ( COMMAND ls -la "${check_symlink}"
W O R K I N G _ D I R E C T O R Y " $ { C P a c k C o m p o n e n t s F o r A l l _ B I N A R Y _ D I R } "
O U T P U T _ V A R I A B L E S Y M L I N K _ P O I N T _
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
if ( "${symlink_name}" STREQUAL "symlink_samedir_path"
O R " $ { s y m l i n k _ n a m e } " S T R E Q U A L " s y m l i n k _ s a m e d i r _ p a t h _ c u r r e n t _ d i r "
O R " $ { s y m l i n k _ n a m e } " S T R E Q U A L " s y m l i n k _ s a m e d i r _ p a t h _ l o n g e r " )
string ( REGEX MATCH "^.*${whitespaces}->${whitespaces}depth_three$" check_symlink "${SYMLINK_POINT_}" )
elseif ( "${symlink_name}" STREQUAL "symlink_subdir_path" )
string ( REGEX MATCH "^.*${whitespaces}->${whitespaces}depth_two/depth_three$" check_symlink "${SYMLINK_POINT_}" )
elseif ( "${symlink_name}" STREQUAL "symlink_parentdir_path" )
string ( REGEX MATCH "^.*${whitespaces}->${whitespaces}../$" check_symlink "${SYMLINK_POINT_}" )
elseif ( "${symlink_name}" STREQUAL "symlink_to_non_relocatable_path" )
string ( REGEX MATCH "^.*${whitespaces}->${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/non_relocatable/depth_two$" check_symlink "${SYMLINK_POINT_}" )
elseif ( "${symlink_name}" STREQUAL "symlink_outside_package" )
string ( REGEX MATCH "^.*${whitespaces}->${whitespaces}outside_package$" check_symlink "${SYMLINK_POINT_}" )
2016-03-31 08:48:38 +03:00
elseif ( "${symlink_name}" STREQUAL "symlink_outside_wdr" )
string ( REGEX MATCH "^.*${whitespaces}->${whitespaces}/outside_package_wdr$" check_symlink "${SYMLINK_POINT_}" )
2015-03-29 21:55:20 +03:00
elseif ( "${symlink_name}" STREQUAL "symlink_other_relocatable_path"
O R " $ { s y m l i n k _ n a m e } " S T R E Q U A L " s y m l i n k _ f r o m _ n o n _ r e l o c a t a b l e _ p a t h "
O R " $ { s y m l i n k _ n a m e } " S T R E Q U A L " s y m l i n k _ r e l o c a t a b l e _ s u b p a t h " )
# these links were not canged - post install script only - ignore them
else ( )
message ( FATAL_ERROR "error: unexpected rpm symbolic link '${check_symlink}'" )
endif ( )
if ( NOT check_symlink )
message ( FATAL_ERROR "symlink points to unexpected location '${SYMLINK_POINT_}'" )
endif ( )
endforeach ( )
# verify post install symlink relocation script
file ( GLOB_RECURSE spec_file "${CPackComponentsForAll_BINARY_DIR}/*libraries*.spec" )
file ( READ ${ spec_file } spec_file_content )
file ( READ "${CMAKE_CURRENT_LIST_DIR}/symlink_postinstall_expected.txt" symlink_postinstall_expected )
# prepare regex
string ( STRIP "${symlink_postinstall_expected}" symlink_postinstall_expected )
string ( REPLACE "[" "\\[" symlink_postinstall_expected "${symlink_postinstall_expected}" )
string ( REPLACE "$" "\\$" symlink_postinstall_expected "${symlink_postinstall_expected}" )
string ( REPLACE "lib" "lib${LIB_SUFFIX}" symlink_postinstall_expected "${symlink_postinstall_expected}" )
# compare
string ( REGEX MATCH ".*${symlink_postinstall_expected}.*" symlink_postinstall_expected_matches "${spec_file_content}" )
if ( NOT symlink_postinstall_expected_matches )
message ( FATAL_ERROR "error: unexpected rpm symbolic link postinstall script! generated spec file: '${spec_file_content}'" )
endif ( )
2014-10-14 09:57:11 +04:00
endif ( )
endif ( )
2015-03-29 21:55:20 +03:00
cmake_policy ( POP )