Bug#285857: dpkg-dev: dpkg-shlibdeps should try adding /usr
Hi,
On Thu 16 dec 2004 at 17:53:03 +0100, Goswin von Brederlow wrote:
> Samuel Thibault <samuel.thibault@ens-lyon.org> writes:
>
> > Another solution would be (when ldd returns /lib/libbar.so.1.0),
> > instead of calling dpkg --search /lib/libbar.so.1.0, to
> > call dpkg --search libbar.so.1.0, which will return
> >
> > libbar: /usr/lib/libbar.so.1.0
> >
> > and then check that /lib/libbar.so.1.0 and /usr/lib/libbar.so.1.0
> > really are the same file: same device, same inode.
> >
> > It is possible that dpkg --search returns several results: dpkg --search
> > libm-2.3.2.so for instance (tls and non-tls versions). A loop would
> > check out which one corresponds to ldd's result.
> >
> > Regards,
> > Samuel
>
> Exactly my thoughts.
Here is a patch doing that: it renames libfiles into libpaths, libfiles
really being the library *files* that we search, and libpaths the paths
where ldd found them. It also renames pathpackages into filepackages,
since it is now indexed by library *files* (and not paths). And
new filepackagespath is the path the package provides. Then stat lets
us decide which package is the good one.
I tried it, it worked for libraries provided as /usr/lib/libbar
in some package but appearing in /lib. It also correctly found the
libc6-dbg package when launched with LD_LIBRARY_PATH=/lib/debug, so I
guess it will also work for your lib64 troubles.
--- /usr/bin/dpkg-shlibdeps 2004-11-11 21:15:52.000000000 +0100
+++ /mnt/hurd/usr/bin/dpkg-shlibdeps 2004-12-27 15:51:54.000000000 +0100
@@ -8,6 +8,7 @@
use POSIX;
use POSIX qw(:errno_h :signal_h);
+use File::stat;
$shlibsoverride= '/etc/dpkg/shlibs.override';
$shlibsdefault= '/etc/dpkg/shlibs.default';
@@ -119,14 +120,16 @@
if (m,^\s*NEEDED\s+,) {
if (m,^\s*NEEDED\s+((\S+)\.so\.(\S+))$,) {
push(@libname,$2); push(@libsoname,$3);
+ push(@libfiles,$1);
push(@libf,$execf[$i]);
&warn("could not find path for $1") unless defined($so2path{$1});
- push(@libfiles,$so2path{$1});
+ push(@libpaths,$so2path{$1});
} elsif (m,^\s*NEEDED\s+((\S+)-(\S+)\.so)$,) {
push(@libname,$2); push(@libsoname,$3);
+ push(@libfiles,$1);
push(@libf,$execf[$i]);
&warn("could not find path for $1") unless defined($so2path{$1});
- push(@libfiles,$so2path{$1});
+ push(@libpaths,$so2path{$1});
} else {
m,^\s*NEEDED\s+(\S+)$,;
&warn("format of $1 not recognized");
@@ -168,8 +171,9 @@
|| scanshlibsfile($shlibsoverride,$libname[$i],$libsoname[$i],$libf[$i])) {
splice(@libname, $i, 1);
splice(@libsoname, $i, 1);
- splice(@libf, $i, 1);
splice(@libfiles, $i, 1);
+ splice(@libf, $i, 1);
+ splice(@libpaths, $i, 1);
$i--;
next PRELIB;
}
@@ -177,8 +181,9 @@
if(scanshlibsfile($shlibsfile, $libname[$i], $libsoname[$i], $libf[$i])) {
splice(@libname, $i, 1);
splice(@libsoname, $i, 1);
- splice(@libf, $i, 1);
splice(@libfiles, $i, 1);
+ splice(@libf, $i, 1);
+ splice(@libpaths, $i, 1);
$i--;
next PRELIB;
}
@@ -200,8 +205,11 @@
if (m/^local diversion |^diversion by/) {
&warn("diversions involved - output may be incorrect");
print(STDERR " $_\n") || syserr("write diversion info to stderr");
- } elsif (m=^(\S+(, \S+)*): (\S+)$=) {
- push @{$pathpackages{$+}}, split(/, /, $1);
+ } elsif (m=^(\S+(, \S+)*): (/(\S+/)*(\S+))$=) {
+ for $p (split(/, /, $1)) {
+ push(@{$filepackages{$+}}, $p);
+ push(@{$filepackagespath{$+}}, $3);
+ }
} else {
&warn("unknown output from dpkg --search: \`$_'");
}
@@ -210,19 +218,25 @@
}
LIB: for ($i=0;$i<=$#libname;$i++) {
- if (!defined($pathpackages{$libfiles[$i]})) {
- &warn("could not find any packages for $libfiles[$i]".
+ if (!defined($filepackages{$libfiles[$i]})) {
+ &warn("could not find any packages for $libpaths[$i]".
" ($libname[$i].so.$libsoname[$i])");
} else {
- for $p (@{$pathpackages{$libfiles[$i]}}) {
- scanshlibsfile("$shlibsppdir/$p$shlibsppext",
+ @pl = @{$filepackages{$libfiles[$i]}};
+ for ($j=0;$j<=$#pl;$j++) {
+ $stl = stat($libpaths[$i]);
+ $stp = stat($filepackagespath{$libfiles[$i]}[$j]);
+ if ($stl->dev != $stp->dev || $stl->ino != $stp->ino) {
+ next;
+ }
+ scanshlibsfile("$shlibsppdir/$pl[$j]$shlibsppext",
$libname[$i],$libsoname[$i],$libf[$i])
&& next LIB;
}
}
scanshlibsfile($shlibsdefault,$libname[$i],$libsoname[$i],$libf[$i]) && next;
&warn("unable to find dependency information for ".
- "shared library $libname[$i] (soname $libsoname[$i], path $libfiles[$i], ".
+ "shared library $libname[$i] (soname $libsoname[$i], path $libpaths[$i], ".
"dependency field $libf[$i])");
}
Reply to: