From 5d139acefcc19b15ae81fcf2b746e258b14d5a71 Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Wed, 28 Nov 2007 10:33:53 +0100 Subject: [PATCH] dpkg-shlibdeps: Always try the realpath of the lib as fallback to identify the associated package * scripts/dpkg-shlibdeps.pl (find_packages): Make sure to always return [''] for a miss in the 'dpkg -S' query. * scripts/dpkg-shlibdeps.pl: Always try the realpath($lib) as fallback to identify the package (even if it's not a symlink) because due to broken RPATH we might get library filenames such as "/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/libssl.so.9.8" which is not a symlink and which can still be simplified to "/usr/lib/libssl.so.9.8" with realpath(). --- ChangeLog | 11 +++++++++++ debian/changelog | 2 ++ scripts/dpkg-shlibdeps.pl | 13 ++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c02b388..6760adce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-11-28 Raphael Hertzog + + * scripts/dpkg-shlibdeps.pl (find_packages): Make sure to always + return [''] for a miss in the 'dpkg -S' query. + * scripts/dpkg-shlibdeps.pl: Always try the realpath($lib) as + fallback to identify the package (even if it's not a symlink) + because due to broken RPATH we might get library filenames such as + "/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/libssl.so.9.8" + which is not a symlink and which can still be simplified to + "/usr/lib/libssl.so.9.8" with realpath(). + 2007-11-25 Raphael Hertzog * scripts/Dpkg/Shlibs.pm (find_library): Canonicalize paths before diff --git a/debian/changelog b/debian/changelog index 87c3292e..8ef98fb4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ dpkg (1.14.12) UNRELEASED; urgency=low * Add -I option to dpkg-gensymbols to force the usage of a specific symbols file. * Dpkg::Shlibs::find_library() now returns canonicalized paths. + * dpkg-shlibdeps always tries the realpath() of a lib as fallback when + trying to identify the package of a lib (and not only for symlinks). -- Guillem Jover Sat, 24 Nov 2007 07:38:13 +0200 diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index 1fe4b7a9..420afafe 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -103,8 +103,9 @@ foreach my $file (keys %exec) { "'shlibs' files are looked into)."), $soname) unless defined($lib); $libfiles{$lib} = $soname; - if (-l $lib) { - $altlibfiles{realpath($lib)} = $soname; + my $reallib = realpath($lib); + if ($reallib ne $lib) { + $altlibfiles{$reallib} = $soname; } print "Library $soname found in $lib\n" if $debug; } @@ -114,15 +115,16 @@ foreach my $file (keys %exec) { my @soname_wo_symfile; foreach my $lib (keys %libfiles) { my $soname = $libfiles{$lib}; - if (not exists $file2pkg->{$lib} and -l $lib) { - # If the lib found is an unpackaged symlink, we try a fallback + if (not scalar(grep { $_ ne '' } @{$file2pkg->{$lib}})) { + # The path of the library as calculated is not the + # official path of a packaged file, try to fallback on # on the realpath() first, maybe this one is part of a package my $reallib = realpath($lib); if (exists $file2pkg->{$reallib}) { $file2pkg->{$lib} = $file2pkg->{$reallib}; } } - if (not exists $file2pkg->{$lib}) { + if (not scalar(grep { $_ ne '' } @{$file2pkg->{$lib}})) { # If the library is really not available in an installed package, # it's because it's in the process of being built # Empty package name will lead to consideration of symbols @@ -529,6 +531,7 @@ sub find_packages { } else { push @files, $_; $cached_pkgmatch{$_} = [""]; # placeholder to cache misses too. + $pkgmatch->{$_} = [""]; # might be replaced later on } } return $pkgmatch unless scalar(@files); -- 2.39.5