[cmake-developers] [CMake 0011944]: CPackDeb: Support dependencies between components/Debian packages

Raffi Enficiaud raffi.enficiaud at mines-paris.org
Tue Apr 21 08:36:08 EDT 2015


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

-------------- next part --------------
>From 204f02edc5ac330053becb45fbec3b2ec5f2f535 Mon Sep 17 00:00:00 2001
From: Raffi Enficiaud <raffi.enficiaud at tuebingen.mpg.de>
Date: Tue, 21 Apr 2015 14:30:43 +0200
Subject: [PATCH] Enabling the description per components

---
 Modules/CPackDeb.cmake                             | 37 ++++++++--
 Tests/CMakeLists.txt                               |  5 +-
 ...onfig-splitted-components-description1.cmake.in | 25 +++++++
 ...onfig-splitted-components-description2.cmake.in | 29 ++++++++
 ...fyResult-splitted-components-description1.cmake | 83 ++++++++++++++++++++++
 ...fyResult-splitted-components-description2.cmake | 83 ++++++++++++++++++++++
 6 files changed, 257 insertions(+), 5 deletions(-)
 create mode 100644 Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-description1.cmake.in
 create mode 100644 Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-description2.cmake.in
 create mode 100644 Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-description1.cmake
 create mode 100644 Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-description2.cmake

diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
index f248a67..1a1270e 100644
--- a/Modules/CPackDeb.cmake
+++ b/Modules/CPackDeb.cmake
@@ -62,6 +62,16 @@
 #
 #  The debian package description
 #
+# .. variable:: CPACK_COMPONENT_<COMP>_DESCRIPTION
+#
+#  * Mandatory : NO
+#  * Default   : CPACK_DEBIAN_PACKAGE_DESCRIPTION
+#
+#  The debian package description for a specific component 'COMP'.
+#  This description has priority over the other descriptions given by
+#  :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` and
+#  :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`.
+#
 # .. variable:: CPACK_DEBIAN_PACKAGE_SECTION
 #
 #  * Mandatory : YES
@@ -379,11 +389,30 @@ function(cpack_deb_prepare_package_vars)
   endif()
 
   # Description: (mandatory)
-  if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
-    if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
-      message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
+  if(NOT CPACK_DEB_PACKAGE_COMPONENT)
+    if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
+      if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+        message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
+      endif()
+      set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
+    endif()
+  else()
+    string(TOUPPER ${CPACK_DEB_PACKAGE_COMPONENT} _local_component_name)
+    set(component_description_var CPACK_COMPONENT_${_local_component_name}_DESCRIPTION)
+    
+    # component description overrides package description
+    if(${component_description_var})
+      set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${${component_description_var}})
+    elseif(CPACK_DEBIAN_PACKAGE_DESCRIPTION)
+      # do nothing
+    else()
+      if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+        message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION
+                 or ${component_description_var}")
+      endif()
+      set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
     endif()
-    set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
+      
   endif()
 
   # Section: (recommended)
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 8145d91..2adb7e7 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1008,7 +1008,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
     if(DPKG_EXECUTABLE)
         set(CPackRun_CPackDEBConfiguration_ALL_CONFIGS)
         set(DEB_TEST_NAMES CPackComponentsDEB)
-        set(DEB_CONFIGURATIONS_TO_TEST "splitted-components-lintian-dpkgdeb-checks")
+        set(DEB_CONFIGURATIONS_TO_TEST "splitted-components-lintian-dpkgdeb-checks"
+                                       "splitted-components-description1"
+                                       "splitted-components-description2"
+                                       )
         set(CPackGen DEB)
         set(CPackRun_CPackGen "-DCPackGen=${CPackGen}")
 
diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-description1.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-description1.cmake.in
new file mode 100644
index 0000000..857e19d
--- /dev/null
+++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-description1.cmake.in
@@ -0,0 +1,25 @@
+#
+# 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)
+
+# overriding previous descriptions
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY           "main description")
+set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION    "applications_description")
+set(CPACK_COMPONENT_HEADERS_DESCRIPTION         "headers_description")
+# libraries does not have any description and should inherit from CPACK_PACKAGE_DESCRIPTION_SUMMARY
+unset(CPACK_COMPONENT_LIBRARIES_DESCRIPTION)
+
+
+
diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-description2.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-description2.cmake.in
new file mode 100644
index 0000000..329189a
--- /dev/null
+++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-splitted-components-description2.cmake.in
@@ -0,0 +1,29 @@
+#
+# 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)
+
+# overriding previous descriptions
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY           "main description 2")
+
+# Components do not have any description
+unset(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION)
+unset(CPACK_COMPONENT_HEADERS_DESCRIPTION)
+unset(CPACK_COMPONENT_LIBRARIES_DESCRIPTION)
+
+
+set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION       "library description")
+
+
+
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-description1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-description1.cmake
new file mode 100644
index 0000000..bd46986
--- /dev/null
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-description1.cmake
@@ -0,0 +1,83 @@
+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:")
+
+  dpkgdeb_return_specific_metaentry(dpkg_description
+                                    DPKGDEB_OUTPUT "${dpkg_output}"
+                                    METAENTRY "Description:")
+
+  message(STATUS "package='${dpkg_package_name}', description='${dpkg_description}'")
+
+  if(${dpkg_package_name} STREQUAL "mylib-applications")
+    if(NOT ${dpkg_description} STREQUAL "applications_description")
+      set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
+                                    "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != applications_description")
+    endif()
+  elseif(${dpkg_package_name} STREQUAL "mylib-headers")
+    if(NOT ${dpkg_description} STREQUAL "headers_description")
+      set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
+                                    "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != headers_description")
+    endif()
+  elseif(${dpkg_package_name} STREQUAL "mylib-libraries")
+    if(NOT ${dpkg_description} STREQUAL "main description")
+      set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
+                                    "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != 'main description'")
+    endif()
+  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()
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-description2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-description2.cmake
new file mode 100644
index 0000000..5cf81ef
--- /dev/null
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-splitted-components-description2.cmake
@@ -0,0 +1,83 @@
+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:")
+
+  dpkgdeb_return_specific_metaentry(dpkg_description
+                                    DPKGDEB_OUTPUT "${dpkg_output}"
+                                    METAENTRY "Description:")
+
+  message(STATUS "package='${dpkg_package_name}', description='${dpkg_description}'")
+
+  if(${dpkg_package_name} STREQUAL "mylib-applications")
+    if(NOT ${dpkg_description} STREQUAL "main description 2")
+      set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
+                                    "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != applications_description")
+    endif()
+  elseif(${dpkg_package_name} STREQUAL "mylib-headers")
+    if(NOT ${dpkg_description} STREQUAL "main description 2")
+      set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
+                                    "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != headers_description")
+    endif()
+  elseif(${dpkg_package_name} STREQUAL "mylib-libraries")
+    if(NOT ${dpkg_description} STREQUAL "library description")
+      set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
+                                    "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != 'main description'")
+    endif()
+  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