--- loncom/build/distprobe 2007/06/28 13:30:06 1.14 +++ loncom/build/distprobe 2021/12/21 13:57:47 1.26 @@ -2,7 +2,7 @@ # # The LearningOnline Network with CAPA # -# $Id: distprobe,v 1.14 2007/06/28 13:30:06 raeburn Exp $ +# $Id: distprobe,v 1.26 2021/12/21 13:57:47 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -28,7 +28,16 @@ # my $dist='default'; -if (-e '/etc/redhat-release') { +my $unknown; +if (-e '/etc/oracle-release') { + open(IN,'; + chomp($versionstring); + close(IN); + if ($versionstring =~ /^Oracle Linux Server release (\d+)/) { + $dist = 'oracle'.$1; + } +} elsif (-e '/etc/redhat-release') { open(IN,'; chomp($versionstring); @@ -53,21 +62,29 @@ if (-e '/etc/redhat-release') { $dist = 'rhes'.$1; } elsif ($versionstring =~ /Red Hat Enterprise Linux Server release (\d+)/) { $dist = 'rhes'.$1; - } elsif ($versionstring =~ /CentOS release (\d+)/) { - $dist = 'centos'.$1; - } elsif ($versionstring =~ /Scientific Linux SL release ([\d\.]+) /) { - $dist = 'scientific'.$1; + } elsif ($versionstring =~ /Red Hat Enterprise Linux release (\d+)/) { + $dist = 'rhes'.$1; + } elsif ($versionstring =~ /CentOS(| Linux| Stream) release (\d+)/) { + $dist = 'centos'.$2; + if ($1 eq ' Stream') { + $dist .= '-stream'; + } + } elsif ($versionstring =~ /Scientific Linux (?:SL )?release ([\d.]+) /) { + my $ver = $1; + $ver =~ s/\.\d+$//; + $dist = 'scientific'.$ver; + } elsif ($versionstring =~ /Rocky Linux release ([\d.]+)/) { + my $ver = $1; + $ver =~ s/\.\d+$//; + $dist = 'rocky'.$ver; + } elsif ($versionstring =~ /AlmaLinux release ([\d.]+)/) { + my $ver = $1; + $ver =~ s/\.\d+$//; + $dist = 'alma'.$ver; } else { warn('Unable to interpret /etc/redhat-release '. 'to determine system type'); - } -} elsif (-e '/etc/debian_version') { - open(IN,'; - chomp($version); - close(IN); - if ($version eq '2.2') { - $dist='debian2.2'; + $unknown = 1; } } elsif (-e '/etc/SuSE-release') { open(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,'; + 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,'; + 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() { + 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;