[cmake-developers] [CMake 0011944]: CPackDeb: Support dependencies between components/Debian packages
Raffi Enficiaud
raffi.enficiaud at mines-paris.org
Tue Apr 21 10:41:37 EDT 2015
Le 21/04/15 14:36, Raffi Enficiaud a écrit :
> Le 18/04/15 09:58, Raffi Enficiaud a écrit :
>> Le 18/04/15 09:34, Domen Vrankar a écrit :
>>>
>>> The way you implemented it you are not covering the case:
>>> 1) CPACK_DEBIAN_PACKAGE_DESCRIPTION no set
>>> 2) CPACK_DEBIAN_PACKAGE_DESCRIPTION is set with component description
>>> 3) next component doesn't set per component description so
>>> CPACK_DEBIAN_PACKAGE_DESCRIPTION is not reset and description of the
>>> previous component is used
>>>
>>> Or if 1) would be set and 3 not set you would loose the initial
>>> description
>>
>> Ok. I worked essentially on having the tests kind of functional. I will
>> add the cases you mentioned in new tests.
>>
>
> Please find attached the patch that allows a description per component.
> I believe I created a test covering the issue you mentioned above.
>
>
> Raffi
>
>
>
Please find attached the patch that enables the setting of the
dependency discovery per-component. This patch is based on the previous
one (description per component), but is rather independent. The next
patch, dependency per component, will depend on the changes made by the
attached patch.
Best,
Raffi
-------------- next part --------------
>From 618ce62aa9c9a53b1091452031c84d01c19ed45c Mon Sep 17 00:00:00 2001
From: Raffi Enficiaud <raffi.enficiaud at tuebingen.mpg.de>
Date: Tue, 21 Apr 2015 16:37:00 +0200
Subject: [PATCH] CPackDEB: Enabling the dependency auto-discovery per
component
---
Modules/CPackDeb.cmake | 26 ++++++++
Tests/CMakeLists.txt | 1 +
...kConfig-splitted-components-shlibdeps1.cmake.in | 24 ++++++++
...rifyResult-splitted-components-shlibdeps1.cmake | 70 ++++++++++++++++++++++
4 files changed, 121 insertions(+)
create mode 100644 Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-shlibdeps1.cmake.in
create mode 100644 Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-shlibdeps1.cmake
diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
index 1a1270e..acdb82c 100644
--- a/Modules/CPackDeb.cmake
+++ b/Modules/CPackDeb.cmake
@@ -114,6 +114,15 @@
# may fail to find your own shared libs.
# See http://www.cmake.org/Wiki/CMake_RPATH_handling.
#
+# .. variable:: CPACK_DEBIAN_<comp>_PACKAGE_SHLIBDEPS
+#
+# * Mandatory : NO
+# * Default : CPACK_DEBIAN_PACKAGE_SHLIBDEPS
+#
+# Same as `CPACK_DEBIAN_PACKAGE_SHLIBDEPS` but for one specific component.
+# If set (either to ON or OFF) it overrides the default given by
+# `CPACK_DEBIAN_PACKAGE_SHLIBDEPS`.
+#
# .. variable:: CPACK_DEBIAN_PACKAGE_DEBUG
#
# * Mandatory : NO
@@ -245,6 +254,23 @@ function(cpack_deb_prepare_package_vars)
set(CPACK_DEBIAN_FAKEROOT_EXECUTABLE ${FAKEROOT_EXECUTABLE})
endif()
+
+ # per component automatic discover: some of the component might not have
+ # binaries.
+ if(CPACK_DEB_PACKAGE_COMPONENT)
+ string(TOUPPER ${CPACK_DEB_PACKAGE_COMPONENT} _local_component_name)
+ set(_component_shlibdeps_var CPACK_DEBIAN_${_local_component_name}_PACKAGE_SHLIBDEPS)
+
+ # if set, overrides the global configuration
+ if(DEFINED ${_component_shlibdeps_var})
+ set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ${${_component_shlibdeps_var}})
+ if(CPACK_DEBIAN_PACKAGE_DEBUG)
+ message("CPackDeb Debug: component '${CPACK_DEB_PACKAGE_COMPONENT}' dpkg-shlibdeps set to ${CPACK_DEBIAN_PACKAGE_SHLIBDEPS}")
+ endif()
+ endif()
+ endif()
+
+
if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
# dpkg-shlibdeps is a Debian utility for generating dependency list
find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps)
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 2adb7e7..35683b5 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1011,6 +1011,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
set(DEB_CONFIGURATIONS_TO_TEST "splitted-components-lintian-dpkgdeb-checks"
"splitted-components-description1"
"splitted-components-description2"
+ "splitted-components-shlibdeps1"
)
set(CPackGen DEB)
set(CPackRun_CPackGen "-DCPackGen=${CPackGen}")
diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-shlibdeps1.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-shlibdeps1.cmake.in
new file mode 100644
index 0000000..cfe6df5
--- /dev/null
+++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-shlibdeps1.cmake.in
@@ -0,0 +1,24 @@
+#
+# Activate component packaging
+#
+
+if(CPACK_GENERATOR MATCHES "DEB")
+ set(CPACK_DEB_COMPONENT_INSTALL "ON")
+endif()
+
+#
+# Choose grouping way
+#
+#set(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE)
+#set(CPACK_COMPONENTS_GROUPING)
+set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
+#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
+
+# we set shlibdeps to on
+set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
+# except for the component "headers" that do not contain any binary.
+# the packaging will just fail if this does not work
+set(CPACK_DEBIAN_HEADERS_PACKAGE_SHLIBDEPS OFF)
+
+# Also libraries contains only a static library.
+set(CPACK_DEBIAN_LIBRARIES_PACKAGE_SHLIBDEPS OFF)
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-shlibdeps1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-shlibdeps1.cmake
new file mode 100644
index 0000000..19fe8ca
--- /dev/null
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-shlibdeps1.cmake
@@ -0,0 +1,70 @@
+if(NOT CPackComponentsDEB_SOURCE_DIR)
+ message(FATAL_ERROR "CPackComponentsDEB_SOURCE_DIR not set")
+endif()
+
+include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
+
+
+
+# requirements
+
+# debian now produces lower case names
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
+set(expected_count 3)
+
+
+set(actual_output)
+run_cpack(actual_output
+ CPack_output
+ CPack_error
+ EXPECTED_FILE_MASK "${expected_file_mask}"
+ CONFIG_ARGS ${config_args}
+ CONFIG_VERBOSE ${config_verbose})
+
+message(STATUS "expected_count='${expected_count}'")
+message(STATUS "expected_file_mask='${expected_file_mask}'")
+message(STATUS "actual_output_files='${actual_output}'")
+
+if(NOT actual_output)
+ message(FATAL_ERROR "error: expected_files do not exist: CPackComponentsDEB test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}")
+endif()
+
+list(LENGTH actual_output actual_count)
+message(STATUS "actual_count='${actual_count}'")
+if(NOT actual_count EQUAL expected_count)
+ message(FATAL_ERROR "error: expected_count=${expected_count} does not match actual_count=${actual_count}: CPackComponents test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error})")
+endif()
+
+
+# dpkg-deb checks for the summary of the packages
+set(dpkgdeb_output_errors_all)
+foreach(_f IN LISTS actual_output)
+
+ # extracts the metadata from the package
+ run_dpkgdeb(dpkg_output
+ FILENAME ${_f}
+ )
+
+ dpkgdeb_return_specific_metaentry(dpkg_package_name
+ DPKGDEB_OUTPUT "${dpkg_output}"
+ METAENTRY "Package:")
+
+ message(STATUS "package='${dpkg_package_name}'")
+
+ if(${dpkg_package_name} STREQUAL "mylib-applications")
+ # pass
+ elseif(${dpkg_package_name} STREQUAL "mylib-headers")
+ # pass
+ elseif(${dpkg_package_name} STREQUAL "mylib-libraries")
+ # pass
+ else()
+ set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
+ "dpkg-deb: ${_f}: component name not found: ${dpkg_package_name}\n")
+ endif()
+
+endforeach()
+
+
+if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
+ message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
+endif()
--
2.0.1
More information about the cmake-developers
mailing list