version 1.6, 2004/10/26 19:45:57
|
version 1.24, 2021/03/18 21:40:03
|
Line 28
|
Line 28
|
# |
# |
|
|
my $dist='default'; |
my $dist='default'; |
if (-e '/etc/redhat-release') { |
my $unknown; |
|
if (-e '/etc/oracle-release') { |
|
open(IN,'</etc/oracle-release'); |
|
my $versionstring=<IN>; |
|
chomp($versionstring); |
|
close(IN); |
|
if ($versionstring =~ /^Oracle Linux Server release (\d+)/) { |
|
$dist = 'oracle'.$1; |
|
} |
|
} elsif (-e '/etc/redhat-release') { |
open(IN,'</etc/redhat-release'); |
open(IN,'</etc/redhat-release'); |
my $versionstring=<IN>; |
my $versionstring=<IN>; |
chomp($versionstring); |
chomp($versionstring); |
Line 42 if (-e '/etc/redhat-release') {
|
Line 51 if (-e '/etc/redhat-release') {
|
} elsif ($version=~/^9/) { |
} elsif ($version=~/^9/) { |
$dist='redhat9'; |
$dist='redhat9'; |
} |
} |
} elsif ($versionstring =~ /Fedora Core release ([\d\.]+) /) { |
} elsif ($versionstring =~ /Fedora( Core)? release ([\d\.]+) /) { |
$dist = 'fedora'.$1; |
my $version=$2; |
|
if ($version - int($version) > .9) { |
|
$dist = 'fedora'.(int($version)+1); |
|
} else { |
|
$dist = 'fedora'.int($version); |
|
} |
|
} elsif ($versionstring =~ /Red Hat Enterprise Linux [AE]S release ([\d\.]+) /) { |
|
$dist = 'rhes'.$1; |
|
} elsif ($versionstring =~ /Red Hat Enterprise Linux Server release (\d+)/) { |
|
$dist = 'rhes'.$1; |
|
} elsif ($versionstring =~ /Red Hat Enterprise Linux release (\d+)/) { |
|
$dist = 'rhes'.$1; |
|
} elsif ($versionstring =~ /CentOS(?:| Linux| Stream) release (\d+)/) { |
|
$dist = 'centos'.$1; |
|
} elsif ($versionstring =~ /Scientific Linux (?:SL )?release ([\d.]+) /) { |
|
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/debian_version') { |
|
open(IN,'</etc/debian_version'); |
|
my $version=<IN>; |
|
chomp($version); |
|
close(IN); |
|
if ($version eq '2.2') { |
|
$dist='debian2.2'; |
|
} |
} |
} elsif (-e '/etc/SuSE-release') { |
} elsif (-e '/etc/SuSE-release') { |
open(IN,'</etc/SuSE-release'); |
open(IN,'</etc/SuSE-release'); |
my $versionstring=<IN>; |
my $versionstring=<IN>; |
chomp($versionstring); |
chomp($versionstring); |
close(IN); |
close(IN); |
if ($versionstring =~ /^SUSE LINUX Enterprise Server ([\d\.]+) /) { |
if ($versionstring =~ /^SUSE LINUX Enterprise Server ([\d\.]+) /i) { |
$dist='sles'.$1; |
$dist='sles'.$1; |
} elsif ($versionstring =~ /^SuSE Linux ([\d\.]+) /) { |
} elsif ($versionstring =~ /^SuSE Linux ([\d\.]+) /i) { |
|
$dist = 'suse'.$1; |
|
} elsif ($versionstring =~ /^openSUSE ([\d\.]+) /i) { |
$dist = 'suse'.$1; |
$dist = 'suse'.$1; |
} 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') { |
|
open(IN,'</etc/issue'); |
|
my $versionstring=<IN>; |
|
chomp($versionstring); |
|
close(IN); |
|
if ($versionstring =~ /^Ubuntu (\d+)\.\d+/i) { |
|
$dist = 'ubuntu'.$1; |
|
} elsif ($versionstring =~ /^Debian\s+GNU\/Linux\s+(\d+)\.\d+/i) { |
|
$dist = 'debian'.$1; |
|
} elsif (-e '/etc/debian_version') { |
|
open(IN,'</etc/debian_version'); |
|
my $version=<IN>; |
|
chomp($version); |
|
close(IN); |
|
if ($version =~ /^(\d+)\.\d+\.?\d*/) { |
|
$dist='debian'.$1; |
|
} else { |
|
warn('Unable to interpret /etc/debian_version '. |
|
'to determine system type'); |
|
$unknown = 1; |
|
} |
|
} |
|
} elsif (-e '/etc/debian_version') { |
|
open(IN,'</etc/debian_version'); |
|
my $version=<IN>; |
|
chomp($version); |
|
close(IN); |
|
if ($version =~ /^(\d+)\.\d+\.?\d*/) { |
|
$dist='debian'.$1; |
|
} else { |
|
warn('Unable to interpret /etc/debian_version '. |
|
'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; |