Commit 53be31e1 authored by Alex Turbov's avatar Alex Turbov

Refactor: Use `list` commands instead of old-way string ops

parent b2c67a77
......@@ -210,7 +210,7 @@ function(cpack_deb_prepare_package_vars)
if(_TMP_VERSION MATCHES "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)")
set(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
else()
set(SHLIBDEPS_EXECUTABLE_VERSION "")
unset(SHLIBDEPS_EXECUTABLE_VERSION)
endif()
if(CPACK_DEBIAN_PACKAGE_DEBUG)
......@@ -388,7 +388,7 @@ function(cpack_deb_prepare_package_vars)
# if per-component variable, overrides the global CPACK_DEBIAN_PACKAGE_${variable_type_}
# automatic dependency discovery will be performed afterwards.
if(CPACK_DEB_PACKAGE_COMPONENT)
foreach(value_type_ DEPENDS RECOMMENDS SUGGESTS PREDEPENDS ENHANCES BREAKS CONFLICTS PROVIDES REPLACES SOURCE SECTION PRIORITY NAME)
foreach(value_type_ IN ITEMS DEPENDS RECOMMENDS SUGGESTS PREDEPENDS ENHANCES BREAKS CONFLICTS PROVIDES REPLACES SOURCE SECTION PRIORITY NAME)
set(_component_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_${value_type_}")
# if set, overrides the global variable
......@@ -402,21 +402,15 @@ function(cpack_deb_prepare_package_vars)
endforeach()
if(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS)
set(COMPONENT_DEPENDS "")
foreach(_PACK ${CPACK_COMPONENT_${_local_component_name}_DEPENDS})
unset(COMPONENT_DEPENDS)
foreach(_PACK IN LISTS CPACK_COMPONENT_${_local_component_name}_DEPENDS)
get_component_package_name(_PACK_NAME "${_PACK}")
if(COMPONENT_DEPENDS)
set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION}), ${COMPONENT_DEPENDS}")
else()
set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})")
endif()
list(PREPEND COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})")
endforeach()
list(JOIN COMPONENT_DEPENDS ", " COMPONENT_DEPENDS)
if(COMPONENT_DEPENDS)
if(CPACK_DEBIAN_PACKAGE_DEPENDS)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}")
else()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}")
endif()
list(PREPEND CPACK_DEBIAN_PACKAGE_DEPENDS ${COMPONENT_DEPENDS})
list(JOIN CPACK_DEBIAN_PACKAGE_DEPENDS ", " CPACK_DEBIAN_PACKAGE_DEPENDS)
endif()
endif()
endif()
......@@ -424,12 +418,9 @@ function(cpack_deb_prepare_package_vars)
# at this point, the CPACK_DEBIAN_PACKAGE_DEPENDS is properly set
# to the minimal dependency of the package
# Append automatically discovered dependencies .
if(NOT "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}" STREQUAL "")
if(CPACK_DEBIAN_PACKAGE_DEPENDS)
set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
else()
set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
endif()
if(CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS)
list(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS})
list(JOIN CPACK_DEBIAN_PACKAGE_DEPENDS ", " CPACK_DEBIAN_PACKAGE_DEPENDS)
endif()
if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
......@@ -519,7 +510,7 @@ function(cpack_deb_prepare_package_vars)
# Are we packaging components ?
if(CPACK_DEB_PACKAGE_COMPONENT)
# override values with per component version if set
foreach(VAR_NAME_ "PACKAGE_CONTROL_EXTRA" "PACKAGE_CONTROL_STRICT_PERMISSION")
foreach(VAR_NAME_ IN ITEMS PACKAGE_CONTROL_EXTRA PACKAGE_CONTROL_STRICT_PERMISSION)
if(CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_})
set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}")
endif()
......@@ -527,12 +518,12 @@ function(cpack_deb_prepare_package_vars)
get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name})
endif()
set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "")
if(NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=")
endif()
unset(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
if(READELF_EXECUTABLE)
foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES)
......@@ -544,9 +535,7 @@ function(cpack_deb_prepare_package_vars)
message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.")
endif()
endforeach()
if(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
string(REPLACE ";" "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}")
endif()
list(JOIN CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
else()
message(FATAL_ERROR "Readelf utility is not available. CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS option is not available.")
endif()
......@@ -554,7 +543,7 @@ function(cpack_deb_prepare_package_vars)
# add ldconfig call in default postrm and postint
set(CPACK_ADD_LDCONFIG_CALL 0)
foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES)
get_filename_component(_DIR ${_FILE} DIRECTORY)
# all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning
if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib")
......@@ -565,12 +554,12 @@ function(cpack_deb_prepare_package_vars)
if(CPACK_ADD_LDCONFIG_CALL)
set(CPACK_DEBIAN_GENERATE_POSTINST 1)
set(CPACK_DEBIAN_GENERATE_POSTRM 1)
foreach(f ${PACKAGE_CONTROL_EXTRA})
foreach(f IN LISTS PACKAGE_CONTROL_EXTRA)
get_filename_component(n "${f}" NAME)
if("${n}" STREQUAL "postinst")
if(n STREQUAL "postinst")
set(CPACK_DEBIAN_GENERATE_POSTINST 0)
endif()
if("${n}" STREQUAL "postrm")
if(n STREQUAL "postrm")
set(CPACK_DEBIAN_GENERATE_POSTRM 0)
endif()
endforeach()
......@@ -671,7 +660,7 @@ function(cpack_deb_prepare_package_vars)
if(BUILD_IDS)
set(GEN_DBGSYMDIR "${DBGSYMDIR}" PARENT_SCOPE)
set(GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME "${CPACK_DBGSYM_OUTPUT_FILE_NAME}" PARENT_SCOPE)
string(REPLACE ";" " " BUILD_IDS "${BUILD_IDS}")
list(JOIN BUILD_IDS " " BUILD_IDS)
set(GEN_BUILD_IDS "${BUILD_IDS}" PARENT_SCOPE)
endif()
endfunction()
......
Markdown is supported
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