[Pkg-qof-maintainers] Bug#462007: -dbg package generation

Neil Williams codehelp at debian.org
Thu Jan 24 22:52:39 UTC 2008


By following the flow of /usr/bin/dh_strip : debhelper
6.0.3

sub make_debug {
        my $file=shift;
        my $tmp=shift;
        my $desttmp=shift;

        my ($base_file)=$file=~/^\Q$tmp\E(.*)/;
        my $debug_path=$desttmp."/usr/lib/debug/".$base_file;
        my $debug_dir=dirname($debug_path);
        if (! -d $debug_dir) {
                doit("install", "-d", $debug_dir);
        }
        if (! -e $debug_path) {
                doit("objcopy", "--only-keep-debug", $file, $debug_path);
        }
        # No reason for this to be executable.
        doit("chmod", 644, $debug_path);
        return $debug_path;
}

neil at holly:lib$ objcopy --only-keep-debug libqof.so.1.0.9 mydebug.so
neil at holly:lib$ ls -l libqof.so.1.0.9 mydebug.so 
-rwxr-xr-x 1 neil neil 1030131 2008-01-21 14:08 libqof.so.1.0.9
-rw-r--r-- 1 neil neil  728803 2008-01-24 21:10 mydebug.so
neil at holly:lib$ objdump -g mydebug.so 

mydebug.so:     file format elf64-x86-64

objdump: mydebug.so: no recognized debugging information
neil at holly:lib$ ls -l /usr/lib/debug/usr/lib/libqof.so.1.0.9 
-rw-r--r-- 1 root root 1029686 2007-12-19 21:49 /usr/lib/debug/usr/lib/libqof.so.1.0.9
neil at holly:lib$ ls -l libqof.so.1.0.9 mydebug.so 
-rwxr-xr-x 1 neil neil 1030131 2008-01-21 14:08 libqof.so.1.0.9
-rw-r--r-- 1 neil neil  728803 2008-01-24 21:10 mydebug.so
neil at holly:lib$ objcopy --only-keep-debug /usr/lib/debug/usr/lib/libqof.so.1.0.9 mydebug2.so
neil at holly:lib$ ll libqof.so.1.0.9 mydebug.so mydebug2.so 
-rwxr-xr-x 1 neil neil 1030131 2008-01-21 14:08 libqof.so.1.0.9
-rw-r--r-- 1 neil neil  728710 2008-01-24 21:13 mydebug2.so
-rw-r--r-- 1 neil neil  728803 2008-01-24 21:10 mydebug.so

i.e. dh_strip -plibqof1  --dbg-package=libqof1-dbg
also appears to be doing the wrong thing because sub make_debug() in
dh_strip should call doit("objcopy", "--only-keep-debug", $file,
$debug_path); which I have tried to replicate above.

The result indicates to me that objcopy --only-keep-debug is not
actually being called during the QOF build.

I now follow what you initially described - the -dbg package is a
complete copy and objcopy --only-keep-debug has not been called.

The chmod command is being run, objcopy --only-keep-debug appears to not
be being run.

Is it this conditional at fault:
       if (! -e $debug_path) {
?

In my tests, the file exists before &make_debug() is called. Commenting
out the conditional reduces the file size:
$ ls -l debian/libqof1-dbg/usr/lib/debug//usr/lib/libqof.so.1.0.9
-rw-r--r-- 1 neil neil 1029686 2007-12-19 21:49 debian/libqof1-dbg/usr/lib/debug//usr/lib/libqof.so.1.0.9

$ ls -l debian/libqof1-dbg/usr/lib/debug//usr/lib/libqof.so.1.0.9
-rw-r--r-- 1 neil neil 728710 2008-01-24 21:54 debian/libqof1-dbg/usr/lib/debug//usr/lib/libqof.so.1.0.9

I understand why the conditional exists but it had unexpected results
for me.

Turns out that this is a bug in my packaging - I'd included a file:
$ cat debian/libqof1-dbg.install
debian/tmp/usr/lib/libqof*.so.* ./usr/lib/debug/usr/lib/

This installed the library (via dh_install) PRIOR to dh_strip being
called and the conditional in dh_strip means that objcopy is not being
called.

I can reproduce this in both CDBS and debhelper packages - simply by
creating an appropriate debian/libfoo-dbg.install file. The build
proceeds apparently normally but the final library in the -dbg package
contains entries in the Dynamic Section of objdump -p.

Remove the .install file for the -dbg package and the dynamic section
disappears with consequent drop in file size. Simple as that.

Nothing changes in the build, whether using a debhelper build or CDBS
build. There are no signs that dh_strip has come across an existing file
and has skipped 'objcopy --only-keep-debug' because the file was found
(for whatever reason). Maybe that would be a useful check / message in
dh_strip ? Even make it an error?

        if ( -e $debug_path) {
		error ("skipping separation of debug symbols: $debug_path exists.");
	}
	else
	{
                doit("objcopy", "--only-keep-debug", $file, $debug_path);
        }

?

I may consider a wishlist bug for lintian to check for this in future.
The symptoms are not obvious and the cause is a little counter-intuitive
(at least to me).

Maybe the manpage for dh_strip could be updated to indicate that
dh_strip will behave differently if the file already exists in the
debian/libfoo-dbg/usr/lib/debug/... path ?

I've also made the same error in other packages, don't worry about
cloning this bug, I'll make the updates at this end and fix things for
the next release in each case.

Thanks for your help with this one. I had no idea what was wrong
initially.

-- 


Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.alioth.debian.org/pipermail/pkg-qof-maintainers/attachments/20080124/f4c04a88/attachment-0001.pgp 


More information about the Pkg-qof-maintainers mailing list