How to check applications vs. libraries
Warren Block
wblock at wonkity.com
Wed Oct 3 15:01:52 PDT 2007
On Wed, 3 Oct 2007, Mel wrote:
> I use the following little php script to identify programs/libraries still
> using old libs:
> #!/usr/local/bin/php -q
> <?php
> // vim: ts=4 sw=4 noet ai tw=78
> $localbase = getenv('LOCALBASE');
> if(!$localbase)
> $localbase='/usr/local';
> $cmd_fmt = '/usr/bin/ldd %s 2>/dev/null| grep compat/pkg';
> $search_paths = array('bin', 'sbin', 'lib', 'libexec');
> chdir($localbase);
> foreach($search_paths AS $path)
> {
> echo("==> $path\n");
> $files = glob("$path/*");
> foreach($files AS $file)
> {
> $check = shell_exec(sprintf($cmd_fmt, $file));
> if( empty($check) )
> continue;
> // pretty print reformat
> $check = preg_replace('/^.*?=>/m', "\t\t=>", $check);
> echo("\t$file depends on:\n$check");
> }
> }
> ?>
Interesting. Here's a Ruby version, which shows either I have no
old dependencies or that I just didn't translate it correctly:
#!/usr/local/bin/ruby
localbase = ENV["LOCALBASE"] || '/usr/local'
Dir.chdir(localbase)
%w( bin sbin lib libexec ).each do |path|
puts path
Dir.glob(path + '/*').each do |file|
check = `/usr/bin/ldd "#{file}" 2>/dev/null | grep compat/pkg`
next if check.empty?
check.sub!(/^.*?=>/m, "\t\t=>")
puts "\t#{file} depends on:\n#{check}"
end
end
-Warren Block * Rapid City, South Dakota USA
More information about the freebsd-questions
mailing list