diff options
author | Domen Vrankar <domen.vrankar@gmail.com> | 2016-05-10 13:40:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-13 14:46:05 (GMT) |
commit | 7e940bf74ab3496b0d89a55cf7c48dc1b15bc8ce (patch) | |
tree | ed31100dd5f82df26f2650a53f478ad0bbd5d91e /Tests/RunCMake/CPack/DEB | |
parent | 3b648894366f86c94d4567811acb9549a81660ec (diff) | |
download | CMake-7e940bf74ab3496b0d89a55cf7c48dc1b15bc8ce.zip CMake-7e940bf74ab3496b0d89a55cf7c48dc1b15bc8ce.tar.gz CMake-7e940bf74ab3496b0d89a55cf7c48dc1b15bc8ce.tar.bz2 |
CPack/Deb test changes due to breaking changes
New CPack/Deb tests and changes to old tests
as package file names and inter component dependency
detection was changed.
Diffstat (limited to 'Tests/RunCMake/CPack/DEB')
13 files changed, 125 insertions, 16 deletions
diff --git a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake index 5adca68..62f2f9c 100644 --- a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake @@ -1,5 +1,5 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "components_empty_dir*.deb") +set(EXPECTED_FILE_1 "components_empty_dir-test_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake index 2ff679a..4531a34 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake @@ -1,9 +1,9 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "deb_extra-*-foo.deb") +set(EXPECTED_FILE_1 "deb_extra-foo_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "deb_extra-*-bar.deb") +set(EXPECTED_FILE_2 "deb_extra-bar_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_2 "^.*/usr/${whitespaces_}.*/usr/bar/${whitespaces_}.*/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_3 "deb_extra-*-bas.deb") +set(EXPECTED_FILE_3 "deb_extra-bas_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_3 "^.*/usr/${whitespaces_}.*/usr/bas/${whitespaces_}.*/usr/bas/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake new file mode 100644 index 0000000..a8efb61 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake @@ -0,0 +1,6 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_1 "generate_shlibs_0.1.1-1_*.deb") +# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it +set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake new file mode 100644 index 0000000..b98065a --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake @@ -0,0 +1,7 @@ +function(get_test_prerequirements found_var) + find_program(READELF_EXECUTABLE NAMES readelf) + + if(READELF_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake new file mode 100644 index 0000000..8ccb628 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake @@ -0,0 +1,3 @@ +set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$") +set(shlibs_shlibs_permissions_regex "-rw-r--r-- .*") +verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake new file mode 100644 index 0000000..9a9dee3 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake @@ -0,0 +1,6 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_1 "generate_shlibs_ldconfig_0.1.1-1_*.deb") +# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it +set(EXPECTED_FILE_CONTENT_1 "^.*/usr/lib${whitespaces_}.*/usr/lib/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake new file mode 100644 index 0000000..b98065a --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake @@ -0,0 +1,7 @@ +function(get_test_prerequirements found_var) + find_program(READELF_EXECUTABLE NAMES readelf) + + if(READELF_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake new file mode 100644 index 0000000..d04c641 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake @@ -0,0 +1,7 @@ +set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs_ldconfig \\(>\\= 0\\.1\\.1\\)\n$") +set(shlibs_shlibs_permissions_regex "-rw-r--r-- .*") +set(shlibs_postinst ".*ldconfig.*") +set(shlibs_postinst_permissions_regex "-rwxr-xr-x .*") +set(shlibs_postrm ".*ldconfig.*") +set(shlibs_postrm_permissions_regex "-rwxr-xr-x .*") +verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs;postinst;postrm") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake index c56c670..c182e30 100644 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake @@ -1,14 +1,14 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "5") -set(EXPECTED_FILE_1 "dependencies*-applications.deb") +set(EXPECTED_FILE_1 "dependencies-applications_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$") -set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb") +set(EXPECTED_FILE_2 "dependencies-applications_auto_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$") -set(EXPECTED_FILE_3 "dependencies*-headers.deb") +set(EXPECTED_FILE_3 "dependencies-headers_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_4 "dependencies*-libs.deb") +set(EXPECTED_FILE_4 "dependencies-libs_0.1.1-1_*.deb") # dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$") -set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb") +set(EXPECTED_FILE_5 "dependencies-libs_auto_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake index 1552a36..6dc5906 100644 --- a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake @@ -1,5 +1,5 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "empty_dir*.deb") +set(EXPECTED_FILE_1 "empty_dir_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$") diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index f490130..d05f115 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -1,7 +1,7 @@ set(ALL_FILES_GLOB "*.deb") function(getPackageContent FILE RESULT_VAR) - execute_process(COMMAND ${DPKG_EXECUTABLE} -c ${FILE} + execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}" OUTPUT_VARIABLE package_content_ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -9,8 +9,73 @@ function(getPackageContent FILE RESULT_VAR) set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) endfunction() +function(getMissingShlibsErrorExtra FILE RESULT_VAR) + execute_process(COMMAND ${DPKG_EXECUTABLE} -x "${FILE}" data_${PREFIX} + ERROR_VARIABLE err_) + + if(err_) + set(error_extra " Extra: Could not unpack package content: '${err}'") + else() + cmake_policy(PUSH) + # Tell file(GLOB_RECURSE) not to follow directory symlinks + # even if the project does not set this policy to NEW. + cmake_policy(SET CMP0009 NEW) + file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/data_${PREFIX}/*") + cmake_policy(POP) + + # get file info so that we can determine if file is executable or not + foreach(FILE_ IN LISTS FILE_PATHS_) + execute_process(COMMAND file "${FILE_}" + WORKING_DIRECTORY "${WDIR}" + OUTPUT_VARIABLE INSTALL_FILE_ + ERROR_VARIABLE err_) + + if(NOT err_) + list(APPEND deb_install_files "${INSTALL_FILE_}") + else() + list(APPEND deb_install_files_errors "'${FILE_}': '${err_}'\n") + endif() + endforeach() + + set(error_extra " Extra: install files '${deb_install_files}'") + + if(deb_install_files_errors) + set(error_extra "${error_extra}; errors \"${deb_install_files_errors}\"") + endif() + + find_program(READELF_EXECUTABLE NAMES readelf) + + if(READELF_EXECUTABLE) + set(error_extra "${error_extra}; readelf \"\n") + + # Only dynamically linked ELF files are included + # Extract only file name infront of ":" + foreach(_FILE IN LISTS deb_install_files) + if(_FILE MATCHES "ELF.*shared object") + string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}") + + execute_process(COMMAND ${READELF_EXECUTABLE} -d "${CMAKE_MATCH_1}" + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE err_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(error_extra "${error_extra} name '${CMAKE_MATCH_1}'\n result '${result}'\n output '${output}'\n error '${err_}'\n") + endif() + endforeach() + + set(error_extra "${error_extra}\"") + else() + set(error_extra "${error_extra}; error readelf missing") + endif() + endif() + + set(${RESULT_VAR} "${error_extra}" PARENT_SCOPE) +endfunction() + function(verifyDebControl FILE PREFIX VERIFY_FILES) - execute_process(COMMAND ${DPKG_EXECUTABLE} --control ${FILE} control_${PREFIX} + execute_process(COMMAND ${DPKG_EXECUTABLE} --control "${FILE}" control_${PREFIX} ERROR_VARIABLE err_) if(err_) @@ -19,6 +84,14 @@ function(verifyDebControl FILE PREFIX VERIFY_FILES) endif() foreach(FILE_ IN LISTS VERIFY_FILES) + if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}") + if(FILE_ STREQUAL "shlibs") + getMissingShlibsErrorExtra("${FILE}" error_extra) + endif() + + message(FATAL_ERROR "Expected Debian control file does not exist: '${FILE_}'${error_extra}") + endif() + file(READ "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}" content_) if(NOT content_ MATCHES "${${PREFIX}_${FILE_}}") message(FATAL_ERROR "Unexpected content in for '${PREFIX}_${FILE_}'!" diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake index 9e4aa7c..648c866 100644 --- a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake @@ -1,5 +1,5 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "minimal*.deb") +set(EXPECTED_FILE_1 "minimal_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake index 1f6c11b..40f6730 100644 --- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake @@ -1,9 +1,9 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "per_component*-pkg_1.deb") +set(EXPECTED_FILE_1 "per_component-pkg_1_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "per_component*-pkg_2.deb") +set(EXPECTED_FILE_2 "second_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_3 "per_component*-pkg_3.deb") +set(EXPECTED_FILE_3 "per_component-pkg_3_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_3 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") |