=================================================================== RCS file: /cvs/openbsd/fill_chroot/find_depends,v retrieving revision 1.2 retrieving revision 1.4 diff -u -r1.2 -r1.4 --- openbsd/fill_chroot/find_depends 2005/12/21 18:16:03 1.2 +++ openbsd/fill_chroot/find_depends 2005/12/21 18:37:38 1.4 @@ -1,15 +1,27 @@ #!/usr/bin/perl -# $RedRiver: find_depends,v 1.1 2005/12/21 18:04:06 andrew Exp $ +# $RedRiver: find_depends,v 1.3 2005/12/21 18:22:32 andrew Exp $ use strict; use warnings; -# find /home/andrew/www/ -name *.so* | xargs find_depends | sort -u | xargs -I {} cp {} /home/andrew/www{} +use Data::Dumper; -die unless @ARGV; +my %opts; +my @Files; +foreach (@ARGV) { + if (/^-+(\w+)$/) { + $opts{$1} = 1; + } else { + push @Files, $_; + } +} + +Help() if $opts{h} || $opts{help}; +Usage() unless @Files; + my %libs; -foreach my $file (@ARGV) { +foreach my $file (@Files) { my $l = find_libs($file); foreach (keys %{ $l }) { @@ -23,13 +35,36 @@ exit; +sub Usage +{ + print "Usage: $0 [-v] file [file2 [file3 [...]]]\n"; + exit; +} + +sub Help +{ + print <) { if (m|^(/[^\w\/]+/)?lib(\S+)\.(\d+)\.(\d+)|) { @@ -78,7 +113,8 @@ my $ldconfig = '/sbin/ldconfig'; my (%paths, %libs); - open my $ld, '-|', $ldconfig, '-r' or die; + open my $ld, '-|', $ldconfig, '-r' + or die "Couldn't open pipe to ldconfig: $!"; while (<$ld>) { chomp; if (/search directories:\s+(.*)/) {