Message was sent to early by accident so I'm resending the rest.

2014-10-14 0:17 GMT+02:00 Domen Vrankar <[email protected]>:

> Hi,
>
> I extended the proposed patch for ticket 13176 with:
> - documentation section
> - CPACK_RPM_<component>_PACKAGE_DESCRIPTION fallback to
> CPACK_COMPONENT_<compName>_DESCRIPTION
> - handling of cases when one component sets its variable and the other
> doesn't
>

e.g.
#set(CPACK_RPM_test_PACKAGE_SUMMARY "test_summary")
set(CPACK_RPM_bin_PACKAGE_SUMMARY "bin_summary")

Could somebody please review the patch attached to this mail?


>
> Regards,
> Domen
>
From 41332720a9f4988590e465c4ae300be658fee888 Mon Sep 17 00:00:00 2001
From: Domen Vrankar <[email protected]>
Date: Tue, 14 Oct 2014 00:06:39 +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 | 63 +++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 49 insertions(+), 14 deletions(-)

diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index 2864b21..137e4e6 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,27 @@ set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACK
 #
 
 # CPACK_RPM_PACKAGE_SUMMARY (mandatory)
-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)
+
+# 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_)
+
+#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(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()
-    set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
+    # if neither var is defined lets use the name as summary
+    string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY_)
   endif()
 endif()
 
@@ -508,12 +526,29 @@ 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_)
+
+#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
@@ -982,7 +1017,7 @@ if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY
    file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in
       "# -*- rpm-spec -*-
 BuildRoot:      \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@
-Summary:        \@CPACK_RPM_PACKAGE_SUMMARY\@
+Summary:        \@CPACK_RPM_PACKAGE_SUMMARY_\@
 Name:           \@CPACK_RPM_PACKAGE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_NAME\@
 Version:        \@CPACK_RPM_PACKAGE_VERSION\@
 Release:        \@CPACK_RPM_PACKAGE_RELEASE\@
@@ -1009,7 +1044,7 @@ Vendor:         \@CPACK_RPM_PACKAGE_VENDOR\@
 \@CPACK_RPM_COMPRESSION_TYPE_TMP\@
 
 %description
-\@CPACK_RPM_PACKAGE_DESCRIPTION\@
+\@CPACK_RPM_PACKAGE_DESCRIPTION_\@
 
 # This is a shortcutted spec file generated by CMake RPM generator
 # we skip _install step because CPack does that for us.
-- 
2.1.0

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to