From: Wichert Akkerman Date: Mon, 17 Jan 2000 20:49:55 +0000 (+0000) Subject: Switch to using objdump in dpkg-shlibdeps X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=601e0e45dd3b644aff5ad48f31857e4b250cb1d5;p=dpkg Switch to using objdump in dpkg-shlibdeps --- diff --git a/ChangeLog b/ChangeLog index 18c2795c..ee239c9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ Mon Jan 17 21:20:35 CET 2000 Wichert Akkerman * dselect/Makefile.in: not all shells support == for strings comparisons * version-nr: update to 1.6.8 + * scripts/dpkg-shlibdeps.pl: update to version from dpkg_test_bz2_syslog_sigs + branch: + + use objdump instead of ldd + + correct checks on shlibs.local Sat Jan 15 03:48:47 CET 2000 Wichert Akkerman diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index 56e0bfd9..4a6b2508 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -88,40 +88,83 @@ sub isbin { for ($i=0;$i<=$#exec;$i++) { if (!isbin ($exec[$i])) { next; } - defined($c= open(P,"-|")) || syserr("cannot fork for ldd"); - if (!$c) { exec("ldd","--",$exec[$i]); syserr("cannot exec ldd"); } - $nthisldd=0; + defined($c= open(P,"-|")) || syserr("cannot fork for objdump"); + if (!$c) { exec("objdump","-p","--",$exec[$i]); syserr("cannot exec objdump"); } while (

) { - chomp; - if (m,^\s+(\S+)\s+\=\>\s+\1$,) { - # shared libraries depend on themselves (unsure why) - # Only under old ld.so - $nthisldd++; - } elsif (m,\s+statically linked(\s+\(ELF\))?$,) { - $nthisldd++; - } elsif (m,^\s+(\S+)\.so\.(\S+)\s+=>\s+(/\S+)(\s+\(0x.+\))?$,) { - push(@libname,$1); push(@libsoname,$2); push(@libpath,$3); + chomp; + if (m,^\s*NEEDED\s+(\S+)\.so\.(\S+)$,) { + push(@libname,$1); push(@libsoname,$2); push(@libf,$execf[$i]); - push(@libpaths,$3) if !$libpathadded{$3}++; - $nthisldd++; - } else { - &warn("unknown output from ldd on \`$exec[$i]': \`$_'"); + push(@libfiles,"$1.so.$2"); } } - close(P); $? && subprocerr("ldd on \`$exec[$i]'"); - $nthisldd || &warn("ldd on \`$exec[$i]' gave nothing on standard output"); + close(P); $? && subprocerr("objdump on \`$exec[$i]'"); } -if ($#libpaths >= 0) { - grep(s/\[\?\*/\\$&/g, @libpaths); +# Now: See if it is in this package. See if it is in any other package. +sub searchdir { + my $dir = shift; + if(opendir(DIR, $dir)) { + my @dirents = readdir(DIR); + closedir(DIR); + for (@dirents) { + if ( -f "$dir/$_/DEBIAN/shlibs" ) { + push(@curshlibs, "$dir/$_/DEBIAN/shlibs"); + next; + } elsif ( $_ !~ /^\./ && -d "$dir/$_" ) { + &searchdir("$dir/$_"); + } + } + } +} + +$searchdir = $exec[0]; +$curpackdir = "debian/tmp"; +do { $searchdir =~ s,/[^/]*$,,; } while($searchdir =~ m,/, && ! -d "$searchdir/DEBIAN"); +if ($searchdir =~ m,/,) { + $curpackdir = $searchdir; + $searchdir =~ s,/[^/]*,,; + &searchdir($searchdir); +} + +if ($#curshlibs >= 0) { + PRELIB: for ($i=0;$i<=$#libname;$i++) { + if(scanshlibsfile($shlibsdefault,$libname[$i],$libsoname[$i],$libf[$i]) + || scanshlibsfile($shlibsoverride,$libname[$i],$libsoname[$i],$libf[$i])) { + splice(@libname, $i, 1); + splice(@libsoname, $i, 1); + splice(@libf, $i, 1); + splice(@libfiles, $i, 1); + $i--; + next PRELIB; + } + for my $shlibsfile (@curshlibs) { + 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); + $i--; + next PRELIB; + } + } + } +} + +if ($#libfiles >= 0) { + grep(s/\[\?\*/\\$&/g, @libname); defined($c= open(P,"-|")) || syserr("cannot fork for dpkg --search"); - if (!$c) { exec("dpkg","--search","--",@libpaths); syserr("cannot exec dpkg"); } + if (!$c) { + close STDERR; # we don't need to see dpkg's errors + open STDERR, "> /dev/null"; + exec("dpkg","--search","--",map {"*/$_"} @libfiles); syserr("cannot exec dpkg"); + } while (

) { - s/\n$//; + chomp; 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+)*): (/.+)$=) { + } elsif (m=^(\S+(, \S+)*): /.+/([^/]+)$=) { $pathpackages{$+}= $1; } else { &warn("unknown output from dpkg --search: \`$_'"); @@ -131,22 +174,20 @@ if ($#libpaths >= 0) { } LIB: for ($i=0;$i<=$#libname;$i++) { - scanshlibsfile($shlibslocal,$libname[$i],$libsoname[$i],$libf[$i]) && next; - scanshlibsfile($shlibsoverride,$libname[$i],$libsoname[$i],$libf[$i]) && next; - if (!defined($pathpackages{$libpath[$i]})) { - &warn("could not find any packages for $libpath[$i]". + if (!defined($pathpackages{$libfiles[$i]})) { + &warn("could not find any packages for $libfiles[$i]". " ($libname[$i].so.$libsoname[$i])"); } else { - @packages= split(/, /,$pathpackages{$libpath[$i]}); + @packages= split(/, /,$pathpackages{$libfiles[$i]}); for $p (@packages) { scanshlibsfile("$shlibsppdir/$p$shlibsppext", $libname[$i],$libsoname[$i],$libf[$i]) && next LIB; } } - scanshlibsfile($shlibsdefault,$libname[$i],$libsoname[$i],$libf[$i]) && next; + scanshlibsfile($shlibslocal,$libname[$i],$libsoname[$i],$libf[$i]) && next; &warn("unable to find dependency information for ". - "shared library $libname[$i] (soname $libsoname[$i], path $libpath[$i], ". + "shared library $libname[$i] (soname $libsoname[$i], path $libfiles[$i], ". "dependency field $libf[$i])"); } @@ -167,6 +208,7 @@ sub scanshlibsfile { next; } next if $1 ne $ln || $2 ne $lsn; + return 1 if $fn eq "debian/$curpackdir/DEBIAN/shlibs"; $da= $'; for $dv (split(/,/,$da)) { $dv =~ s/^\s+//; $dv =~ s/\s+$//;