MantisBT - CMake
View Issue Details
0012063CMakeCPackpublic2011-04-09 03:532012-03-06 08:37
Eric NOULARD 
Eric NOULARD 
normalfeaturehave not tried
closedfixed 
LinuxRPM based distros
CMake 2.8.4 
CMake 2.8.6CMake 2.8.6 
0012063: CPackRPM: cannot specify per-component install scripts
CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
CPACK_RPM_POST_INSTALL_SCRIPT_FILE
CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE

cannot be specified on a per-component basis.

Initially reported on the ML:
http://www.cmake.org/pipermail/cmake/2011-March/043393.html [^]
No tags attached.
related to 0012062closed Domen Vrankar CPackDeb: The EXTRA control files may not be specified on a per-component basis 
has duplicate 0012469closed Eric NOULARD RPM COMPONENT packaging support for pre/post install scripts is weak 
? CPackRPM.cmake (32,784) 2011-07-26 14:13
https://public.kitware.com/Bug/file/3981/CPackRPM.cmake
bz2 rpmcomponenttest2.tar.bz2 (1,304) 2011-07-28 07:33
https://public.kitware.com/Bug/file/3985/rpmcomponenttest2.tar.bz2
patch CPackRPM.cmake.patch (9,838) 2011-09-20 10:31
https://public.kitware.com/Bug/file/4057/CPackRPM.cmake.patch
Issue History
2011-04-09 03:53Eric NOULARDNew Issue
2011-04-09 03:54Eric NOULARDRelationship addedrelated to 0012062
2011-07-26 14:13winfrieddNote Added: 0027073
2011-07-26 14:13winfrieddFile Added: CPackRPM.cmake
2011-07-26 14:14winfrieddFile Added: rpmcomponenttest.tar.bz2
2011-07-26 14:15winfrieddNote Edited: 0027073bug_revision_view_page.php?bugnote_id=27073#r384
2011-07-26 14:25winfrieddNote Edited: 0027073bug_revision_view_page.php?bugnote_id=27073#r385
2011-07-26 16:12Eric NOULARDAssigned To => Eric NOULARD
2011-07-26 16:12Eric NOULARDStatusnew => assigned
2011-07-26 16:23Eric NOULARDNote Added: 0027075
2011-07-28 04:22winfrieddNote Added: 0027094
2011-07-28 07:33winfrieddFile Added: rpmcomponenttest2.tar.bz2
2011-07-28 07:35winfrieddNote Added: 0027095
2011-07-28 08:10Eric NOULARDFile Deleted: rpmcomponenttest.tar.bz2
2011-09-19 14:37Eric NOULARDRelationship addedhas duplicate 0012469
2011-09-19 15:32Chip ChristianNote Added: 0027455
2011-09-20 10:31Chip ChristianFile Added: CPackRPM.cmake.patch
2011-09-20 10:32Chip ChristianNote Added: 0027458
2011-09-20 10:37Eric NOULARDNote Added: 0027459
2011-09-20 14:24Eric NOULARDFixed in Version => CMake 2.8.6
2011-09-20 14:24Eric NOULARDTarget Version => CMake 2.8.6
2011-09-20 14:24Eric NOULARDNote Added: 0027460
2011-09-20 14:24Eric NOULARDStatusassigned => resolved
2011-09-20 14:24Eric NOULARDResolutionopen => fixed
2012-03-06 08:37David ColeNote Added: 0028825
2012-03-06 08:37David ColeStatusresolved => closed

Notes
(0027073)
winfriedd   
2011-07-26 14:13   
(edited on: 2011-07-26 14:25)
I made some modifications agains the CPackRPM.cmake of cmake 2.8.5 to implement this issue.

If component installation is turned the CPACK_RPM_PRE_INSTALL_SCRIPT_FILE and friends variables can be overridden with:

CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE
CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE
CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE
CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE

If they are not specified the CPACK_RPM_PRE_INSTALL_SCRIPT_FILE etc. variables are used (for backwards compatibility).

I will attach the modified module and a simple test project with 2 components.

Hopefully this can be accepted for 2.8.6

regards, Winfried

ps: what I don't understand and don't like is that in the attached test project I have to set the CPACK_RPM_COMPONENT1_POST_INSTALL_SCRIPT_FILE etc variables in the CMakeLists.txt of the root directory. If I set them in the CMakeLists.txt of one of the subdirectories they are not set in CPackRPM.cmake...

(0027075)
Eric NOULARD   
2011-07-26 16:23   
Thank you winfried,

I'll review your patch.
But probably not before a week or two.

Concerning the location of "where" you can set(CPACK_xxx) in order to get them
defined in CPackRPM.cmake this is a "SCOPE" issue.

CPackRPM.cmake is loaded "at CPack-time" and CMakeLists.txt are loaded at "CMake-time".

CPackRPM.cmake inherits from the vars defined in CPackConfig.cmake (in your build tree).
CPackConfig.cmake gets created by the include(CPack.cmake) probably done in
your main CMakeLists.txt. This inclusion gets all CPACK_<whatever> vars defined
before the inclusion and put them in the generated CPackConfig.cmake.

CPACK_xx variable defined in subdirs are out of the scope of the main CMakeLists.txt (unless you use PARENT_SCOPE or CACHE) thus the problem.

The solution should be either put the var in global SCOPE
or define those in a separate CPACK_PROJECT_CONFIG_FILE:
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#Overall_usage_.28common_to_all_generators.29 [^]

this file gets loaded at CPack-time.
(0027094)
winfriedd   
2011-07-28 04:22   
Thanks for the clarification.

If the patch needs any changes let me know, or edit yourself as you see fit.
(0027095)
winfriedd   
2011-07-28 07:35   
Please use file rpmcomponenttest2.tar.bz2 for testing, that one is for cmake 2.8.5. The first uploaded tar ball (for cmake 2.8.4) can be deleted, but I don't seem to be able to delete it myself.
(0027455)
Chip Christian   
2011-09-19 15:32   
This patch works well for me, but I see a problem for non-component installs:

CPACK_RPM_POST_INSTALL_READ_FILE, etc. are only set iff CPACK_RPM_PACKAGE_COMPONENT is set
(0027458)
Chip Christian   
2011-09-20 10:32   
Try the patch I just uploaded. Should work correctly now with or without a COMPONENT install. Also fixed up the else/endifs.
(0027459)
Eric NOULARD   
2011-09-20 10:37   
I'll do that may be tonight or in a day or two.
Thank you for you contribution.
(0027460)
Eric NOULARD   
2011-09-20 14:24   
Just merged to next with small editing.
Merge topic 'CPackRPM-per-component-script' into next

cc26a06 CPackRPM authorize per-component pre/post-[un]install scripts (0012063)
(0028825)
David Cole   
2012-03-06 08:37   
Closing resolved issues that have not been updated in more than 4 months.