CPackRPM: Fix packaging in folders with ++ in name

Construct a regex that can match a path with special characters instead
of treating the path as a regex directly.

Fixes: #18967
This commit is contained in:
Harry Mallon
2019-02-22 11:58:42 +00:00
committed by Brad King
parent 63928f0868
commit d3ffe90598

View File

@@ -63,6 +63,11 @@ function(get_unix_permissions_octal_notation PERMISSIONS_VAR RETURN_VAR)
set(${RETURN_VAR} "${OWNER_PERMISSIONS}${GROUP_PERMISSIONS}${WORLD_PERMISSIONS}" PARENT_SCOPE)
endfunction()
function(cpack_rpm_exact_regex regex_var string)
string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" regex "${string}")
set("${regex_var}" "${regex}" PARENT_SCOPE)
endfunction()
function(cpack_rpm_prepare_relocation_paths)
# set appropriate prefix, remove possible trailing slash and convert backslashes to slashes
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX)
@@ -482,7 +487,9 @@ function(cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXE
# recalculate path length after conversion to canonical form
string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_)
if(SYMLINK_POINT_ MATCHES "${WDIR}/.*")
cpack_rpm_exact_regex(IN_SYMLINK_POINT_REGEX "${WDIR}")
string(APPEND IN_SYMLINK_POINT_REGEX "/.*")
if(SYMLINK_POINT_ MATCHES "${IN_SYMLINK_POINT_REGEX}")
# only symlinks that are pointing inside the packaging structure should be checked for relocation
string(SUBSTRING "${SYMLINK_POINT_}" ${WDR_LEN_} -1 SYMLINK_POINT_WD_)
cpack_rpm_symlink_get_relocation_prefixes("${F}" "${PACKAGE_PREFIXES}" "SYMLINK_RELOCATIONS")