Building an RPM: debuginfo package not being created

(Very short version, for the benefit of the frustrated: comments in RPM SPEC files don't do what you think).

I was building an RPM for NXLOG (http://nxlog-ce.sourceforge.net/) because I needed to get a debuginfo package in order to help diagnose a memory leak from the vendor's supplied SPEC file. NXLOG helpfully includes a make_rpm.sh script in its source-code. What I expected to see near the end of the build was the following output:

...
Wrote: /home/cameron/src/rpm/SRPMS/nxlog-ce-2.8.1248-1.src.rpm
Wrote: /home/cameron/src/rpm/RPMS/x86_64/nxlog-ce-2.8.1248-1.x86_64.rpm
Wrote: /home/cameron/src/rpm/RPMS/x86_64/nxlog-ce-debuginfo-2.8.1248-1.x86_64.rpm
...

However, it wasn't building the debuginfo package (that line was missing).


Firstly, make sure you have the redhat-rpm-config package installed, and a debuginfo package should be built by default. If not, then something may be disabling it (such as something in ~/.rpmmacros). But I didn't get the debuginfo package.

Second, check the SPEC file. In this particular case, there was a line at the top that said the following:

#%define debug_package 1

Anyone would think that that's a comment... and unfortunately, you'd be only partly correct. What we really needed was to either remove the line altogether, or write it as:

#%%define debug_package 1

This is due to the macros being evaluated as part of the proprocessing stage (the macros don't intepret the comment lines). In a multiline-macro, this would cause only the first line to be commented. Thank goodness for Aaron D. Marasco's comment regarding this on Stack Overflow.

But why would removing the line entirely make it work? Because in any recent rpm environment, the debuginfo stuff should be built automatically, from about Fedora 9 onwards (not sure if that would include RHEL 5, but it does cover RHEL 6). The automatic building of debuginfo packages was announced in 2003. That's what the 'redhat-rpm-config' package is reponsible for. Otherwise, you might need to include the %define debug_package 1

Note that disabling the debuginfo from your SPEC file should only really be done with good reason (eg. it doesn't make sense to provide debuginfo packages).

Hope that helps,
Cameron

Comments

Popular posts from this blog

ORA-12170: TNS:Connect timeout — resolved

Getting MySQL server to run with SSL

From DNS Packet Capture to analysis in Kibana