line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Generic::Softwares::Deb; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
155504433
|
use strict; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
125
|
|
4
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
144
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1077
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1048
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
0
|
return canRun('dpkg-query'); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub doInventory { |
13
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
16
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
0
|
my $command = |
19
|
|
|
|
|
|
|
'dpkg-query --show --showformat=\'' . |
20
|
|
|
|
|
|
|
'${Package}\t' . |
21
|
|
|
|
|
|
|
'${Architecture}\t' . |
22
|
|
|
|
|
|
|
'${Version}\t'. |
23
|
|
|
|
|
|
|
'${Installed-Size}\n' . |
24
|
|
|
|
|
|
|
'\''; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
my $packages = _getPackagesList( |
27
|
|
|
|
|
|
|
logger => $logger, command => $command |
28
|
|
|
|
|
|
|
); |
29
|
0
|
0
|
|
|
|
0
|
return unless $packages; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# mimic RPM inventory behaviour, as GLPI aggregates software |
32
|
|
|
|
|
|
|
# based on name and publisher |
33
|
0
|
|
|
|
|
0
|
my $publisher = getFirstMatch( |
34
|
|
|
|
|
|
|
logger => $logger, |
35
|
|
|
|
|
|
|
pattern => qr/^Distributor ID:\s(.+)/, |
36
|
|
|
|
|
|
|
command => 'lsb_release -i', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
foreach my $package (@$packages) { |
40
|
0
|
|
|
|
|
0
|
$package->{PUBLISHER} = $publisher; |
41
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
42
|
|
|
|
|
|
|
section => 'SOFTWARES', |
43
|
|
|
|
|
|
|
entry => $package |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _getPackagesList { |
49
|
1
|
|
|
1
|
|
307
|
my $handle = getFileHandle(@_); |
50
|
1
|
50
|
|
|
|
4
|
return unless $handle; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
2
|
my @packages; |
53
|
1
|
|
|
|
|
15
|
while (my $line = <$handle>) { |
54
|
|
|
|
|
|
|
# skip descriptions |
55
|
15
|
50
|
|
|
|
34
|
next if $line =~ /^ /; |
56
|
15
|
|
|
|
|
20
|
chomp $line; |
57
|
15
|
|
|
|
|
46
|
my @infos = split("\t", $line); |
58
|
15
|
|
|
|
|
105
|
push @packages, { |
59
|
|
|
|
|
|
|
NAME => $infos[0], |
60
|
|
|
|
|
|
|
ARCH => $infos[1], |
61
|
|
|
|
|
|
|
VERSION => $infos[2], |
62
|
|
|
|
|
|
|
FILESIZE => $infos[3], |
63
|
|
|
|
|
|
|
COMMENTS => $infos[4], |
64
|
|
|
|
|
|
|
FROM => 'deb' |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
} |
67
|
1
|
|
|
|
|
41
|
close $handle; |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
5
|
return \@packages; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |