Commit e22dbdb7 authored by Brad King's avatar Brad King 💬 Committed by Kitware Robot
Browse files

Merge topic 'cpack-rpm-extra-slash-in-path'

598400a3

 CPack/RPM: handle extra slashes
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !583
parents a5931b61 598400a3
......@@ -958,10 +958,20 @@ function(cpack_rpm_prepare_relocation_paths)
foreach(RELOCATION_PATH ${RPM_RELOCATION_PATHS})
if(IS_ABSOLUTE "${RELOCATION_PATH}")
set(PREPARED_RELOCATION_PATH "${RELOCATION_PATH}")
elseif(PATH_PREFIX STREQUAL "/")
# don't prefix path with a second slash as "//" is treated as network path
# by get_filename_component() so it remains in path even inside rpm
# package where it may cause problems with relocation
set(PREPARED_RELOCATION_PATH "/${RELOCATION_PATH}")
else()
set(PREPARED_RELOCATION_PATH "${PATH_PREFIX}/${RELOCATION_PATH}")
endif()
# handle cases where path contains extra slashes (e.g. /a//b/ instead of
# /a/b)
get_filename_component(PREPARED_RELOCATION_PATH
"${PREPARED_RELOCATION_PATH}" ABSOLUTE)
if(EXISTS "${WDIR}/${PREPARED_RELOCATION_PATH}")
string(APPEND TMP_RPM_PREFIXES "Prefix: ${PREPARED_RELOCATION_PATH}\n")
list(APPEND RPM_USED_PACKAGE_PREFIXES "${PREPARED_RELOCATION_PATH}")
......@@ -2130,6 +2140,11 @@ function(cpack_rpm_generate_package)
set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}")
endif()
# handle cases where path contains extra slashes (e.g. /a//b/ instead of
# /a/b)
get_filename_component(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
"${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}" ABSOLUTE)
if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS)
file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.files"
"${CPACK_RPM_INSTALL_FILES}")
......
......@@ -21,6 +21,7 @@ run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;
run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT")
run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT")
run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM" true "CUSTOM")
run_cpack_test(EXTRA_SLASH_IN_PATH "RPM" true "COMPONENT")
run_cpack_source_test(SOURCE_PACKAGE "RPM")
run_cpack_test(SUGGESTS "RPM" false "MONOLITHIC")
run_cpack_test(USER_FILELIST "RPM" false "MONOLITHIC")
......
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "5")
set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE)
set(EXPECTED_FILE_1_COMPONENT "applications")
set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog")
set(EXPECTED_FILE_2 "extra_slash_in_path*-headers.rpm")
set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt")
set(EXPECTED_FILE_3 "extra_slash_in_path*-libs.rpm")
set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so")
set(EXPECTED_FILE_4_COMPONENT "applications-debuginfo")
set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*")
set(EXPECTED_FILE_5_COMPONENT "libs-debuginfo")
set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*")
# check that relocation path is /foo and not //foo
getPackageInfo("${FOUND_FILE_1}" "FILE_INFO_")
set(whitespaces_ "[\t\n\r ]*")
if(NOT FILE_INFO_ MATCHES "Relocations${whitespaces_}:${whitespaces_}/${whitespaces_}/foo")
message(FATAL_ERROR "Unexpected relocation path in file '${FOUND_FILE_1}';"
" file info: '${FILE_INFO_}'")
endif()
set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
# PGI compiler doesn't add build id to binaries by default
if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI")
string(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,--build-id")
string(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id")
endif()
set(CMAKE_BUILD_TYPE Debug)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
"int test_lib();\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
"#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n")
add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
"#include \"test_lib.hpp\"\nint main() {return test_lib();}\n")
add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
target_link_libraries(test_prog test_lib)
install(TARGETS test_prog DESTINATION foo COMPONENT applications)
install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers)
install(TARGETS test_lib DESTINATION bas COMPONENT libs)
set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_APPLICATIONS_DEBUGINFO_PACKAGE ON)
set(CPACK_RPM_LIBS_DEBUGINFO_PACKAGE ON)
# extra trailing slash at the end that should be removed
set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/src/")
# combination should not cause //foo to apper as an relocation path
# should be only /foo (extra slashes cause path comparisons to fail)
set(CPACK_PACKAGING_INSTALL_PREFIX "/")
# extra trailing slash at the end that should be removed
set(CPACK_RPM_RELOCATION_PATHS "foo/")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment