=================================================================== RCS file: /cvs/openbsd/fill_chroot/find_depends,v retrieving revision 1.8 retrieving revision 1.12 diff -u -r1.8 -r1.12 --- openbsd/fill_chroot/find_depends 2008/05/05 19:58:18 1.8 +++ openbsd/fill_chroot/find_depends 2008/09/16 23:38:04 1.12 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $RedRiver: find_depends,v 1.7 2008/04/22 20:08:41 andrew Exp $ +# $RedRiver: find_depends,v 1.11 2008/09/16 22:28:53 andrew Exp $ use strict; use warnings; @@ -66,20 +66,35 @@ my @libs = search_file($file); foreach (@libs) { - my ($name, $maj, $min) = $_ =~ /lib([^\/]+)\.so\.(\d+)\.(\d+)$/; - next if ! $name; - my $spec = 'l' . $name . '.' . $maj . '.' . $min; + my $spec; + + if ($_ eq $file) { + # We don't want to include the file we are looking in + next; + } + elsif ( my ($name, $maj, $min) = $_ =~ /lib([^\/]+)\.so\.(\d+)\.(\d+)$/ ) { + $spec = 'l' . $name . '.' . $maj . '.' . $min; + if ($ld->{$spec}) { + $locs->{$spec} = $ld->{$spec}; + } + } + elsif (-e $_) { + $spec = $_; + $locs->{$spec} = $spec; + } + else { + next; + } - if (exists $ld->{$spec}) { - next if exists $locs->{$spec}; + if (! $locs->{$spec}) { + print STDERR "Couldn't find location for '$_' (file '$file')\n"; + next; + } - $locs->{$spec} = $ld->{$spec}; + print " Found '$spec' => '$locs->{$spec}'\n" if $opts{v}; - $locs = find_libs($locs->{$spec}, $ld, $locs); + $locs = find_libs($locs->{$spec}, $ld, $locs); - } else { - warn "Couldn't find location for lib '$_' (file '$file')"; - } } return $locs; @@ -92,9 +107,9 @@ open my $libs, '-|', '/usr/bin/ldd', $file or die "Couldn't open ldd '$file': $!"; while (<$libs>) { - next if length($_) < 56; chomp; - my $spec = substr $_, 56; + my ($spec) = (split(/\s+/, $_))[7]; + next if ! $spec; next if $spec !~ m{^/}xms; push @libs, $spec; }