Annotation of loncom/build/distprobe, revision 1.26
1.1 harris41 1: #!/usr/bin/perl
1.5 matthew 2: #
3: # The LearningOnline Network with CAPA
4: #
1.26 ! raeburn 5: # $Id: distprobe,v 1.25 2021/12/20 03:13:29 raeburn Exp $
1.5 matthew 6: #
7: # Copyright Michigan State University Board of Trustees
8: #
9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
10: #
11: # LON-CAPA is free software; you can redistribute it and/or modify
12: # it under the terms of the GNU General Public License as published by
13: # the Free Software Foundation; either version 2 of the License, or
14: # (at your option) any later version.
15: #
16: # LON-CAPA is distributed in the hope that it will be useful,
17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19: # GNU General Public License for more details.
20: #
21: # You should have received a copy of the GNU General Public License
22: # along with LON-CAPA; if not, write to the Free Software
23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24: #
25: # /home/httpd/html/adm/gpl.txt
26: #
27: # http://www.lon-capa.org/
28: #
1.1 harris41 29:
30: my $dist='default';
1.21 raeburn 31: my $unknown;
1.23 raeburn 32: if (-e '/etc/oracle-release') {
33: open(IN,'</etc/oracle-release');
34: my $versionstring=<IN>;
35: chomp($versionstring);
36: close(IN);
37: if ($versionstring =~ /^Oracle Linux Server release (\d+)/) {
38: $dist = 'oracle'.$1;
39: }
40: } elsif (-e '/etc/redhat-release') {
1.1 harris41 41: open(IN,'</etc/redhat-release');
42: my $versionstring=<IN>;
43: chomp($versionstring);
44: close(IN);
1.5 matthew 45: if ($versionstring =~ /^Red Hat Linux release ([\d\.]+) /) {
46: $version = $1;
47: if ($version=~/^7\./) {
48: $dist='redhat7';
49: } elsif ($version=~/^8\./) {
50: $dist='redhat8';
51: } elsif ($version=~/^9/) {
52: $dist='redhat9';
53: }
1.13 raeburn 54: } elsif ($versionstring =~ /Fedora( Core)? release ([\d\.]+) /) {
55: my $version=$2;
1.7 albertel 56: if ($version - int($version) > .9) {
57: $dist = 'fedora'.(int($version)+1);
58: } else {
59: $dist = 'fedora'.int($version);
60: }
1.9 albertel 61: } elsif ($versionstring =~ /Red Hat Enterprise Linux [AE]S release ([\d\.]+) /) {
1.8 raeburn 62: $dist = 'rhes'.$1;
1.12 raeburn 63: } elsif ($versionstring =~ /Red Hat Enterprise Linux Server release (\d+)/) {
64: $dist = 'rhes'.$1;
1.22 raeburn 65: } elsif ($versionstring =~ /Red Hat Enterprise Linux release (\d+)/) {
66: $dist = 'rhes'.$1;
1.26 ! raeburn 67: } elsif ($versionstring =~ /CentOS(| Linux| Stream) release (\d+)/) {
! 68: $dist = 'centos'.$2;
! 69: if ($1 eq ' Stream') {
! 70: $dist .= '-stream';
! 71: }
1.19 raeburn 72: } elsif ($versionstring =~ /Scientific Linux (?:SL )?release ([\d.]+) /) {
1.17 raeburn 73: my $ver = $1;
74: $ver =~ s/\.\d+$//;
75: $dist = 'scientific'.$ver;
1.25 raeburn 76: } elsif ($versionstring =~ /Rocky Linux release ([\d.]+)/) {
77: my $ver = $1;
78: $ver =~ s/\.\d+$//;
79: $dist = 'rocky'.$ver;
80: } elsif ($versionstring =~ /AlmaLinux release ([\d.]+)/) {
81: my $ver = $1;
82: $ver =~ s/\.\d+$//;
83: $dist = 'alma'.$ver;
1.5 matthew 84: } else {
85: warn('Unable to interpret /etc/redhat-release '.
86: 'to determine system type');
1.21 raeburn 87: $unknown = 1;
1.1 harris41 88: }
1.16 raeburn 89: } elsif (-e '/etc/SuSE-release') {
90: open(IN,'</etc/SuSE-release');
91: my $versionstring=<IN>;
92: chomp($versionstring);
93: close(IN);
94: if ($versionstring =~ /^SUSE LINUX Enterprise Server ([\d\.]+) /i) {
95: $dist='sles'.$1;
96: } elsif ($versionstring =~ /^SuSE Linux ([\d\.]+) /i) {
97: $dist = 'suse'.$1;
98: } elsif ($versionstring =~ /^openSUSE ([\d\.]+) /i) {
99: $dist = 'suse'.$1;
100: } else {
101: warn('Unable to interpret /etc/SuSE-release '.
102: 'to determine system type');
1.21 raeburn 103: $unknown = 1;
1.16 raeburn 104: }
1.15 raeburn 105: } elsif (-e '/etc/issue') {
106: open(IN,'</etc/issue');
107: my $versionstring=<IN>;
108: chomp($versionstring);
109: close(IN);
110: if ($versionstring =~ /^Ubuntu (\d+)\.\d+/i) {
111: $dist = 'ubuntu'.$1;
112: } elsif ($versionstring =~ /^Debian\s+GNU\/Linux\s+(\d+)\.\d+/i) {
113: $dist = 'debian'.$1;
114: } elsif (-e '/etc/debian_version') {
115: open(IN,'</etc/debian_version');
116: my $version=<IN>;
117: chomp($version);
118: close(IN);
119: if ($version =~ /^(\d+)\.\d+\.?\d*/) {
120: $dist='debian'.$1;
121: } else {
122: warn('Unable to interpret /etc/debian_version '.
123: 'to determine system type');
1.21 raeburn 124: $unknown = 1;
1.15 raeburn 125: }
126: }
1.5 matthew 127: } elsif (-e '/etc/debian_version') {
1.1 harris41 128: open(IN,'</etc/debian_version');
129: my $version=<IN>;
130: chomp($version);
131: close(IN);
1.15 raeburn 132: if ($version =~ /^(\d+)\.\d+\.?\d*/) {
133: $dist='debian'.$1;
134: } else {
135: warn('Unable to interpret /etc/debian_version '.
136: 'to determine system type');
1.21 raeburn 137: $unknown = 1;
138: }
139: }
140: if (($dist eq 'default') && (!$unknown)) {
141: if (-e '/etc/os-release') {
142: if (open(IN,'<','/etc/os-release')) {
143: my ($id,$version);
144: while(<IN>) {
145: chomp();
146: if (/^ID="(\w+)"/) {
147: $id=$1;
148: } elsif (/^VERSION_ID="([\d\.]+)"/) {
149: $version=$1;
150: }
151: }
152: close(IN);
153: if ($id eq 'sles') {
154: my ($major,$minor) = split(/\./,$version);
155: if ($major =~ /^\d+$/) {
156: $dist = $id.$major;
157: }
158: }
159: }
160: if ($dist eq 'default') {
161: warn('Unable to interpret /etc/os-release '.
162: 'to determine system type.');
163: $unknown = 1;
164: }
165: } else {
166: warn('Unknown installation: expecting a debian, ubuntu, suse, sles, redhat, fedora or scientific linux system.')."\n";
1.1 harris41 167: }
168: }
169: print $dist;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>