line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Packages::Dpkg; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1308
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
3
|
use vars qw($VERSION @ISA); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
479
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Alien::Packages::Dpkg - get's information from Debian's package database via dpkg-query |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = "0.001"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require Alien::Packages::Base; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
@ISA = qw(Alien::Packages::Base); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 ISA |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Alien::Packages::Rpm |
22
|
|
|
|
|
|
|
ISA Alien::Packages::Base |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
require IPC::Cmd; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $dpkg_query; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 usable |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Returns true when the C command could be found in the path. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub usable |
39
|
|
|
|
|
|
|
{ |
40
|
1
|
50
|
|
1
|
1
|
6
|
unless ( defined($dpkg_query) ) |
41
|
|
|
|
|
|
|
{ |
42
|
1
|
|
|
|
|
7
|
$dpkg_query = IPC::Cmd::can_run('dpkg-query'); |
43
|
1
|
|
50
|
|
|
99761
|
$dpkg_query ||= ''; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
10
|
return $dpkg_query; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 list_packages |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Returns the list of installed I packages. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub list_packages |
56
|
|
|
|
|
|
|
{ |
57
|
1
|
|
|
1
|
1
|
2
|
my $self = $_[0]; |
58
|
1
|
|
|
|
|
0
|
my @packages; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
8
|
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = |
61
|
|
|
|
|
|
|
$self->_run_ipc_cmd( |
62
|
|
|
|
|
|
|
command => [ $dpkg_query, '-W', q(-f=${Package}:${Version}:${Description}\n) ], |
63
|
|
|
|
|
|
|
verbose => 0, ); |
64
|
|
|
|
|
|
|
|
65
|
1
|
50
|
|
|
|
13
|
if ($success) |
66
|
|
|
|
|
|
|
{ |
67
|
1
|
|
|
|
|
44
|
chomp $stdout_buf->[0]; |
68
|
1
|
|
|
|
|
373
|
my @pkglist = split( /\n/, $stdout_buf->[0] ); |
69
|
1
|
|
|
|
|
3
|
my %pkg_details; |
70
|
1
|
|
|
|
|
6
|
foreach my $pkg (@pkglist) |
71
|
|
|
|
|
|
|
{ |
72
|
1595
|
100
|
|
|
|
1476
|
if ( 0 == index( $pkg, ' ' ) ) |
73
|
|
|
|
|
|
|
{ |
74
|
1386
|
|
|
|
|
730
|
push( @{ $pkg_details{Description} }, $pkg ); |
|
1386
|
|
|
|
|
1381
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else |
77
|
|
|
|
|
|
|
{ |
78
|
209
|
100
|
|
|
|
540
|
%pkg_details and push( @packages, {%pkg_details} ); |
79
|
209
|
|
|
|
|
396
|
@pkg_details{ 'Package', 'Version', 'Summary' } = split( ':', $pkg ); |
80
|
209
|
|
|
|
|
231
|
$pkg_details{Description} = []; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
1
|
50
|
|
|
|
75
|
%pkg_details and push( @packages, {%pkg_details} ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
41
|
return @packages; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 list_fileowners |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns the I packages which are associated to requested file(s). |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub list_fileowners |
96
|
|
|
|
|
|
|
{ |
97
|
1
|
|
|
1
|
1
|
3
|
my ( $self, @files ) = @_; |
98
|
1
|
|
|
|
|
2
|
my %file_owners; |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
2
|
foreach my $file (@files) |
101
|
|
|
|
|
|
|
{ |
102
|
2
|
|
|
|
|
15
|
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = |
103
|
|
|
|
|
|
|
$self->_run_ipc_cmd( command => [ $dpkg_query, '-S', $file ], |
104
|
|
|
|
|
|
|
verbose => 0, ); |
105
|
|
|
|
|
|
|
|
106
|
2
|
100
|
|
|
|
21
|
if ($success) |
107
|
|
|
|
|
|
|
{ |
108
|
1
|
|
|
|
|
8
|
chomp $stdout_buf->[0]; |
109
|
1
|
|
|
|
|
7
|
my @pkglist = split( /\n/, $stdout_buf->[0] ); |
110
|
1
|
|
|
|
|
4
|
foreach my $pkg (@pkglist) |
111
|
|
|
|
|
|
|
{ |
112
|
1
|
50
|
|
|
|
13
|
if ( my ( $pkg_name, $fn ) = $pkg =~ m/^([^:]+):\s+([^\s].*)$/ ) |
113
|
|
|
|
|
|
|
{ |
114
|
1
|
|
|
|
|
3
|
push( @{ $file_owners{$fn} }, { Package => $pkg_name } ); |
|
1
|
|
|
|
|
11
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
11
|
return %file_owners; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Jens Rehsack, C<< >> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright 2010 Jens Rehsack. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
132
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
133
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |