line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Generic::Softwares::Deb; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
123940744
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
75
|
|
4
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
64
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
426
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
404
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
return canRun('dpkg-query'); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub doInventory { |
13
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
16
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
17
|
|
|
|
|
|
|
|
18
|
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
|
|
|
|
|
|
my $packages = _getPackagesList( |
27
|
|
|
|
|
|
|
logger => $logger, command => $command |
28
|
|
|
|
|
|
|
); |
29
|
0
|
0
|
|
|
|
|
return unless $packages; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# mimic RPM inventory behaviour, as GLPI aggregates software |
32
|
|
|
|
|
|
|
# based on name and publisher |
33
|
0
|
|
|
|
|
|
my $publisher = getFirstMatch( |
34
|
|
|
|
|
|
|
logger => $logger, |
35
|
|
|
|
|
|
|
pattern => qr/^Distributor ID:\s(.+)/, |
36
|
|
|
|
|
|
|
command => 'lsb_release -i', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
foreach my $package (@$packages) { |
40
|
0
|
|
|
|
|
|
$package->{PUBLISHER} = $publisher; |
41
|
0
|
|
|
|
|
|
$inventory->addEntry( |
42
|
|
|
|
|
|
|
section => 'SOFTWARES', |
43
|
|
|
|
|
|
|
entry => $package |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _getPackagesList { |
49
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
50
|
0
|
0
|
|
|
|
|
return unless $handle; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my @packages; |
53
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
54
|
|
|
|
|
|
|
# skip descriptions |
55
|
0
|
0
|
|
|
|
|
next if $line =~ /^ /; |
56
|
0
|
|
|
|
|
|
chomp $line; |
57
|
0
|
|
|
|
|
|
my @infos = split("\t", $line); |
58
|
0
|
|
|
|
|
|
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
|
0
|
|
|
|
|
|
close $handle; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return \@packages; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |