Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
sousage/ldd_bee/ldd_bee.pl
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
114 lines (96 sloc)
2.06 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use Data::Dumper;$Data::Dumper::Sortkeys=1; | |
my %ldd; | |
my @bins; | |
for my $bin (@ARGV) { | |
@_=`ldd $bin 2>&1`; | |
if ( $? == 0 ) { | |
chomp @_; | |
map {/=>\s(\S+)/ && $ldd{$1}++} @_; | |
push @bins,$bin; | |
} | |
else { | |
die "ldd failed on $bin"; | |
} | |
} | |
my @libs = sort keys %ldd; | |
my $k; | |
my %BEEQUERY; | |
for my $bee (</usr/share/bee/*>) { | |
next unless -e "$bee/CONTENT"; | |
$bee=~/.*\/(.*)/; | |
my $b = $1; | |
open I,'<',"$bee/CONTENT" or die; | |
while (<I>) { | |
if (m{:file=(.*)}) { | |
$_=$1; | |
s{//.*}{}; #unsymlink | |
push @{$BEEQUERY{$_}},$b; | |
} | |
} | |
close I; | |
} | |
unshift @libs,@bins; | |
my %bee; | |
for my $l (@libs) { | |
print "# $l\n"; | |
if ( exists( $BEEQUERY{$l}) ) { | |
map { $bee{$_}{$l}++ } @{$BEEQUERY{$l}}; | |
} | |
else { | |
die "## $l not found in any bee file\n"; | |
} | |
} | |
my $b = 0; | |
for my $bee ( sort keys %bee ) { | |
print "\n"; | |
my ($beefile) = </usr/share/bee/$bee/*.bee>; | |
my $mt = (stat($beefile))[9]; | |
print "PKGALLPKG[$b]=$bee\n"; | |
print " BEEFILE[$b]=$beefile\n"; | |
printf " BEETIME[$b]=%d # %s (%s)\n",$mt,years(time-$mt,2),scalar(localtime($mt)); | |
my $bc = 0; | |
for my $lib ( sort keys %{$bee{$bee}} ) { | |
print " BEEF[$b][$bc]=$lib\n"; | |
$bc++; | |
} | |
$b++; | |
} | |
sub years { | |
my $s = shift; | |
my $n = shift; | |
if ($s == 0) { | |
return '0 secs'; | |
} | |
my @T=(); | |
my $t = int($s/(365*60*60*24)); | |
push @T, ($t > 0) ? $t : 0; # months | |
$s -= $t*int(365*60*60*24); | |
$t = int($s/(30.42*60*60*24)); | |
push @T, ($t > 0) ? $t : 0; # months | |
$s -= $t*int(30.42*60*60*24); | |
$t = int($s/(60*60*24)); | |
push @T, ($t > 0) ? $t : 0; # days | |
$s -= $t*(60*60*24); | |
$t = int($s/(60*60)); | |
push @T, ($t > 0) ? $t : 0; # hrs | |
$s -= $t*(60*60); | |
$t = int($s/(60)); | |
push @T, ($t > 0) ? $t : 0; # min | |
$s -= $t*60; | |
$t = int($s); | |
push @T, ($t > 0) ? $t : 0; # sec | |
my @L; | |
for my $x ('yrs','mon','days','hrs','min','secs') { | |
my $y = shift @T; | |
if ($y != 0) { | |
if (defined($n)) { | |
$n--; | |
last if ($n < 0); | |
} | |
push @L,"$y $x"; | |
} | |
} | |
return join(' ',@L); | |
} | |