MantisBT - CMake
View Issue Details
0013898CMakeCPackpublic2013-02-07 19:152013-07-01 09:37
Jonathan M Davis 
Eric NOULARD 
normalminoralways
closedfixed 
Linux
CMake 2.8.10.2 
 
0013898: cpack fails to use some CPACK_RPM_PACKAGE_* variables in the generated rpm spec if their value is less than 3 characters long
If you do set(CPACK_RPM_PACKAGE_AUTOREQPROV 0) or set(CPACK_RPM_PACKAGE_AUTOREQPROV no), when using the RPM generator for cpack, it has no effect on the RPM spec file which is generated. However, if you do set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") or set(CPACK_RPM_PACKAGE_AUTOREQPROV "no "), then it works.

Looking through CPackRPM.cmake, I suspect that it has to do with this section at line 480:

----------------
  if(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)
    string(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH)
    math(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - 1")
    string(SUBSTRING ${_RPM_SPEC_HEADER} 1 ${_PACKAGE_HEADER_STRLENGTH} _PACKAGE_HEADER_TAIL)
    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}")
    if(CPACK_RPM_PACKAGE_DEBUG)
      message("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}")
    endif()
    set(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}")
  else()
    # Do not forget to unset previously set header (from previous component)
    unset(TMP_RPM_${_RPM_SPEC_HEADER})
  endif()
----------------

and I expect that it affects every variable which is looped over and hits that code:

----------------
foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV)
----------------

but I've only tested it with CPACK_RPM_PACKAGE_AUTOREQPROV. I've also only tested it with a library target.
1. Use set(CPACK_RPM_PACKAGE_AUTOREQPROV 0) or set(CPACK_RPM_PACKAGE_AUTOREQPROV no) as part of setting up cpack for generating RPMs in cmake.

2. Use make package to generate the RPM.

3. Run "rpm -qRp filename.rpm" on your rpm, and it will print out the list of stuff in the Required field of the RPM. It should have a very short list of items with no .so files included.

Instead, it lists all of the .so files that your program or library requires; stuff like

libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.7)(64bit)
No tags attached.
Issue History
2013-02-07 19:15Jonathan M DavisNew Issue
2013-02-08 04:39Eric NOULARDNote Added: 0032219
2013-02-08 04:39Eric NOULARDAssigned To => Eric NOULARD
2013-02-08 04:39Eric NOULARDStatusnew => assigned
2013-02-08 04:48Jonathan M DavisNote Added: 0032220
2013-02-09 07:44Eric NOULARDNote Added: 0032244
2013-02-09 07:44Eric NOULARDStatusassigned => resolved
2013-02-09 07:44Eric NOULARDResolutionopen => fixed
2013-07-01 09:37Robert MaynardNote Added: 0033418
2013-07-01 09:37Robert MaynardStatusresolved => closed

Notes
(0032219)
Eric NOULARD   
2013-02-08 04:39   
Hi Jonathan,

The problem is not where it seems to be.
the portion of code you quoted is not handling the "value" of
CPACK_RPM_PACKAGE_AUTOREQPROV but the name "AUTOREQPROV" itself
in order to produce:
"Autoreqprov" out of "AUTOREQPROV"
i.e. first letter upper-case and the tail being lower case.

Now the problem lies in this line
if(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)

when the value of "CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP"
namely "CPACK_RPM_PACKAGE_AUTOREQPROV" is either
0, NO, no, OFF then CMake 'if' command semantic says it is false!!
What we want in this case is

if (DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)

I'll prepare a patch for that.
(0032220)
Jonathan M Davis   
2013-02-08 04:48   
Oh well, then I guessed wrong, but I'm not very good at reading cmake string manipulation. It's a good thing that you figured it out in either case. I _did_ think that I'd tried either 01 or 12 and it didn't work though (I forget which). I'd messed around with shortening either 1234567890 or 0123456789 until it stopped working, and it stopped working at 2 characters, and then no did the name thing - it worked when I added characters but not otherwise (though that part fits with your explanation), so I'd come to the conclusion that it was an issue with the number of characters. But I may not remember what I did correctly. Regardless, the important thing is that the valid arguments to AutoReqProv work (as well as the arguments for any other of the variables in that loop), and no and 0 don't currently work. Thanks for the quick response time in any case.
(0032244)
Eric NOULARD   
2013-02-09 07:44   
Merge topic 'CPackRPM-fixSomeRPMSpecificVarHandling' into next

9be3da1 CPackRPM fix 0013898 uses IF(DEFINED var) to avoid wrong var value logic
(0033418)
Robert Maynard   
2013-07-01 09:37   
Closing resolved issues that have not been updated in more than 4 months.