I missed a few things in my previous message.

I'm currently trying to solve a two problems with the RPM generator:
  * Lack of support for file names containing spaces
  * Lack of support for %config and %config(noreplace)

  * Lack of support for "Obsoletes:"
  * Lack of support for %doc

I'm yet to succeed. I tried to fix the call to sed to enclose file names between double quotes. It's not working as expected. I suspect I might have missed a backslash somewhere.

I did add another backslash to escape the parentheses. Special
characters are now supported in file names with the exception of double
quotes. I did not bother adding support for these, although this should
be easy.

As for the %config support, it works well as long as I specify only one file. I believe I would need to add a %config line for each file. Unfortunately don't know how to achieve this with CMake macros.

Ok. I managed to get this to work using lists and foreach.

Any help is of course welcome. Here are my changes:

Oops! It seems I made the diff with the wrong file. Most of the changes
were missing. The changes are attached to this message.
--
Erwan Legrand
Sr. Software Engineer
Gateway Technology
Cloudmark

--- CPackRPM.cmake.orig	2010-05-07 10:46:54.000000000 +0200
+++ CPackRPM.cmake	2010-05-07 15:01:41.000000000 +0200
@@ -45,7 +45,7 @@
 #  CPACK_RPM_PACKAGE_VENDOR 
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_VENDOR if set or "unknown"
-#     The RPM package group.
+#     The RPM package vendor.
 #  CPACK_RPM_PACKAGE_DESCRIPTION
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_DESCRIPTION_FILE if set or "no package description available"
@@ -60,6 +60,10 @@
 #     Mandatory : NO
 #     Default   : -
 #     May be used to set RPM dependencies (provides).
+#  CPACK_RPM_PACKAGES_OBSOLETES
+#     Mandatory : NO
+#     Default   : -
+#     May be used to set RPM update information (obsoletes).
 #  CPACK_RPM_SPEC_INSTALL_POST
 #     Mandatory : NO
 #     Default   : -
@@ -70,6 +74,14 @@
 #     Mandatory : NO
 #     Default   : -
 #     May be used to add any %define lines to the generated spec file.
+#  CPACK_RPM_SPEC_CONFIG
+#     Mandatory : NO
+#     Default   : -
+#     May be used to add any %config lines to the generated spec file.
+#  CPACK_RPM_SPEC_CONFIG_NOREPLACE
+#     Mandatory : NO
+#     Default   : -
+#     May be used to add any %config(noreplace) lines to the generated spec file.
 #  CPACK_RPM_PACKAGE_DEBUG
 #     Mandatory : NO
 #     Default   : -
@@ -285,6 +297,16 @@
   SET(TMP_RPM_PROVIDES "Provides: ${CPACK_RPM_PACKAGE_PROVIDES}")
 ENDIF(CPACK_RPM_PACKAGE_PROVIDES)
 
+# CPACK_RPM_PACKAGE_OBSOLETES
+# Placeholder used to specify binary RPM dependencies (if any)
+# see http://www.rpm.org/max-rpm/s1-rpm-depend-manual-dependencies.html
+IF(CPACK_RPM_PACKAGE_OBSOLETES)
+  IF(CPACK_RPM_PACKAGE_DEBUG)
+    MESSAGE("CPackRPM:Debug: User defined Obsoletes:\n ${CPACK_RPM_PACKAGE_OBSOLETES}")
+  ENDIF(CPACK_RPM_PACKAGE_DEBUG)
+  SET(TMP_RPM_OBSOLETES "Obsoletes: ${CPACK_RPM_PACKAGE_OBSOLETES}")
+ENDIF(CPACK_RPM_PACKAGE_OBSOLETES)
+
 # CPACK_RPM_SPEC_INSTALL_POST
 # May be used to define a RPM post intallation script
 # for example setting it to "/bin/true" may prevent
@@ -346,6 +368,28 @@
   ENDIF(CPACK_RPM_PACKAGE_DEBUG)
 ENDIF(CPACK_RPM_SPEC_MORE_DEFINE)
 
+# CPACK_RPM_SPEC_CONFIG
+# Add %config to spec file
+IF(CPACK_RPM_SPEC_CONFIG)
+  IF(CPACK_RPM_PACKAGE_DEBUG)
+    MESSAGE("CPackRPM:Debug: User defined CPACK_RPM_SPEC_CONFIG = ${CPACK_RPM_SPEC_CONFIG}")
+  ENDIF(CPACK_RPM_PACKAGE_DEBUG)
+  FOREACH(f ${CPACK_RPM_SPEC_CONFIG})
+    SET(TMP_RPM_SPEC_CONFIG "${TMP_RPM_SPEC_CONFIG}\n%config ${f}")
+  ENDFOREACH(f)
+ENDIF(CPACK_RPM_SPEC_CONFIG)
+
+# CPACK_RPM_SPEC_CONFIG_NOREPLACE
+# Add %config(noreplace) to spec file
+IF(CPACK_RPM_SPEC_CONFIG_NOREPLACE)
+  IF(CPACK_RPM_PACKAGE_DEBUG)
+    MESSAGE("CPackRPM:Debug: User defined CPACK_RPM_SPEC_CONFIG_NOREPLACE = ${CPACK_RPM_SPEC_CONFIG_NOREPLACE}")
+  ENDIF(CPACK_RPM_PACKAGE_DEBUG)
+  FOREACH(f ${CPACK_RPM_SPEC_CONFIG_NOREPLACE})
+    SET(TMP_RPM_SPEC_CONFIG_NOREPLACE "${TMP_RPM_SPEC_CONFIG_NOREPLACE}\n%config(noreplace) ${f}")
+  ENDFOREACH(f)
+ENDIF(CPACK_RPM_SPEC_CONFIG_NOREPLACE)
+
 # Now we may create the RPM build tree structure
 SET(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}")
 MESSAGE(STATUS "CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}")
@@ -367,12 +411,13 @@
 
 # Use files tree to construct files command (spec file)
 # We should not forget to include symlinks (thus -o -type l)
-# We must remove the './' due to the local search (thus the sed)
 # Then we must authorize any man pages extension (adding * at the end)
 # because rpmbuild may automatically compress those files
-EXECUTE_PROCESS(COMMAND find -type f -o -type l
-               COMMAND sed {s/\\.//}
-               COMMAND sed {s/.*man.*\\/.*/&*/}
+# Then must remove the './' due to the local search and escape the
+# file name by enclosing it between double quotes (thus the sed)
+EXECUTE_PROCESS(COMMAND find . -type f -o -type l
+               COMMAND sed {s:.*/man.*/.*:&*:}
+               COMMAND sed {s/\\.\\\(.*\\\)/\"\\1\"/}
                WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}"
                OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES)
 
@@ -410,6 +455,7 @@
 Vendor:         \...@cpack_rpm_package_vendor\@
 \...@tmp_rpm_requires\@
 \...@tmp_rpm_provides\@
+...@tmp_rpm_obsoletes\@
 \...@tmp_rpm_buildarch\@
  
 #p define prefix \...@cmake_install_prefix\@
@@ -455,8 +501,8 @@
 \...@cpack_rpm_spec_preuninstall\@
 
 %files
-%defattr(-,root,root,-)
-${CPACK_RPM_INSTALL_FILES}
+%defattr(-,root,root,-)\...@tmp_rpm_spec_config\@\...@tmp_rpm_spec_config_noreplace\@
+...@cpack_rpm_install_files\@
 
 %changelog
 * Sat Nov 28 2009 Erk <[email protected]>
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to