From 5b0a64ebc5d03a4dd0022b87e8e6cb77c3db013b Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Fri, 23 Dec 2016 21:01:38 +0100 Subject: CPack/Archive minimal tests for more formats --- Tests/RunCMake/CMakeLists.txt | 2 +- Tests/RunCMake/CPack/7Z/Helpers.cmake | 3 ++ Tests/RunCMake/CPack/7Z/Prerequirements.cmake | 4 ++ .../CPack/7Z/packaging_COMPONENT_default.cmake | 1 + .../CPack/ArchiveCommon/common_helpers.cmake | 62 +++++++++++++++++++++ Tests/RunCMake/CPack/RunCMakeTest.cmake | 2 +- Tests/RunCMake/CPack/TBZ2/Helpers.cmake | 3 ++ Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake | 4 ++ .../CPack/TBZ2/packaging_COMPONENT_default.cmake | 1 + Tests/RunCMake/CPack/TGZ/Helpers.cmake | 63 +--------------------- Tests/RunCMake/CPack/TXZ/Helpers.cmake | 3 ++ Tests/RunCMake/CPack/TXZ/Prerequirements.cmake | 4 ++ .../CPack/TXZ/packaging_COMPONENT_default.cmake | 1 + Tests/RunCMake/CPack/TZ/Helpers.cmake | 3 ++ Tests/RunCMake/CPack/TZ/Prerequirements.cmake | 4 ++ .../CPack/TZ/packaging_COMPONENT_default.cmake | 1 + Tests/RunCMake/CPack/ZIP/Helpers.cmake | 3 ++ Tests/RunCMake/CPack/ZIP/Prerequirements.cmake | 4 ++ .../CPack/ZIP/packaging_COMPONENT_default.cmake | 1 + Tests/RunCMake/CPack/tests/MINIMAL/test.cmake | 4 ++ 20 files changed, 110 insertions(+), 63 deletions(-) create mode 100644 Tests/RunCMake/CPack/7Z/Helpers.cmake create mode 100644 Tests/RunCMake/CPack/7Z/Prerequirements.cmake create mode 100644 Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake create mode 100644 Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake create mode 100644 Tests/RunCMake/CPack/TBZ2/Helpers.cmake create mode 100644 Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake create mode 100644 Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake create mode 100644 Tests/RunCMake/CPack/TXZ/Helpers.cmake create mode 100644 Tests/RunCMake/CPack/TXZ/Prerequirements.cmake create mode 100644 Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake create mode 100644 Tests/RunCMake/CPack/TZ/Helpers.cmake create mode 100644 Tests/RunCMake/CPack/TZ/Prerequirements.cmake create mode 100644 Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake create mode 100644 Tests/RunCMake/CPack/ZIP/Helpers.cmake create mode 100644 Tests/RunCMake/CPack/ZIP/Prerequirements.cmake create mode 100644 Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index adfd37d..d2465c4 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -345,7 +345,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") add_RunCMake_test(CompilerLauncher) endif() -add_RunCMake_test_group(CPack "DEB;RPM;TGZ") +add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used add_RunCMake_test(AutoExportDll) diff --git a/Tests/RunCMake/CPack/7Z/Helpers.cmake b/Tests/RunCMake/CPack/7Z/Helpers.cmake new file mode 100644 index 0000000..f256a42 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "7z") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/7Z/Prerequirements.cmake b/Tests/RunCMake/CPack/7Z/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake new file mode 100644 index 0000000..ce039f5 --- /dev/null +++ b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake @@ -0,0 +1,62 @@ +set(ALL_FILES_GLOB "*.${cpack_archive_extension_}") + +function(getPackageContent FILE RESULT_VAR) + # TODO for some types this only works because libarchive handles it... (not + # part of for e.g. gnu tar) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xtf ${FILE} + OUTPUT_VARIABLE package_content_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + set(${RESULT_VAR} + "${NAME}-${VERSION}-*${COMPONENT}.${cpack_archive_extension_}" PARENT_SCOPE) +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + getPackageContent("${FILE}" package_content_) + + string(REPLACE "\n" ";" package_content_ "${package_content_}") + foreach(i_ IN LISTS package_content_) + string(REGEX REPLACE "/$" "" result_ "${i_}") + list(APPEND items_ "${result_}") + endforeach() + + set(${RESULT_VAR} "${items_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + findExpectedFile("${FILE_NO}" "file_") + + # component and monolithic packages differ for some reason by either having + # package filename prefix in path or not + if(PACKAGING_TYPE STREQUAL "MONOLITHIC") + get_filename_component(prefix_ "${file_}" NAME) + # NAME_WE removes everything after the dot and dot is in version so replace instead + string(REPLACE ".${cpack_archive_extension_}" "/" prefix_ "${prefix_}") + else() + unset(prefix_) + endif() + + if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) + set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") + endif() + + unset(filtered_) + foreach(part_ IN LISTS ${CONTENT_VAR}) + string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") + + if(part_) + list(APPEND filtered_ "${prefix_}${part_}") + endif() + endforeach() + + set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 3077340..7a83bf2 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -15,7 +15,7 @@ run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT") run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT") run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC") run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT") -run_cpack_test(MINIMAL "RPM;DEB;TGZ" false "MONOLITHIC") +run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP" false "MONOLITHIC") run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC") run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT") run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT") diff --git a/Tests/RunCMake/CPack/TBZ2/Helpers.cmake b/Tests/RunCMake/CPack/TBZ2/Helpers.cmake new file mode 100644 index 0000000..292b691 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.bz2") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake b/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/TGZ/Helpers.cmake b/Tests/RunCMake/CPack/TGZ/Helpers.cmake index 4a194c6..4357a59 100644 --- a/Tests/RunCMake/CPack/TGZ/Helpers.cmake +++ b/Tests/RunCMake/CPack/TGZ/Helpers.cmake @@ -1,62 +1,3 @@ -set(ALL_FILES_GLOB "*.tar.gz") +set(cpack_archive_extension_ "tar.gz") -function(getPackageContent FILE RESULT_VAR) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar -ztvf ${FILE} - OUTPUT_VARIABLE package_content_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) -endfunction() - -function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) - if(COMPONENT) - set(COMPONENT "-${COMPONENT}") - endif() - - set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.tar.gz" PARENT_SCOPE) -endfunction() - -function(getPackageContentList FILE RESULT_VAR) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar -ztf ${FILE} - OUTPUT_VARIABLE package_content_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - string(REPLACE "\n" ";" package_content_ "${package_content_}") - foreach(i_ IN LISTS package_content_) - string(REGEX REPLACE "/$" "" result_ "${i_}") - list(APPEND items_ "${result_}") - endforeach() - - set(${RESULT_VAR} "${items_}" PARENT_SCOPE) -endfunction() - -function(toExpectedContentList FILE_NO CONTENT_VAR) - findExpectedFile("${FILE_NO}" "file_") - - # component and monolithic packages differ for some reason by either having - # package filename prefix in path or not - if(PACKAGING_TYPE STREQUAL "MONOLITHIC") - get_filename_component(prefix_ "${file_}" NAME) - # NAME_WE removes everything after the dot and dot is in version so replace instead - string(REPLACE ".tar.gz" "/" prefix_ "${prefix_}") - else() - unset(prefix_) - endif() - - if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) - set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") - endif() - - unset(filtered_) - foreach(part_ IN LISTS ${CONTENT_VAR}) - string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") - - if(part_) - list(APPEND filtered_ "${prefix_}${part_}") - endif() - endforeach() - - set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) -endfunction() +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TXZ/Helpers.cmake b/Tests/RunCMake/CPack/TXZ/Helpers.cmake new file mode 100644 index 0000000..f390cb4 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.xz") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake b/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/TZ/Helpers.cmake b/Tests/RunCMake/CPack/TZ/Helpers.cmake new file mode 100644 index 0000000..117cd24 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.Z") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TZ/Prerequirements.cmake b/Tests/RunCMake/CPack/TZ/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/ZIP/Helpers.cmake b/Tests/RunCMake/CPack/ZIP/Helpers.cmake new file mode 100644 index 0000000..3710bcf --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "zip") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake b/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake b/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake index 83ed0f2..15c5892 100644 --- a/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake +++ b/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake @@ -1 +1,5 @@ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() -- cgit v0.12 From 05c14ea0a97f3e8a7287f3e0bbc57f91e2a6e490 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Fri, 23 Dec 2016 21:03:05 +0100 Subject: RunCMake.CPack_* add COMPONENT to minimal test Add component based packages testing to current monolithic minimal package tests. --- Tests/RunCMake/CPack/RunCMakeTest.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 7a83bf2..ea6d96b 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -15,7 +15,7 @@ run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT") run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT") run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC") run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT") -run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP" false "MONOLITHIC") +run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC") run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT") run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT") -- cgit v0.12 From 36bc7e4c3f91c560df8051afedddea3f49474264 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Sun, 25 Dec 2016 10:51:34 +0100 Subject: store old locale to a temporary variable On Windows XP 32 bit setLocale seems to cause old pointer invalidation and causes program crash in destructor. This was causing CPackZIP to crash so to fix it we copy the value into a temporary variable. --- Source/cmLocale.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmLocale.h b/Source/cmLocale.h index e8e751d..cca7cf5 100644 --- a/Source/cmLocale.h +++ b/Source/cmLocale.h @@ -6,10 +6,11 @@ #include #include +#include class cmLocaleRAII { - const char* OldLocale; + std::string OldLocale; public: cmLocaleRAII() @@ -17,7 +18,7 @@ public: { setlocale(LC_CTYPE, ""); } - ~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale); } + ~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale.c_str()); } }; #endif -- cgit v0.12