Annotation of loncom/build/distprobe, revision 1.15
1.1 harris41 1: #!/usr/bin/perl
1.5 matthew 2: #
3: # The LearningOnline Network with CAPA
4: #
1.15 ! raeburn 5: # $Id: distprobe,v 1.14 2007/06/28 13:30:06 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';
31: if (-e '/etc/redhat-release') {
32: open(IN,'</etc/redhat-release');
33: my $versionstring=<IN>;
34: chomp($versionstring);
35: close(IN);
1.5 matthew 36: if ($versionstring =~ /^Red Hat Linux release ([\d\.]+) /) {
37: $version = $1;
38: if ($version=~/^7\./) {
39: $dist='redhat7';
40: } elsif ($version=~/^8\./) {
41: $dist='redhat8';
42: } elsif ($version=~/^9/) {
43: $dist='redhat9';
44: }
1.13 raeburn 45: } elsif ($versionstring =~ /Fedora( Core)? release ([\d\.]+) /) {
46: my $version=$2;
1.7 albertel 47: if ($version - int($version) > .9) {
48: $dist = 'fedora'.(int($version)+1);
49: } else {
50: $dist = 'fedora'.int($version);
51: }
1.9 albertel 52: } elsif ($versionstring =~ /Red Hat Enterprise Linux [AE]S release ([\d\.]+) /) {
1.8 raeburn 53: $dist = 'rhes'.$1;
1.12 raeburn 54: } elsif ($versionstring =~ /Red Hat Enterprise Linux Server release (\d+)/) {
55: $dist = 'rhes'.$1;
1.14 raeburn 56: } elsif ($versionstring =~ /CentOS release (\d+)/) {
57: $dist = 'centos'.$1;
58: } elsif ($versionstring =~ /Scientific Linux SL release ([\d\.]+) /) {
59: $dist = 'scientific'.$1;
1.5 matthew 60: } else {
61: warn('Unable to interpret /etc/redhat-release '.
62: 'to determine system type');
1.1 harris41 63: }
1.15 ! raeburn 64: } elsif (-e '/etc/issue') {
! 65: open(IN,'</etc/issue');
! 66: my $versionstring=<IN>;
! 67: chomp($versionstring);
! 68: close(IN);
! 69: if ($versionstring =~ /^Ubuntu (\d+)\.\d+/i) {
! 70: $dist = 'ubuntu'.$1;
! 71: } elsif ($versionstring =~ /^Debian\s+GNU\/Linux\s+(\d+)\.\d+/i) {
! 72: $dist = 'debian'.$1;
! 73: } elsif (-e '/etc/debian_version') {
! 74: open(IN,'</etc/debian_version');
! 75: my $version=<IN>;
! 76: chomp($version);
! 77: close(IN);
! 78: if ($version =~ /^(\d+)\.\d+\.?\d*/) {
! 79: $dist='debian'.$1;
! 80: } else {
! 81: warn('Unable to interpret /etc/debian_version '.
! 82: 'to determine system type');
! 83: }
! 84: } else {
! 85: warn('Unable to interpret /etc/issue '.
! 86: 'to determine system type');
! 87: }
1.5 matthew 88: } elsif (-e '/etc/debian_version') {
1.1 harris41 89: open(IN,'</etc/debian_version');
90: my $version=<IN>;
91: chomp($version);
92: close(IN);
1.15 ! raeburn 93: if ($version =~ /^(\d+)\.\d+\.?\d*/) {
! 94: $dist='debian'.$1;
! 95: } else {
! 96: warn('Unable to interpret /etc/debian_version '.
! 97: 'to determine system type');
1.1 harris41 98: }
1.6 albertel 99: } elsif (-e '/etc/SuSE-release') {
100: open(IN,'</etc/SuSE-release');
101: my $versionstring=<IN>;
102: chomp($versionstring);
103: close(IN);
1.10 raeburn 104: if ($versionstring =~ /^SUSE LINUX Enterprise Server ([\d\.]+) /i) {
1.6 albertel 105: $dist='sles'.$1;
1.10 raeburn 106: } elsif ($versionstring =~ /^SuSE Linux ([\d\.]+) /i) {
1.6 albertel 107: $dist = 'suse'.$1;
1.11 raeburn 108: } elsif ($versionstring =~ /^openSUSE ([\d\.]+) /i) {
109: $dist = 'suse'.$1;
1.6 albertel 110: } else {
111: warn('Unable to interpret /etc/SuSE-release '.
112: 'to determine system type');
113: }
1.5 matthew 114: } else {
1.6 albertel 115: warn('Unknown installation: expecting a debian, suse, or redhat system');
1.1 harris41 116: }
117: print $dist;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>