MantisBT - CMake
View Issue Details
0010294CMakeCPackpublic2010-02-15 20:272012-04-25 18:04
Thawan Kooburat 
Eric NOULARD 
normalfeatureN/A
closedfixed 
CMake-2-8 
CMake 2.8.8CMake 2.8.8 
0010294: Patch for CPack RPM generator (CPACK_RPM_SPEC_IGNORE_FILES)
Hi,

I created a patch that another control variable to CPackRPM
# CPACK_RPM_SPEC_IGNORE_FILES
# Mandatory : NO
# Default : -
# Can be used to specify a list of files to ignore when CPackRPM is
# generating a file list to fill %file section (@CPACK_RPM_INSTALL_FILES@)

Scenario:
Files in RPM package can be installed with various attributes. It may be owned by user other than "root" or specified as configuration file (%config)

Problem:
CPack RPM automatically add all files into ${CPACK_RPM_INSTALL_FILES} which is specified as normal file and owner by root.

Usage:
By specifying a list of ignore files in CPACK_RPM_SPEC_IGNORE_FILES, user can customize attribute of some files manually and the rest is automatically filled by CPackRPM. Without this modification, RPM will report warnings that there are duplicate entries in %file section if I try to write a spec file as below. (However, the result RPM works as intended)

Example usage:
[CMakeLists.txt]
set (CPACK_RPM_USER_BINARY_SPECFILE foo.spec.in )
set (CPACK_RPM_SPEC_IGNORE_FILES "/etc/foo.config" "/etc/init.d/foo")

[foo.spec.in]
...
%files
%defattr(-,root,root,-)
%config(noreplace) /etc/foo.config
%config(noreplace) /etc/init.d/foo

@CPACK_RPM_INSTALL_FILES@

No tags attached.
related to 0012608closed Eric NOULARD Unexpected %config file declaration. 
related to 0010701closed Eric NOULARD Lack of "%doc, %config, Obsolete" in CPackRPM 
patch CPackRPM.patch (1,219) 2010-02-15 20:27
https://public.kitware.com/Bug/file/2867/CPackRPM.patch
Issue History
2010-02-15 20:27Thawan KooburatNew Issue
2010-02-15 20:27Thawan KooburatFile Added: CPackRPM.patch
2010-02-20 11:43Eric NOULARDStatusnew => assigned
2010-02-20 11:43Eric NOULARDAssigned To => Eric NOULARD
2010-02-20 11:44Eric NOULARDNote Added: 0019558
2010-04-04 16:21Eric NOULARDNote Added: 0020072
2010-04-06 16:51Thawan KooburatNote Added: 0020081
2010-04-07 02:25Eric NOULARDNote Added: 0020087
2010-04-07 20:57Thawan KooburatNote Added: 0020100
2010-04-08 02:47Eric NOULARDNote Added: 0020101
2010-05-11 04:16Eric NOULARDRelationship addedrelated to 0010701
2010-08-23 13:08Eric NOULARDNote Added: 0021897
2012-04-20 15:11Eric NOULARDRelationship addedrelated to 0012608
2012-04-20 15:13Eric NOULARDNote Added: 0029281
2012-04-20 15:13Eric NOULARDStatusassigned => closed
2012-04-20 15:13Eric NOULARDResolutionopen => fixed
2012-04-20 15:13Eric NOULARDFixed in Version => CMake 2.8.8
2012-04-25 18:04David ColeTarget Version => CMake 2.8.8

Notes
(0019558)
Eric NOULARD   
2010-02-20 11:44   
Thank you thawan,

I self-assign this bug.
I'll review your patch ASAP.
(0020072)
Eric NOULARD   
2010-04-04 16:21   
Just looking into the patch.

I was thinking that may be it would be easier to directly specify
the appropriate line for the files like:

set (CPACK_RPM_SPEC_FILES_LINES "%config(noreplace);/etc/foo.config;%config(noreplace);/etc/init.d/foo")

Then we could extract from this "list of pair" the file name
in order to filter out the appropriate file and directly replace
it with appropriate prefix in the spec file without the need
to use a CPACK_RPM_USER_BINARY_SPECFILE.

Thus even a "generated" spec file may offer the control over the
appropriate right for any file.

Do you think it suits the needs?
(0020081)
Thawan Kooburat   
2010-04-06 16:51   
Thank you for reviewing my patch. I agree that the solution you purposed can solve my issue and also allow the other user to use this functionality with the “generated” spec file.

The solution that I purposed allows me to easily port my old spec file into CPack and let CPackRPM fill-in the rest of the files that do not need special attention.

Below is an example spec files that I found from the internet. You can look at the %file section and see that it might be easier to let the user write the %file section manually because there are many ways to write it.

http://www.madboa.com/geek/specs/pine.spec [^]

In conclusion, I will be very appreciated if you could keep CPACK_RPM_SPEC_IGNORE_FILES even though you choose to add CPACK_RPM_SPEC_FILES_LINES because I guess that internally you have to create a list of files that needed to be filter-out anyway. Thus, allowing user to specify that list as well should not add much complexity.
(0020087)
Eric NOULARD   
2010-04-07 02:25   
OK I see.
I'll see what I can do, however my idea is to avoid to have
to specify the very same information (the list of file to filter out)
at two DIFFERENT places like
    a) in CPACK_RPM_SPEC_IGNORE_FILES
    b) in the USER binary spec file.

same info in different places sometimes leads to hard to track errors
because of non-voluntary inconsistencies between the different places.

Concerning the various to write a spec file you are damn right
there many different possibilities
(see http://www.rpm.org/max-rpm/ [^])
and I do not intend to support them all in the generated spec file.
Thus the CPACK_RPM_USER_BINARY_SPECFILE mechanism as a solution
to trap for "unsupported featuress".

The idea is:
   1) Generated spec file should ease at the maximum
      the creation of RPM with some flexibility

   2) Then go for CPACK_RPM_USER_BINARY_SPECFILE when
      maximum flexibility is needed.
(0020100)
Thawan Kooburat   
2010-04-07 20:57   
Thanks for looking into this issue. I understand your concerns about the duplicate information.

CPACK_RPM_USER_BINARY_SPECFILE is very flexible. In my case, I can replace all dynamic variables with CPackRPM variables and everything works like a charm (Too bad that the documentation does not give enough examples on how to use this mechanism, so it took me a while to figure this out).

However, the list of files to fill in %file section is the main problem. Small projects might be able to use a static list or user wildcards if they don’t care much. Initially, I try to come up with a solution to prepare a list of binaries by myself dynamically without modifying CPackRPM but it was too hard. My point is that @CPACK_RPM_INSTALL_FILES@ is really important for me to use the user-specified spec file properly.

I think that both CPACK_RPM_SPEC_FILES_LINES and CPACK_RPM_SPEC_IGNORE_FILES can co-exist without causing much confusion. For example, the final list for files to filter-out is a union between lists of files from both variables. In this case, even if users incorrectly specify them in both locations, it does not affect the correctness of the final spec file (both user specified and generated one). However, you might need to have two variables from %file section in the generated spec file which may look like below

%file
%defattr(-,root,root,-)
@CPACK_RPM_SPEC_FILES_LINES@
@CPACK_RPM_INSTALL_FILES @

The benefit of this are:
1. Users might be able to use %attr for each SPEC_FILE_LINE pair to override the default owner and permission if he wanted to (Not sure about this but I think it should be possible).
2. Those who want to use their own spec file only need to use @ CPACK_RPM_INSTALL_FILES @ like the first example.

So CPACK_RPM_SPEC_IGNORE_FILES will give users direct control over the @ CPACK_RPM_INSTALL_FILES @. Otherwise they have to indirectly use CPACK_RPM_SPEC_FILES_LINES to filter-out the files which might not be clear to users when reading from the documentation.

PS. Sorry for long description : )
(0020101)
Eric NOULARD   
2010-04-08 02:47   
OK noted.
Concerning documentation there is currently two places:
 a) embedded doc in CPackRPM.cmake
    see cmake --help-module CPackRPM

 b) Wiki pages:
     http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29 [^]

I would kindly accept documentation patch for a) too ;-)
and the Wiki may be improved by any registered user.
May be you can write a paragraph on your experience feedback concerning
CPACK_RPM_USER_BINARY_SPECFILE.

I'm not sure to be able to work on this before 2 weeks so be patient
and I'll come back to you.
(0021897)
Eric NOULARD   
2010-08-23 13:08   
Hi Thawan,

If you have time, have a look at lastest patches attached to
bug 7000: http://public.kitware.com/Bug/view.php?id=7000. [^]

It should pave the way to solve the current issue too.
Currently %config is added automatically to absolute installed files
but adding a filtering feature which add the extra (noreplace)
is now easier.

For example we can define

CPACK_RPM_NOREPLACE_FILES which give the list of files
which should be added noreplace.

We could even add a CPACK_RPM_INSTALLED_FILES_PREFIX
which should be a list of pair "filename;prefix" indicating
that "filename" must be prefixed by "prefix".
(0029281)
Eric NOULARD   
2012-04-20 15:13   
This bug has been fixed in a more general way wit 0012608 fix.

commit 121c29553fc66575f231bebda6682b21216c1e03
Author: Eric NOULARD <eric.noulard@gmail.com>
Date: Mon Dec 12 23:11:02 2011 +0100

CPackRPM fix 0012608 and unoticed related bug
    
    The User may now specify a list of file that shouldn't be
    automatically handled by CPack but specified by the user.
    Like %config(noreplace) or specific %attr.
    The concerned files/dir lines will be removed from the set
    automatically handled by CPack.