[CMake] CPack RPM with COMPONENTS packaging

Theodore Papadopoulo Theodore.Papadopoulo at inria.fr
Wed Mar 20 11:45:35 EDT 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/20/2013 03:58 PM, Eric Noulard wrote:
> 2013/3/20 Theodore Papadopoulo <Theodore.Papadopoulo at inria.fr>:
>> 
>> That was what I was missing. Thanks. It is a pity that the
>> example does not include that. I think this is quite hidden
> 
> Which example are you refering to?

The ComponentExample.zip mentionned at
http://www.cmake.org/Wiki/CMake:Component_Install_With_CPack

>> - From CPackRPM.cmake
>> 
>> [...] %files %defattr(-,root,root,-) ${CPACK_RPM_INSTALL_FILES} 
>> ${CPACK_RPM_ABSOLUTE_INSTALL_FILES} 
>> ${CPACK_RPM_USER_INSTALL_FILES} [...]
>> 
>> That seems a bug... Should the following patch be applied ??
>> 
>> diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake 
>> index fa79e1b..e6b0076 100644 - --- a/Modules/CPackRPM.cmake +++
>> b/Modules/CPackRPM.cmake @@ -902,9 +902,9 @@ mv
>> \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT
>> 
>> %files %defattr(-,root,root,-) - -${CPACK_RPM_INSTALL_FILES} -
>> -${CPACK_RPM_ABSOLUTE_INSTALL_FILES} -
>> -${CPACK_RPM_USER_INSTALL_FILES} +\@CPACK_RPM_INSTALL_FILES\@ 
>> +\@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@ 
>> +\@CPACK_RPM_USER_INSTALL_FILES\@
> 
> This shouldn't make any difference. The template is expanded at
> CPack time so that putting @ or $ should not make any difference
> unless you do set those variables at CMake time, Do you do that?

Well there is a difference. Imagine I generate the template as you
said and then use my template. Later on, I add a new file, the
filenames in the template being fixed, this file will not be added
whereas it will with the proposed patch (since the template will
already not have the file list and cpack will replace them).

>> Anyhow, I guess I have a workaround by placing these lines
>> instead of the files in my templates.
> 
> And do you observe differences when you do  that?

As I said above, no there is no difference in my case because the set
of file is fixed. But the difference will appear if a new file is
added in a component.

>> But then there is another question, can I use different templates
>> for different components ?? One of the bug reports seems to hint
>> at that for changing descriptions, but I cannot figure out how to
>> specify per component templates.
> 
> This is a missing feature. Not all feature are componentized.

Ouch. This is a showstopper for me...
But not too difficult to do...
Would the attached patch be a solution ?
Works for me at least.

Then I'll have to proceed to DEB, NSIS and MacOS BUNDLE packages....
Should I expect similar problems (looks like NSIS should be easy) and
I suspect that DEB will be very similar to RPM.

   Thank's again,

	Theo.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlFJ2Z8ACgkQEr8WrU8nPV2unwCgqKTaZH6wHBBTynYUhsUbJqXB
J+oAmwZX4JiYdRnH7Yr1ovqJCR1r21xa
=MDI3
-----END PGP SIGNATURE-----
-------------- next part --------------
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index fa79e1b..0f40e72 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -902,9 +902,9 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT
 
 %files
 %defattr(-,root,root,-)
-${CPACK_RPM_INSTALL_FILES}
-${CPACK_RPM_ABSOLUTE_INSTALL_FILES}
-${CPACK_RPM_USER_INSTALL_FILES}
+\@CPACK_RPM_INSTALL_FILES\@
+\@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@
+\@CPACK_RPM_USER_INSTALL_FILES\@
 
 %changelog
 \@CPACK_RPM_SPEC_CHANGELOG\@
@@ -919,11 +919,26 @@ endif()
 
 # After that we may either use a user provided spec file
 # or generate one using appropriate variables value.
-if(CPACK_RPM_USER_BINARY_SPECFILE)
-  # User may have specified SPECFILE just use it
-  message("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}")
-  # The user provided file is processed for @var replacement
-  configure_file(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
+if(CPACK_RPM_USER_BINARY_SPECFILE OR 
+   (CPACK_RPM_PACKAGE_COMPONENT AND CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE))
+  if(CPACK_RPM_PACKAGE_COMPONENT)
+    # User may have specified SPECFILE just use it
+    # If there is a per component spec file, use it.
+    set(_SPEC_TEMPLATE ${CPACK_RPM_USER_BINARY_SPECFILE})
+    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE)
+      set(_SPEC_TEMPLATE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE})
+      message("CPackRPM: Will use per component USER specified spec file: ${_SPEC_TEMPLATE}")
+    else()
+      message("CPackRPM: Will use USER specified spec file: ${_SPEC_TEMPLATE}")
+    endif()
+    # The user provided file is processed for @var replacement
+    configure_file(${_SPEC_TEMPLATE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
+  else()
+    # User may have specified SPECFILE just use it
+    message("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}")
+    # The user provided file is processed for @var replacement
+    configure_file(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
+  endif()
 else()
   # No User specified spec file, will use the generated spec file
   message("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}")


More information about the CMake mailing list