Package: libdpkg-perl
Version: 1.17.22
File: /usr/share/perl5/Dpkg/Shlibs.pm
Tags: patch
User: helm...@debian.org
Usertags: rebootstrap

I hit a case where dpkg-shlibdeps returns bogus dependencies e.g.
libc6-amd64 with DEB_HOST_ARCH=amd64. It can happen when you install
e.g. libc6:amd64 and libc6-amd64:i386. The quick answer here is: Don't
do that then. Unfortunately, things are not as easy. Turns out this
problem also arises when you install libc6:amd64 and
libc6-amd64-i386-cross:all and that both of these are (indirectly)
build-depended upon by gcc-4.9. So just installing Build-Depends results
in this situation.  In this case, the cross compiler has a versioned
dependency on libc6-amd64. The foreign architecture got lost when
dpkg-cross failed to convert the .symbols file.

This raises the question: Why was the multilib libc selected over the
multiarch libc? Looking into /etc/ld.so.conf.d, one can see that glibc
explicitly prefers multiarch over multilib and running ldd on any
dynamically linked binary confirms this for the libc. Looking into
dpkg-shlibdeps and in particular Shlibs.pm one can see that it hardcodes
the library search path to prefer multilib over multiarch (exactly the
other way round): multilib paths are included in DEFAULT_LIBRARY_PATH
and multiarch paths are later appended in parse_ldso_conf. I am
therefore proposing the attached patch to change the library path order
from:

LD_LIBRARY_PATH > DEFAULT_LIBRARY_PATH > crosslibrarypaths > ld.so.conf

to:

LD_LIBRARY_PATH > non multilib part of DEFAULT_LIBRARY_PATH > ld.so.conf >
multilib part of DEFAULT_LIBRARY_PATH > crosslibrarypaths

After applying this patch, libc6 is preferred over libc6-amd64 by
dpkg-shlibdeps.

Helmut
diff -Nru dpkg-1.17.22/debian/changelog dpkg-1.17.22+nmu1/debian/changelog
--- dpkg-1.17.22/debian/changelog
+++ dpkg-1.17.22+nmu1/debian/changelog
@@ -1,3 +1,10 @@
+dpkg (1.17.22+nmu1) UNRELEASED; urgency=low
+
+  * Non-maintainer upload.
+  * Fix dpkg-shlibdeps to use same search order as ld.so. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Fri, 05 Dec 2014 21:11:43 +0100
+
 dpkg (1.17.22) unstable; urgency=low
 
   [ Guillem Jover ]
diff -Nru dpkg-1.17.22/scripts/Dpkg/Shlibs.pm 
dpkg-1.17.22+nmu1/scripts/Dpkg/Shlibs.pm
--- dpkg-1.17.22/scripts/Dpkg/Shlibs.pm
+++ dpkg-1.17.22+nmu1/scripts/Dpkg/Shlibs.pm
@@ -36,7 +36,9 @@
                   gnutriplet_to_multiarch debarch_to_multiarch);
 
 use constant DEFAULT_LIBRARY_PATH =>
-    qw(/lib /usr/lib /lib32 /usr/lib32 /lib64 /usr/lib64
+    qw(/lib /usr/lib);
+use constant DEFAULT_MULTILIB_PATH =>
+    qw(/lib32 /usr/lib32 /lib64 /usr/lib64
        /emul/ia32-linux/lib /emul/ia32-linux/usr/lib);
 
 # Adjust set of directories to consider when we're in a situation of a
@@ -67,7 +69,7 @@
             "/$crossprefix/lib64", "/usr/$crossprefix/lib64";
 }
 
-my @librarypaths = (DEFAULT_LIBRARY_PATH, @crosslibrarypaths);
+my @librarypaths = (DEFAULT_LIBRARY_PATH);
 
 # XXX: Deprecated. Update library paths with LD_LIBRARY_PATH
 if ($ENV{LD_LIBRARY_PATH}) {
@@ -80,6 +82,9 @@
 # Update library paths with ld.so config
 parse_ldso_conf('/etc/ld.so.conf') if -e '/etc/ld.so.conf';
 
+push @librarypaths, DEFAULT_MULTILIB_PATH;
+push @librarypaths, @crosslibrarypaths;
+
 my %visited;
 sub parse_ldso_conf {
     my $file = shift;

Reply via email to