diff options
author | Domen Vrankar <domen.vrankar@gmail.com> | 2017-11-08 19:25:29 (GMT) |
---|---|---|
committer | Domen Vrankar <domen.vrankar@gmail.com> | 2017-11-08 19:27:11 (GMT) |
commit | 7e896029cd6bc0a19b7e0ed6fa7b876e0f1764b3 (patch) | |
tree | b1deb87df7b92e2a623f111b4cb8893629f0714e /Tests | |
parent | a4c829167dc8fa24e151d2afde7896b4588b24ad (diff) | |
download | CMake-7e896029cd6bc0a19b7e0ed6fa7b876e0f1764b3.zip CMake-7e896029cd6bc0a19b7e0ed6fa7b876e0f1764b3.tar.gz CMake-7e896029cd6bc0a19b7e0ed6fa7b876e0f1764b3.tar.bz2 |
CPack: enable setting default dir creation permissions
Introduces CPACK_DEFAULT_DIRECTORY_INSTALL_PERMISSIONS
variable which adds support for functionality introduced
by CMAKE_DEFAULT_DIRECTORY_INSTALL_PERMISSIONS variable.
Fixes #17333
# Conflicts:
# Help/release/dev/cmake-default-dir-install-permissions.rst
Diffstat (limited to 'Tests')
6 files changed, 82 insertions, 0 deletions
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index b00e373..4b7f146 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -7,6 +7,7 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM" false "MONOLITHIC;COMPONENT") run_cpack_test(CUSTOM_NAMES "RPM;DEB;TGZ" true "COMPONENT") run_cpack_test(DEBUGINFO "RPM" true "COMPONENT") +run_cpack_test_subtests(DEFAULT_PERMISSIONS "CMAKE_var_set;CPACK_var_set;both_set;invalid_CMAKE_var;invalid_CPACK_var" "RPM;DEB" false "MONOLITHIC;COMPONENT") run_cpack_test(DEPENDENCIES "RPM;DEB" true "COMPONENT") run_cpack_test(DIST "RPM" false "MONOLITHIC") run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/ExpectedFiles.cmake new file mode 100644 index 0000000..9b8205b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/ExpectedFiles.cmake @@ -0,0 +1,6 @@ +if(${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid_.*_var") + set(EXPECTED_FILES_COUNT "0") +else() + set(EXPECTED_FILES_COUNT "1") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +endif() diff --git a/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/VerifyResult.cmake new file mode 100644 index 0000000..16ebcdc --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/VerifyResult.cmake @@ -0,0 +1,39 @@ +if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid_.*_var") + if(GENERATOR_TYPE STREQUAL "RPM") + function(checkContentPermissions_ FILE REGEX) + execute_process(COMMAND ${RPM_EXECUTABLE} -qp --dump ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE PERMISSIONS_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT PERMISSIONS_ MATCHES "${REGEX}") + message(FATAL_ERROR "Permissions in '${FILE}'. Permissions: '${PERMISSIONS_}'") + endif() + endfunction() + + if(${RunCMake_SUBTEST_SUFFIX} MATCHES "CMAKE_var_set") + checkContentPermissions_("${FOUND_FILE_1}" + "/usr/foo .*740 root root.*") + else() + checkContentPermissions_("${FOUND_FILE_1}" + "/usr/foo .*700 root root.*") + endif() + else() # DEB + function(checkContentPermissions_ FILE REGEX) + getPackageContent("${FILE}" PERMISSIONS_) + + if(NOT PERMISSIONS_ MATCHES "${REGEX}") + message(FATAL_ERROR "Permissions in '${FILE}'. Permissions: '${PERMISSIONS_}'") + endif() + endfunction() + + if(${RunCMake_SUBTEST_SUFFIX} MATCHES "CMAKE_var_set") + checkContentPermissions_("${FOUND_FILE_1}" + "drwxr----- root/root .* ./usr/\ndrwxr----- root/root .* ./usr/foo/\n.*") + else() + checkContentPermissions_("${FOUND_FILE_1}" + "drwx------ root/root .* ./usr/\ndrwx------ root/root .* ./usr/foo/\n.*") + endif() + endif() +endif() diff --git a/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CMAKE_var-stderr.txt b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CMAKE_var-stderr.txt new file mode 100644 index 0000000..541763a --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CMAKE_var-stderr.txt @@ -0,0 +1 @@ +.*CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS value is invalid.* diff --git a/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CPACK_var-stderr.txt b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CPACK_var-stderr.txt new file mode 100644 index 0000000..541763a --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CPACK_var-stderr.txt @@ -0,0 +1 @@ +.*CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS value is invalid.* diff --git a/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/test.cmake b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/test.cmake new file mode 100644 index 0000000..afe9390 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/test.cmake @@ -0,0 +1,34 @@ +if(${RunCMake_SUBTEST_SUFFIX} MATCHES "CMAKE_var_set" OR + ${RunCMake_SUBTEST_SUFFIX} MATCHES "both_set") + + set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS + OWNER_READ + OWNER_WRITE + OWNER_EXECUTE + GROUP_READ + ) +endif() + +if(${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid_CMAKE_var") + list(APPEND CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS "INVALID") +endif() + +if(${RunCMake_SUBTEST_SUFFIX} MATCHES "CPACK_var_set" OR + ${RunCMake_SUBTEST_SUFFIX} MATCHES "both_set") + + set(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS + OWNER_READ + OWNER_WRITE + OWNER_EXECUTE + ) +endif() + +if(${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid_CPACK_var") + list(APPEND CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS "INVALID") +endif() + +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() |