Description | CPackRPM supports per-component configuration, to a certain extent.
It can build many rpm's from one project, and these rpm's may have different require/obsolete, and prein/etc scripts.
But they all have the same summary and description.
One might expect CPACK_RPM_<component>_PACKAGE_SUMMARY and CPACK_RPM_<component>_PACKAGE_DESCRIPTION to work, but they don't.
Alternatively, CPackRPM could use CPACK_COMPONENT_<component>_DESCRIPTION, which may be less intuitive, but might allow better code reuse (in CMakeLists.txt) and less copy-pasting.
|
Attached Files | CPackRPM_component_summary_description.patch [^] (1,284 bytes) 2014-05-05 21:45 [Show Content] [Hide Content]diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index 2864b21..81ddccf 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -430,6 +430,14 @@ set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACK
#
# CPACK_RPM_PACKAGE_SUMMARY (mandatory)
+#Check for component description first.
+#If not set, it will use regular package summary logic.
+if(CPACK_RPM_PACKAGE_COMPONENT)
+ if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY)
+ set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY})
+ endif()
+endif()
+
if(NOT CPACK_RPM_PACKAGE_SUMMARY)
# if neither var is defined lets use the name as summary
if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
@@ -508,6 +516,14 @@ endif()
# if it is defined
# - set to a default value
#
+
+#Check for a component description first
+if(CPACK_RPM_PACKAGE_COMPONENT)
+ if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION)
+ set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION})
+ endif()
+endif()
+
if (NOT CPACK_RPM_PACKAGE_DESCRIPTION)
if (CPACK_PACKAGE_DESCRIPTION_FILE)
file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION)
0001-CPackRPM-component-based-packaging-description-and-s.patch [^] (5,040 bytes) 2014-10-14 03:51 [Show Content] [Hide Content]From 5c229cd048086f3d6413ade0ba0e317c869036f8 Mon Sep 17 00:00:00 2001
From: Domen Vrankar <domen.vrankar@gmail.com>
Date: Tue, 14 Oct 2014 07:57:11 +0200
Subject: [PATCH] CPackRPM component based packaging description and summary
Enables per component description and summary setting through
CPACK_RPM_<component>_PACKAGE_DESCRIPTION,
CPACK_COMPONENT_<compName>_DESCRIPTION
and CPACK_RPM_<component>_PACKAGE_SUMMARY variables
---
Modules/CPackRPM.cmake | 77 ++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 66 insertions(+), 11 deletions(-)
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index 2864b21..bab5c83 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -29,6 +29,7 @@
# However as a handy reminder here comes the list of specific variables:
#
# .. variable:: CPACK_RPM_PACKAGE_SUMMARY
+# CPACK_RPM_<component>_PACKAGE_SUMMARY
#
# The RPM package summary.
#
@@ -100,11 +101,13 @@
# * Default : -
#
# .. variable:: CPACK_RPM_PACKAGE_DESCRIPTION
+# CPACK_RPM_<component>_PACKAGE_DESCRIPTION
#
# RPM package description.
#
# * Mandatory : YES
-# * Default : CPACK_PACKAGE_DESCRIPTION_FILE if set or "no package
+# * Default : CPACK_COMPONENT_<compName>_DESCRIPTION (component based installers
+# only) if set, CPACK_PACKAGE_DESCRIPTION_FILE if set or "no package
# description available"
#
# .. variable:: CPACK_RPM_COMPRESSION_TYPE
@@ -430,12 +433,31 @@ set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACK
#
# CPACK_RPM_PACKAGE_SUMMARY (mandatory)
+
+# CPACK_RPM_PACKAGE_SUMMARY_ is used only locally so that it can be unset each time before use otherwise
+# component packaging could leak variable content between components
+unset(CPACK_RPM_PACKAGE_SUMMARY_)
+if(CPACK_RPM_PACKAGE_SUMMARY)
+ set(CPACK_RPM_PACKAGE_SUMMARY_ ${CPACK_RPM_PACKAGE_SUMMARY})
+ unset(CPACK_RPM_PACKAGE_SUMMARY)
+endif()
+
+#Check for component summary first.
+#If not set, it will use regular package summary logic.
+if(CPACK_RPM_PACKAGE_COMPONENT)
+ if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY)
+ set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY})
+ endif()
+endif()
+
if(NOT CPACK_RPM_PACKAGE_SUMMARY)
- # if neither var is defined lets use the name as summary
- if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
- string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY)
- else()
+ if(CPACK_RPM_PACKAGE_SUMMARY_)
+ set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_PACKAGE_SUMMARY_})
+ elseif(CPACK_PACKAGE_DESCRIPTION_SUMMARY)
set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
+ else()
+ # if neither var is defined lets use the name as summary
+ string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY)
endif()
endif()
@@ -508,12 +530,33 @@ endif()
# if it is defined
# - set to a default value
#
-if (NOT CPACK_RPM_PACKAGE_DESCRIPTION)
- if (CPACK_PACKAGE_DESCRIPTION_FILE)
- file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION)
- else ()
- set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available")
- endif ()
+
+# CPACK_RPM_PACKAGE_DESCRIPTION_ is used only locally so that it can be unset each time before use otherwise
+# component packaging could leak variable content between components
+unset(CPACK_RPM_PACKAGE_DESCRIPTION_)
+if(CPACK_RPM_PACKAGE_DESCRIPTION)
+ set(CPACK_RPM_PACKAGE_DESCRIPTION_ ${CPACK_RPM_PACKAGE_DESCRIPTION})
+ unset(CPACK_RPM_PACKAGE_DESCRIPTION)
+endif()
+
+#Check for a component description first.
+#If not set, it will use regular package description logic.
+if(CPACK_RPM_PACKAGE_COMPONENT)
+ if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION)
+ set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION})
+ elseif(CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT}_DESCRIPTION)
+ set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT}_DESCRIPTION})
+ endif()
+endif()
+
+if(NOT CPACK_RPM_PACKAGE_DESCRIPTION)
+ if(CPACK_RPM_PACKAGE_DESCRIPTION_)
+ set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_PACKAGE_DESCRIPTION_})
+ elseif(CPACK_PACKAGE_DESCRIPTION_FILE)
+ file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION)
+ else ()
+ set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available")
+ endif ()
endif ()
# CPACK_RPM_COMPRESSION_TYPE
@@ -1100,3 +1143,15 @@ else()
message(FATAL_ERROR "RPM packaging through alien not done (yet)")
endif()
endif()
+
+# reset variables from temporary variables
+if(CPACK_RPM_PACKAGE_SUMMARY_)
+ set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_PACKAGE_SUMMARY_})
+else()
+ unset(CPACK_RPM_PACKAGE_SUMMARY)
+endif()
+if(CPACK_RPM_PACKAGE_DESCRIPTION_)
+ set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_PACKAGE_DESCRIPTION_})
+else()
+ unset(CPACK_RPM_PACKAGE_DESCRIPTION)
+endif()
--
2.1.0
0001-add-added-semantic-tests-for-rpm-component-descripti.patch [^] (6,250 bytes) 2014-10-21 02:10 [Show Content] [Hide Content]From 649c27844659524d5cfdc8980781fb3e72ecb2a2 Mon Sep 17 00:00:00 2001
From: Domen Vrankar <domen.vrankar@gmail.com>
Date: Tue, 21 Oct 2014 07:55:10 +0200
Subject: [PATCH] -(add) semantic tests for rpm component description and
summary
-(fix) CPACK_COMPONENT_<compName>_DESCRIPTION compName must be in upper case
---
Modules/CPackRPM.cmake | 5 +-
.../MyLibCPackConfig-IgnoreGroup.cmake.in | 9 +++-
.../RunCPackVerifyResult.cmake | 59 ++++++++++++++++++++++
3 files changed, 70 insertions(+), 3 deletions(-)
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index bab5c83..e86cc98 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -417,6 +417,7 @@ endif()
# Are we packaging components ?
if(CPACK_RPM_PACKAGE_COMPONENT)
set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}")
+ string(TOUPPER ${CPACK_RPM_PACKAGE_COMPONENT} CPACK_RPM_PACKAGE_COMPONENT_UPPER)
else()
set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "")
endif()
@@ -544,8 +545,8 @@ endif()
if(CPACK_RPM_PACKAGE_COMPONENT)
if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION)
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION})
- elseif(CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT}_DESCRIPTION)
- set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT}_DESCRIPTION})
+ elseif(CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION)
+ set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION})
endif()
endif()
diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
index 450c204..8c01b32 100644
--- a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
+++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
@@ -8,6 +8,13 @@ endif()
if(CPACK_GENERATOR MATCHES "RPM")
set(CPACK_RPM_COMPONENT_INSTALL "ON")
set(CPACK_RPM_applications_PACKAGE_REQUIRES "mylib-libraries")
+
+ # test package summary override
+ set(CPACK_RPM_PACKAGE_SUMMARY "default summary")
+ set(CPACK_RPM_libraries_PACKAGE_SUMMARY "libraries summary")
+
+ # test package description override
+ set(CPACK_RPM_libraries_PACKAGE_DESCRIPTION "libraries description")
endif()
if(CPACK_GENERATOR MATCHES "DEB")
@@ -20,4 +27,4 @@ endif()
#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)
\ No newline at end of file
+#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
index 0b6d07d..4d56218 100644
--- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
+++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
@@ -123,3 +123,62 @@ if(expected_file_mask)
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()
endif()
+
+# Validate content
+if(CPackGen MATCHES "RPM")
+ find_program(RPM_EXECUTABLE rpm)
+ if(NOT RPM_EXECUTABLE)
+ message(FATAL_ERROR "error: missing rpm executable required by the test")
+ endif()
+
+ set(CPACK_RPM_PACKAGE_SUMMARY "default summary")
+ set(CPACK_RPM_libraries_PACKAGE_SUMMARY "libraries summary")
+ set(CPACK_RPM_libraries_PACKAGE_DESCRIPTION "libraries description")
+ set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
+ "An extremely useful application that makes use of MyLib")
+ set(CPACK_COMPONENT_HEADERS_DESCRIPTION
+ "C/C\\+\\+ header files for use with MyLib")
+
+ if(${CPackComponentWay} STREQUAL "IgnoreGroup")
+ foreach(check_file ${expected_file})
+ string(REGEX MATCH ".*libraries.*" check_file_libraries_match ${check_file})
+ string(REGEX MATCH ".*headers.*" check_file_headers_match ${check_file})
+ string(REGEX MATCH ".*applications.*" check_file_applications_match ${check_file})
+ string(REGEX MATCH ".*Unspecified.*" check_file_Unspecified_match ${check_file})
+
+ execute_process(COMMAND ${RPM_EXECUTABLE} -pqi ${check_file}
+ OUTPUT_VARIABLE check_file_content
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(check_file_libraries_match)
+ set(check_file_match_expected_summary ".*${CPACK_RPM_libraries_PACKAGE_SUMMARY}.*")
+ set(check_file_match_expected_description ".*${CPACK_RPM_libraries_PACKAGE_DESCRIPTION}.*")
+ elseif(check_file_headers_match)
+ set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
+ set(check_file_match_expected_description ".*${CPACK_COMPONENT_HEADERS_DESCRIPTION}.*")
+ elseif(check_file_applications_match)
+ set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
+ set(check_file_match_expected_description ".*${CPACK_COMPONENT_APPLICATIONS_DESCRIPTION}.*")
+ elseif(check_file_Unspecified_match)
+ set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
+ set(check_file_match_expected_description ".*DESCRIPTION.*")
+ else()
+ message(FATAL_ERROR "error: unexpected rpm package '${check_file}'")
+ endif()
+
+ string(REGEX MATCH ${check_file_match_expected_summary} check_file_match_summary ${check_file_content})
+
+ if(NOT check_file_match_summary)
+ message(FATAL_ERROR "error: '${check_file}' rpm package summary does not match expected value - regex '${check_file_match_expected_summary}'")
+ endif()
+
+ string(REGEX MATCH ${check_file_match_expected_description} check_file_match_description ${check_file_content})
+
+ if(NOT check_file_match_description)
+ message(FATAL_ERROR "error: '${check_file}' rpm package description does not match expected value - regex '${check_file_match_expected_description}'")
+ endif()
+ endforeach()
+ elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
+ endif()
+endif()
--
2.1.0
|