version 1.16, 2009/07/05 23:58:38
|
version 1.21, 2018/10/17 14:33:49
|
Line 28
|
Line 28
|
# |
# |
|
|
my $dist='default'; |
my $dist='default'; |
|
my $unknown; |
if (-e '/etc/redhat-release') { |
if (-e '/etc/redhat-release') { |
open(IN,'</etc/redhat-release'); |
open(IN,'</etc/redhat-release'); |
my $versionstring=<IN>; |
my $versionstring=<IN>; |
Line 53 if (-e '/etc/redhat-release') {
|
Line 54 if (-e '/etc/redhat-release') {
|
$dist = 'rhes'.$1; |
$dist = 'rhes'.$1; |
} elsif ($versionstring =~ /Red Hat Enterprise Linux Server release (\d+)/) { |
} elsif ($versionstring =~ /Red Hat Enterprise Linux Server release (\d+)/) { |
$dist = 'rhes'.$1; |
$dist = 'rhes'.$1; |
} elsif ($versionstring =~ /CentOS release (\d+)/) { |
} elsif ($versionstring =~ /CentOS(?:| Linux) release (\d+)/) { |
$dist = 'centos'.$1; |
$dist = 'centos'.$1; |
} elsif ($versionstring =~ /Scientific Linux SL release ([\d\.]+) /) { |
} elsif ($versionstring =~ /Scientific Linux (?:SL )?release ([\d.]+) /) { |
$dist = 'scientific'.$1; |
my $ver = $1; |
|
$ver =~ s/\.\d+$//; |
|
$dist = 'scientific'.$ver; |
} else { |
} else { |
warn('Unable to interpret /etc/redhat-release '. |
warn('Unable to interpret /etc/redhat-release '. |
'to determine system type'); |
'to determine system type'); |
|
$unknown = 1; |
} |
} |
} elsif (-e '/etc/SuSE-release') { |
} elsif (-e '/etc/SuSE-release') { |
open(IN,'</etc/SuSE-release'); |
open(IN,'</etc/SuSE-release'); |
Line 75 if (-e '/etc/redhat-release') {
|
Line 79 if (-e '/etc/redhat-release') {
|
} else { |
} else { |
warn('Unable to interpret /etc/SuSE-release '. |
warn('Unable to interpret /etc/SuSE-release '. |
'to determine system type'); |
'to determine system type'); |
|
$unknown = 1; |
} |
} |
} elsif (-e '/etc/issue') { |
} elsif (-e '/etc/issue') { |
open(IN,'</etc/issue'); |
open(IN,'</etc/issue'); |
Line 95 if (-e '/etc/redhat-release') {
|
Line 100 if (-e '/etc/redhat-release') {
|
} else { |
} else { |
warn('Unable to interpret /etc/debian_version '. |
warn('Unable to interpret /etc/debian_version '. |
'to determine system type'); |
'to determine system type'); |
|
$unknown = 1; |
} |
} |
} else { |
|
warn('Unable to interpret /etc/issue '. |
|
'to determine system type'); |
|
} |
} |
} elsif (-e '/etc/debian_version') { |
} elsif (-e '/etc/debian_version') { |
open(IN,'</etc/debian_version'); |
open(IN,'</etc/debian_version'); |
Line 110 if (-e '/etc/redhat-release') {
|
Line 113 if (-e '/etc/redhat-release') {
|
} else { |
} else { |
warn('Unable to interpret /etc/debian_version '. |
warn('Unable to interpret /etc/debian_version '. |
'to determine system type'); |
'to determine system type'); |
|
$unknown = 1; |
|
} |
|
} |
|
if (($dist eq 'default') && (!$unknown)) { |
|
if (-e '/etc/os-release') { |
|
if (open(IN,'<','/etc/os-release')) { |
|
my ($id,$version); |
|
while(<IN>) { |
|
chomp(); |
|
if (/^ID="(\w+)"/) { |
|
$id=$1; |
|
} elsif (/^VERSION_ID="([\d\.]+)"/) { |
|
$version=$1; |
|
} |
|
} |
|
close(IN); |
|
if ($id eq 'sles') { |
|
my ($major,$minor) = split(/\./,$version); |
|
if ($major =~ /^\d+$/) { |
|
$dist = $id.$major; |
|
} |
|
} |
|
} |
|
if ($dist eq 'default') { |
|
warn('Unable to interpret /etc/os-release '. |
|
'to determine system type.'); |
|
$unknown = 1; |
|
} |
|
} else { |
|
warn('Unknown installation: expecting a debian, ubuntu, suse, sles, redhat, fedora or scientific linux system.')."\n"; |
} |
} |
} else { |
|
warn('Unknown installation: expecting a debian, suse, or redhat system'); |
|
} |
} |
print $dist; |
print $dist; |