| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::which_package; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
749
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
5
|
1
|
|
|
1
|
|
387
|
use Alien::Packages; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Path::Class qw( file dir ); |
|
7
|
|
|
|
|
|
|
use Text::Table; |
|
8
|
|
|
|
|
|
|
use File::Which qw( which ); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Determine which package installed a file |
|
11
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $ap = Alien::Packages->new; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub main |
|
16
|
|
|
|
|
|
|
{ |
|
17
|
|
|
|
|
|
|
my($class, @files) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
unless(@files > 0) |
|
20
|
|
|
|
|
|
|
{ |
|
21
|
|
|
|
|
|
|
say STDERR "usage: which_package /path/to/file"; |
|
22
|
|
|
|
|
|
|
return 1; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $table = Text::Table->new(qw( file package type )); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my %owners = $ap->list_fileowners( |
|
28
|
|
|
|
|
|
|
map { $_->absolute } |
|
29
|
|
|
|
|
|
|
map { -d $_ ? dir($_) : file($_) } |
|
30
|
|
|
|
|
|
|
map { -e $_ ? $_ : which($_) } |
|
31
|
|
|
|
|
|
|
@files |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $count = 0; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
foreach my $file (sort keys %owners) |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
|
|
|
|
|
|
foreach my $package (sort { $a->{Package} cmp $b->{Package} } @{ $owners{$file} }) |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
|
|
|
|
|
|
$table->add($file, $package->{Package}, $package->{PkgType}); |
|
41
|
|
|
|
|
|
|
$count++; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
if($count > 0) |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
|
|
|
|
|
|
print $table; |
|
48
|
|
|
|
|
|
|
return 0; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
else |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
|
|
|
|
|
|
return 2; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |