line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Generic::Softwares::RPM; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
123478009
|
use strict; |
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
86
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
73
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
495
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
385
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
return canRun('rpm'); |
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
|
|
|
|
|
|
|
'rpm -qa --queryformat \'' . |
20
|
|
|
|
|
|
|
'%{NAME}\t' . |
21
|
|
|
|
|
|
|
'%{ARCH}\t' . |
22
|
|
|
|
|
|
|
'%{VERSION}-%{RELEASE}\t' . |
23
|
|
|
|
|
|
|
'%{INSTALLTIME:date}\t' . |
24
|
|
|
|
|
|
|
'%{SIZE}\t' . |
25
|
|
|
|
|
|
|
'%{VENDOR}\t' . |
26
|
|
|
|
|
|
|
'%{SUMMARY}\n' . |
27
|
|
|
|
|
|
|
'\''; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $packages = _getPackagesList( |
30
|
|
|
|
|
|
|
logger => $logger, command => $command |
31
|
|
|
|
|
|
|
); |
32
|
0
|
0
|
|
|
|
|
return unless $packages; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
foreach my $package (@$packages) { |
35
|
0
|
|
|
|
|
|
$inventory->addEntry( |
36
|
|
|
|
|
|
|
section => 'SOFTWARES', |
37
|
|
|
|
|
|
|
entry => $package |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _getPackagesList { |
43
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
44
|
0
|
0
|
|
|
|
|
return unless $handle; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my @packages; |
47
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
48
|
0
|
|
|
|
|
|
chomp $line; |
49
|
0
|
|
|
|
|
|
my @infos = split("\t", $line); |
50
|
0
|
|
|
|
|
|
my $package = { |
51
|
|
|
|
|
|
|
NAME => $infos[0], |
52
|
|
|
|
|
|
|
ARCH => $infos[1], |
53
|
|
|
|
|
|
|
VERSION => $infos[2], |
54
|
|
|
|
|
|
|
INSTALLDATE => $infos[3], |
55
|
|
|
|
|
|
|
FILESIZE => $infos[4], |
56
|
|
|
|
|
|
|
COMMENTS => $infos[6], |
57
|
|
|
|
|
|
|
FROM => 'rpm' |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
$package->{PUBLISHER} = $infos[5] if $infos[5] ne '(none)'; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
push @packages, $package; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
close $handle; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return \@packages; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |