| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux::Distro::NonLSB; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
131084776
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
63
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
91
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
11
|
use English qw(-no_match_vars); |
|
|
1
|
|
|
|
|
79
|
|
|
|
1
|
|
|
|
|
26
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1683
|
use FusionInventory::Agent::Tools; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
217
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use List::Util qw(first); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
632
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# This array contains four items for each distribution: |
|
12
|
|
|
|
|
|
|
# - release file |
|
13
|
|
|
|
|
|
|
# - distribution name, |
|
14
|
|
|
|
|
|
|
# - regex to get the version |
|
15
|
|
|
|
|
|
|
# - template to get the full name |
|
16
|
|
|
|
|
|
|
my @distributions = ( |
|
17
|
|
|
|
|
|
|
# vmware-release contains something like "VMware ESX Server 3" or "VMware ESX 4.0 (Kandinsky)" |
|
18
|
|
|
|
|
|
|
[ '/etc/vmware-release', 'VMWare', '([\d.]+)', '%s' ], |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
[ '/etc/arch-release', 'ArchLinux', '(.*)', 'ArchLinux' ], |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
[ '/etc/debian_version', 'Debian', '(.*)', 'Debian GNU/Linux %s'], |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# fedora-release contains something like "Fedora release 9 (Sulphur)" |
|
25
|
|
|
|
|
|
|
[ '/etc/fedora-release', 'Fedora', 'release ([\d.]+)', '%s' ], |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
[ '/etc/gentoo-release', 'Gentoo', '(.*)', 'Gentoo Linux %s' ], |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# knoppix_version contains something like "3.2 2003-04-15". |
|
30
|
|
|
|
|
|
|
# Note: several 3.2 releases can be made, with different dates, so we need to keep the date suffix |
|
31
|
|
|
|
|
|
|
[ '/etc/knoppix_version', 'Knoppix', '(.*)', 'Knoppix GNU/Linux %s' ], |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# mandriva-release contains something like "Mandriva Linux release 2010.1 (Official) for x86_64" |
|
34
|
|
|
|
|
|
|
[ '/etc/mandriva-release', 'Mandriva', 'release ([\d.]+)', '%s'], |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# mandrake-release contains something like "Mandrakelinux release 10.1 (Community) for i586" |
|
37
|
|
|
|
|
|
|
[ '/etc/mandrake-release', 'Mandrake', 'release ([\d.]+)', '%s'], |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# oracle-release contains something like "Oracle Linux Server release 6.3" |
|
40
|
|
|
|
|
|
|
[ '/etc/oracle-release', 'Oracle Linux Server', 'release ([\d.]+)', '%s' ], |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# centos-release contains something like "CentOS Linux release 6.0 (Final) |
|
43
|
|
|
|
|
|
|
[ '/etc/centos-release', 'CentOS', 'release ([\d.]+)', '%s' ], |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# redhat-release contains something like "Red Hat Enterprise Linux Server release 5 (Tikanga)" |
|
46
|
|
|
|
|
|
|
[ '/etc/redhat-release', 'RedHat', 'release ([\d.]+)', '%s' ], |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
[ '/etc/slackware-version', 'Slackware', 'Slackware (.*)', '%s' ], |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# SuSE-release contains something like "SUSE Linux Enterprise Server 11 (x86_64)" |
|
51
|
|
|
|
|
|
|
# Note: it may contain several extra lines |
|
52
|
|
|
|
|
|
|
[ '/etc/SuSE-release', 'SuSE', '([\d.]+)', '%s' ], |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# trustix-release contains something like "Trustix Secure Linux release 2.0 (Cloud)" |
|
55
|
|
|
|
|
|
|
[ '/etc/trustix-release', 'Trustix', 'release ([\d.]+)', '%s' ], |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Fallback |
|
58
|
|
|
|
|
|
|
[ '/etc/issue', 'Unknown Linux distribution', '([\d.]+)' , '%s' ], |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Note: Ubuntu is not listed here as it does not have a |
|
61
|
|
|
|
|
|
|
# ubuntu-{release,version} file, but it should always have the lsb_release |
|
62
|
|
|
|
|
|
|
# command so it will be handled by the Linux::Distro::LSB module |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
our $runMeIfTheseChecksFailed = |
|
66
|
|
|
|
|
|
|
["FusionInventory::Agent::Task::Inventory::Linux::Distro::LSB"]; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub isEnabled { |
|
69
|
0
|
|
|
0
|
0
|
|
return !canRun('lsb_release'); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub doInventory { |
|
73
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
0
|
|
|
my $distribution = first { -f $_->[0] } @distributions; |
|
|
0
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
return unless $distribution; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my $data = _getDistroData($distribution); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$inventory->setHardware({ |
|
83
|
|
|
|
|
|
|
OSNAME => $data->{FULL_NAME} |
|
84
|
0
|
|
|
|
|
|
}); |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$inventory->setOperatingSystem($data); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _getDistroData { |
|
90
|
0
|
|
|
0
|
|
|
my ($distribution) = @_; |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $name = $distribution->[1]; |
|
93
|
0
|
|
|
|
|
|
my $regexp = $distribution->[2]; |
|
94
|
0
|
|
|
|
|
|
my $template = $distribution->[3]; |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my $line = getFirstLine(file => $distribution->[0]); |
|
97
|
|
|
|
|
|
|
# Arch Linux has an empty release file |
|
98
|
0
|
|
|
|
|
|
my ($release, $version); |
|
99
|
0
|
0
|
|
|
|
|
if ($line) { |
|
100
|
0
|
|
|
|
|
|
$release = sprintf $template, $line; |
|
101
|
0
|
|
|
|
|
|
($version) = $line =~ /$regexp/; |
|
102
|
|
|
|
|
|
|
} else { |
|
103
|
0
|
|
|
|
|
|
$release = $template; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# If the detected OS is RedHat, but the release contains Scientific, then it is Scientific |
|
107
|
0
|
0
|
|
|
|
|
if ($name =~ /RedHat/) { |
|
108
|
0
|
0
|
|
|
|
|
if ($release =~ /Scientific/) { |
|
109
|
|
|
|
|
|
|
# this is really a scientific linux, we have to change the name |
|
110
|
0
|
|
|
|
|
|
$name = "Scientific"; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
my $data = { |
|
115
|
|
|
|
|
|
|
NAME => $name, |
|
116
|
|
|
|
|
|
|
VERSION => $version, |
|
117
|
|
|
|
|
|
|
FULL_NAME => $release |
|
118
|
|
|
|
|
|
|
}; |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
if ($name eq 'SuSE') { |
|
121
|
0
|
|
|
|
|
|
$data->{SERVICE_PACK} = getFirstMatch( |
|
122
|
|
|
|
|
|
|
file => '/etc/SuSE-release', |
|
123
|
|
|
|
|
|
|
pattern => qr/^PATCHLEVEL = ([0-9]+)/ |
|
124
|
|
|
|
|
|
|
); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return $data; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |