[CMake] Debuginfo builds and CPack RPM support

Joe Nardone jnardone at gmail.com
Mon Dec 3 16:00:05 EST 2012


On Mon, Dec 3, 2012 at 2:06 PM, Eric Noulard <eric.noulard at gmail.com> wrote:
>> The canonical way on conformant platforms is to include %debug_package in
>> the SPEC file, which triggers a number of actions, namely to
>> find-debuginfo.sh (which creates the debug files and generates a sub-package
>> in the RPM spec that includes this.)
>
> Where should the %debug_package be placed in the spec file?
> i.e. in which section (prep, build, install, ...)

It's a macro that essentially expands to its own section; in my
testing, I've been able to put it at the end of the spec file with the
intended effect.  It's visible in /usr/lib/rpm/macros on at least
Fedora, RHEL/CentOS, and Ubuntu (with RPM tools installed).

Relevant snippet starts with:
#       Template for debug information sub-package.
%debug_package \
...
%package debug\
Summary: Debug information for package %{name}\
...

However, there is no option to change how this sub-package is named.
This causes a problem because of CPack's _rpmfilename.

>
>> However, CPack's RPM generator does not play nice with this.  Since it has a
>> fixed RPM name and not a template, what ends up happening is the sub-package
>> overwrites the main installer (using the same name).  Attempts to change the
>> rpm name to a template confuse the upstream CPack, which assumes a single
>> installer with the same name as it provided to the module.
>
> What do you mean by a "template"  do you mean that the
> "Name:           package_name"
> could be templated in some way?

I'm speaking specifically to _rpmfilename; I believe there's an open
issue on this.  _rpmfilename can use placeholders with RPM (which RPM
subpackages utilize by appending the sub-package name to the package
name, however because CPackRPM uses a fixed string vs. variable
substitution, this can't be used.  The default in RPM is
%%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm but CPack sets
this to a fixed literal.).  For this approach to work, we'd at least
need to use an _rpmfilename with %%{NAME} in it, as %debug_package
will add a subpackage called 'debug' (resulting in a package name that
is %%{NAME}-%%{SUBPACKAGENAME} (e.g. foo-debug.....rpm)

Ref: http://www.rpm.org/max-rpm/s1-rpm-subpack-spec-file-changes.html

It's going to be exceedingly difficult to do this without leveraging
RPM's %{NAME} var, at least during RPM building (we could rename
after).  See below.

>
> Could you give me an example or a pointer explaining how this could be
> templated?
>

Here's how I can generate both packages, but of course CPack doesn't
know how to find them/rename them.

1) Changed spec file to %define _rpmfilename foo-0.42.0-Linux-%%{NAME}.rpm
    (this had been foo-0.42.0-Linux.rpm as populated by CPackRPM.cmake)
2) Added %debug_package prior to %description, but it can go anywhere
3) Built with this spec file.  This generated two RPM files:
    foo-0.42.0-Linux-foo.rpm
    foo-0.42.0-Linux-foo-debug.rpm

At this point, we could rename files to remove the extraneous %%{NAME}
from the name and then move anything foo-0.42.0-Linux*.rpm to the
right place.

> The problem you discovered is the fact that CPack must know how many
> package files (with their name) are spitted out from rpmbuild in order to move
> them from CPack private location to the root of the build tree at the
> end of the process.
>
> We could make CPackRPM aware of debuginfo feature by adding a new
> CPACK_RPM_DEBUGINFO which would trigger the feature.
>
> Is the debuginfo generation distribution-specific or is it the same
> for Fedora, Mandriva, OpenSuSE or any other RPM-based distro?

I verified that the RPM macros exist on CentOS, Fedora, Ubuntu (with
RPM tools), and Mandriva.

Joe


More information about the CMake mailing list