diff options
author | Raphaël Hertzog <hertzog@debian.org> | 2016-11-14 11:46:09 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2016-12-19 02:36:54 +0100 |
commit | a927295c93fb7a17742441aa863aaffcf4a351b5 (patch) | |
tree | d866ca9ccc8913e469fd7b26ef2d51a0707c6263 /scripts/dpkg-shlibdeps.pl | |
parent | cff8e24ca76451a4a52cea6b05e8a76dcd1f5ecf (diff) | |
download | dpkg-a927295c93fb7a17742441aa863aaffcf4a351b5.tar.gz |
dpkg-shlibdeps: Improve logic to identify packages owning a library
With things like merged-/usr, a system might have libraries that are
stored for example in /usr/lib but that dpkg knows under /lib. This
breaks some of the initial assumptions made in dpkg-shlibdeps.
We now scan all possible paths for a given library (instead of trying
to guess which one is the canonical one) and whenever we find a match
in the dpkg database, we also associate the package for the associated
realpath(). That way when a library is not properly identified, we can
fallback on looking if its realpath is known and be confident that if
the library was packaged, we did identify it correctly.
[guillem@debian.org:
- Fold find_library_locations() into find_library().
- Minor coding style fixes.
- Squash the two separate commits and cleanup the commit message. ]
Closes: #843073
Signed-off-by: Guillem Jover <guillem@debian.org>
Diffstat (limited to 'scripts/dpkg-shlibdeps.pl')
-rwxr-xr-x | scripts/dpkg-shlibdeps.pl | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index 3204026d8..e121aaea3 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -6,7 +6,7 @@ # Copyright © 2000 Wichert Akkerman # Copyright © 2006 Frank Lichtenheld # Copyright © 2006-2010,2012-2015 Guillem Jover <guillem@debian.org> -# Copyright © 2007 Raphaël Hertzog +# Copyright © 2007, 2016 Raphaël Hertzog <hertzog@debian.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -192,8 +192,8 @@ foreach my $file (keys %exec) { my %soname_notfound; my %alt_soname; foreach my $soname (@sonames) { - my $lib = my_find_library($soname, $obj->{RPATH}, $obj->{format}, $file); - unless (defined $lib) { + my @libs = my_find_library($soname, $obj->{RPATH}, $obj->{format}, $file); + unless (scalar @libs) { $soname_notfound{$soname} = 1; $global_soname_notfound{$soname} = 1; my $msg = g_("couldn't find library %s needed by %s (ELF " . @@ -206,12 +206,14 @@ foreach my $file (keys %exec) { } next; } - $libfiles{$lib} = $soname; - my $reallib = realpath($lib); - if ($reallib ne $lib) { - $altlibfiles{$reallib} = $soname; - } - print "Library $soname found in $lib\n" if $debug; + foreach my $lib (@libs) { + $libfiles{$lib} = $soname; + my $reallib = realpath($lib); + if ($reallib ne $lib) { + $altlibfiles{$reallib} = $soname; + } + print "Library $soname found in $lib\n" if $debug; + } } my $file2pkg = find_packages(keys %libfiles, keys %altlibfiles); my $symfile = Dpkg::Shlibs::SymbolFile->new(); @@ -830,17 +832,14 @@ sub my_find_library { foreach my $builddir (@builddirs) { next if defined($dir_checked{$builddir}); next if ignore_pkgdir($builddir); - $file = find_library($lib, \@RPATH, $format, $builddir); - return $file if defined($file); + my @libs = find_library($lib, \@RPATH, $format, $builddir); + return @libs if scalar @libs; $dir_checked{$builddir} = 1; } # Fallback in the root directory if we have not found what we were # looking for in the packages - $file = find_library($lib, \@RPATH, $format, ''); - return $file if defined($file); - - return; + return find_library($lib, \@RPATH, $format, ''); } my %cached_pkgmatch = (); @@ -879,7 +878,9 @@ sub find_packages { or syserr(g_('write diversion info to stderr')); } elsif (m/^([-a-z0-9+.:, ]+): (\/.*)$/) { my ($pkgs, $path) = ($1, $2); + my $realpath = realpath($path); $cached_pkgmatch{$path} = $pkgmatch->{$path} = [ split /, /, $pkgs ]; + $cached_pkgmatch{$realpath} = $pkgmatch->{$realpath} = [ split /, /, $pkgs ]; } else { warning(g_("unknown output from dpkg --search: '%s'"), $_); } |