=================================================================== RCS file: /cvs/openbsd/fill_chroot/find_depends,v retrieving revision 1.7 retrieving revision 1.11 diff -u -r1.7 -r1.11 --- openbsd/fill_chroot/find_depends 2008/04/22 21:08:41 1.7 +++ openbsd/fill_chroot/find_depends 2008/09/16 23:28:53 1.11 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $RedRiver: find_depends,v 1.6 2007/05/16 19:55:42 andrew Exp $ +# $RedRiver: find_depends,v 1.10 2008/09/16 22:15:03 andrew Exp $ use strict; use warnings; @@ -66,19 +66,36 @@ my @libs = search_file($file); foreach (@libs) { - my ($name, $maj, $min) = $_ =~ /lib([^\/]+)\.so\.(\d+)\.(\d+)$/; - my $spec = 'l' . $name . '.' . $maj . '.' . $min; + my $spec; + + if (/\/ld\.so$/) { + $spec = $_; + } + else { + if ( my ($name, $maj, $min) = $_ =~ /lib([^\/]+)\.so\.(\d+)\.(\d+)$/ ) { + $spec = 'l' . $name . '.' . $maj . '.' . $min; + } + } - if (exists $ld->{$spec}) { - next if exists $locs->{$spec}; + next if ! $spec; + next if exists $locs->{$spec}; - $locs->{$spec} = $ld->{$spec}; + print " Found spec '$spec'\n" if $opts{v}; - $locs = find_libs($locs->{$spec}, $ld, $locs); - - } else { - warn "Couldn't find location for lib '$_' (file '$file')"; + if (-e $spec) { + $locs->{$spec} = $spec; } + else { + $locs->{$spec} = $ld->{$spec}; + } + + if (! $locs->{$spec}) { + print STDERR "Couldn't find location for '$_' (file '$file')\n"; + next; + } + + $locs = find_libs($locs->{$spec}, $ld, $locs); + } return $locs; @@ -92,7 +109,8 @@ open my $libs, '-|', '/usr/bin/ldd', $file or die "Couldn't open ldd '$file': $!"; while (<$libs>) { chomp; - my $spec = substr $_, 56; + my ($spec) = (split(/\s+/, $_))[7]; + next if ! $spec; next if $spec !~ m{^/}xms; push @libs, $spec; }