The final patch version with erroneous spelling fixes.

2014-10-19 15:28 GMT+04:00 Micha Hergarden <micha.hergar...@gmail.com>:

>  On 10/09/2014 07:30 PM, Evgeny Kalishenko wrote:
>
> Ok, thanks for the advise about STREQUAL. Explanation of s/_/(/ (from
> http://www.rpm.org/max-rpm-snapshot/s1-rpm-depend-manual-dependencies.html
> ):
> "Recent versions of RPM support context marked dependencies. This is a
> special type of a dependency that applies only in a specified *context*.
> Using this feature, one can specify dependencies for pre- and
> post(un)install scriptlets, ie. the context of a dependency is the
> execution time of the specified scriptlet.
>
> The syntax for specifying these dependencies is:
>
> Requires(*X*): foo
>
>    Here, *X* can be one of *pre*, *post*, *preun*, or *postun*, which
> tells RPM that the package depends on package foo for running the
> corresponding *%pre*, *%post*, *%preun*, or *%postun* script."
>
> Modified patch attached.
>
> 2014-10-09 18:03 GMT+04:00 Brad King <brad.k...@kitware.com>:
>
>> On 10/08/2014 01:48 PM, Evgeny Kalishenko wrote:
>> > I was interested in feature request
>> > http://public.kitware.com/Bug/view.php?id=14769 and made a
>> > simple patch for CPack RPM generator (attached).
>>
>> Thanks.
>>
>> In this hunk:
>>
>> > +    # The following keywords require braces around the "pre" or "post"
>> suffix in the final RPM spec file.
>> > +    if("${_RPM_SPEC_HEADER}" MATCHES "REQUIRES_PRE"  OR
>> "${_RPM_SPEC_HEADER}" MATCHES "REQUIRES_POST")
>> > +      string(REPLACE "_" "(" _PACKAGE_HEADER_NAME
>> "${_PACKAGE_HEADER_NAME}")
>> > +      set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME})")
>> > +    endif()
>>
>> The MATCHES conditions can use simply STREQUAL instead.
>> I'm not very familiar with the spec format, so please
>> explain the purpose of the s/_/(/ subsitution in comments
>> here.
>>
>> Thanks,
>> -Brad
>>
>>
>
>
> --
> С уважением,
> Евгений Калишенко
>
>
>  In this hunk:
> +#  May be used to set RPM postinstall dependencies (requires(post)).
> Note that you must enclose
> +#  the complete requires string between quotes, for example::
> +#
> +#   set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
> +#
> +#
>
> The variable name CPACK_RPM_PACKAGE_REQUIRES_PRE should be
> CPACK_RPM_PACKAGE_REQUIRES_POST.
>
> In this hunk:
> +    # The following keywords require braces around the "pre" or "post"
> suffix in the final RPM spec file.
> +    if("${_RPM_SPEC_HEADER}" MATCHES "REQUIRES_PRE"  OR
> "${_RPM_SPEC_HEADER}" MATCHES "REQUIRES_POST")
> +      string(REPLACE "_" "(" _PACKAGE_HEADER_NAME
> "${_PACKAGE_HEADER_NAME}")
> +      set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME})")
> +    endif()
>
> Shouldn't braces be called parentheses here ( i.e '(' versus '{' )?
>
> I have checked with a minimal project on a ubuntu 14.04 box (using rpm
> 4.11.1) and the generated package seems good. So, no further comments.
>
> With kind regards,
> Micha Hergarden
>



-- 
Regards,
Evgeny Kalishenko
From 0f05b7863f5db20a9099bf1076df880d7bc68f65 Mon Sep 17 00:00:00 2001
From: evgenyk <ydgins...@gmail.com>
Date: Wed, 8 Oct 2014 21:39:19 +0400
Subject: [PATCH 1/3] Requires for pre(post) install scripts are implemented
 for RPM packager

---
 Modules/CPackRPM.cmake | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index 2864b21..27c5f51 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -135,6 +135,31 @@
 #
 #   rpm -qp --requires file.rpm
 #
+# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
+#
+#  RPM spec requires(pre) field.
+#
+#  * Mandatory : NO
+#  * Default   : -
+#
+#  May be used to set RPM preinstall dependencies (requires(pre)).  Note that you must enclose
+#  the complete requires string between quotes, for example::
+#
+#   set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
+#
+# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
+#
+#  RPM spec requires(post) field.
+#
+#  * Mandatory : NO
+#  * Default   : -
+#
+#  May be used to set RPM postinstall dependencies (requires(post)).  Note that you must enclose
+#  the complete requires string between quotes, for example::
+#
+#   set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
+#
+#
 # .. variable:: CPACK_RPM_PACKAGE_SUGGESTS
 #
 #  RPM spec suggest field.
@@ -556,7 +581,7 @@ endif()
 # There may be some COMPONENT specific variables as well
 # If component specific var is not provided we use the global one
 # for each component
-foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV)
+foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST)
     if(CPACK_RPM_PACKAGE_DEBUG)
       message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}")
     endif()
@@ -595,6 +620,11 @@ foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLIC
     string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL)
     string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME)
     set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}")
+    # The following keywords require braces around the "pre" or "post" suffix in the final RPM spec file.
+    if("${_RPM_SPEC_HEADER}" MATCHES "REQUIRES_PRE"  OR  "${_RPM_SPEC_HEADER}" MATCHES "REQUIRES_POST")
+      string(REPLACE "_" "(" _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}")
+      set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME})")
+    endif()
     if(CPACK_RPM_PACKAGE_DEBUG)
       message("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}")
     endif()
@@ -991,6 +1021,8 @@ Group:          \@CPACK_RPM_PACKAGE_GROUP\@
 Vendor:         \@CPACK_RPM_PACKAGE_VENDOR\@
 \@TMP_RPM_URL\@
 \@TMP_RPM_REQUIRES\@
+\@TMP_RPM_REQUIRES_PRE\@
+\@TMP_RPM_REQUIRES_POST\@
 \@TMP_RPM_PROVIDES\@
 \@TMP_RPM_OBSOLETES\@
 \@TMP_RPM_CONFLICTS\@
-- 
1.8.1.4


From b3eedb616170ff1633ec2fb99b3daf2f4a3fa0a4 Mon Sep 17 00:00:00 2001
From: evgenyk <ydgins...@gmail.com>
Date: Thu, 9 Oct 2014 21:29:18 +0400
Subject: [PATCH 2/3] PREUN and POSTUN requirements implemented for CPackRPM

---
 Modules/CPackRPM.cmake | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index 27c5f51..feab872 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -409,7 +409,7 @@ if(CPACK_RPM_PACKAGE_DEBUG)
                     OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
                     ERROR_QUIET
                     OUTPUT_STRIP_TRAILING_WHITESPACE)
-    string(REPLACE "\n" ", "
+    string(REGEX REPLACE "\n" ", "
            LSB_RELEASE_OUTPUT
            ${_TMP_LSB_RELEASE_OUTPUT})
   else ()
@@ -422,7 +422,7 @@ endif()
 # to shut down warning about space in buildtree
 # some recent RPM version should support space in different places.
 # not checked [yet].
-if(CPACK_TOPLEVEL_DIRECTORY MATCHES " ")
+if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*")
   message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.")
 endif()
 
@@ -581,7 +581,7 @@ endif()
 # There may be some COMPONENT specific variables as well
 # If component specific var is not provided we use the global one
 # for each component
-foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST)
+foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
     if(CPACK_RPM_PACKAGE_DEBUG)
       message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}")
     endif()
@@ -621,7 +621,9 @@ foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLIC
     string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME)
     set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}")
     # The following keywords require braces around the "pre" or "post" suffix in the final RPM spec file.
-    if("${_RPM_SPEC_HEADER}" MATCHES "REQUIRES_PRE"  OR  "${_RPM_SPEC_HEADER}" MATCHES "REQUIRES_POST")
+    set(SCRIPTS_REQUIREMENTS_LIST REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
+    list(FIND SCRIPTS_REQUIREMENTS_LIST ${_RPM_SPEC_HEADER} IS_SCRIPTS_REQUIREMENT_FOUND)
+    if(NOT ${IS_SCRIPTS_REQUIREMENT_FOUND} EQUAL -1)
       string(REPLACE "_" "(" _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}")
       set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME})")
     endif()
@@ -1023,6 +1025,8 @@ Vendor:         \@CPACK_RPM_PACKAGE_VENDOR\@
 \@TMP_RPM_REQUIRES\@
 \@TMP_RPM_REQUIRES_PRE\@
 \@TMP_RPM_REQUIRES_POST\@
+\@TMP_RPM_REQUIRES_PREUN\@
+\@TMP_RPM_REQUIRES_POSTUN\@
 \@TMP_RPM_PROVIDES\@
 \@TMP_RPM_OBSOLETES\@
 \@TMP_RPM_CONFLICTS\@
-- 
1.8.1.4


From 00a0ba38bd1a9c09cb21b897b2160b308d0296d6 Mon Sep 17 00:00:00 2001
From: evgenyk <ydgins...@gmail.com>
Date: Mon, 20 Oct 2014 20:49:25 +0400
Subject: [PATCH 3/3] Erroneous spelling fixed for pre(post) install scripts
 implementation

---
 Modules/CPackRPM.cmake | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index feab872..64d86e8 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -157,7 +157,7 @@
 #  May be used to set RPM postinstall dependencies (requires(post)).  Note that you must enclose
 #  the complete requires string between quotes, for example::
 #
-#   set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
+#   set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts")
 #
 #
 # .. variable:: CPACK_RPM_PACKAGE_SUGGESTS
@@ -620,7 +620,7 @@ foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLIC
     string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL)
     string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME)
     set(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}")
-    # The following keywords require braces around the "pre" or "post" suffix in the final RPM spec file.
+    # The following keywords require parentheses around the "pre" or "post" suffix in the final RPM spec file.
     set(SCRIPTS_REQUIREMENTS_LIST REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
     list(FIND SCRIPTS_REQUIREMENTS_LIST ${_RPM_SPEC_HEADER} IS_SCRIPTS_REQUIREMENT_FOUND)
     if(NOT ${IS_SCRIPTS_REQUIREMENT_FOUND} EQUAL -1)
-- 
1.8.1.4

-- 

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