Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Oct 2007 16:01:50 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        Mel <fbsd.questions@rachie.is-a-geek.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: How to check applications vs. libraries
Message-ID:  <20071003154416.J45443@wonkity.com>
In-Reply-To: <200710031425.20972.fbsd.questions@rachie.is-a-geek.net>
References:  <200710021923.29750.daniel.tourde@spray.se> <20071002215320.13360851@gumby.homeunix.com.> <200710031425.20972.fbsd.questions@rachie.is-a-geek.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071003154416.J45443>