2 BEGIN{$^W = 1} # equivalent of -w
3 # -*- Mode: perl; indent-tabs-mode: nil -*-
5 # This script does not need to run under taint perl.
7 # This script is derived from a generic build script for tinderbox. It will
8 # display, on stdout, details of the OS and distribution in use.
10 # The contents of this file are subject to the Mozilla Public
11 # License Version 1.1 (the "License"); you may not use this file
12 # except in compliance with the License. You may obtain a copy of
13 # the License at http://www.mozilla.org/NPL/
15 # Software distributed under the License is distributed on an "AS
16 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 # implied. See the License for the specific language governing
18 # rights and limitations under the License.
20 # The Original Code is the Tinderbox build tool.
22 # The Initial Developer of the Original Code is Netscape Communications
23 # Corporation. Portions created by Netscape are
24 # Copyright (C) 1998 Netscape Communications Corporation. All
27 # complete rewrite by Ken Estes, Mail.com (kestes@staff.mail.com).
31 # $Date: 2002/01/02 18:09:59 $
32 # $Author: kestes%walrus.com $
47 return wantarray ? split /\n/, $out : $out;
53 if (lc $OS eq "linux") {
54 if (open F, "/etc/debian_version") {
57 $distro = "Debian $_";
58 if (open F, "/etc/lsb-release") {
59 # For Ubuntu (derived from Debian)
60 my ($id, $release, $codename, $desc);
62 if (/^DISTRIB_ID=(.+)/) {
64 } elsif (/^DISTRIB_RELEASE=(.+)/) {
66 } elsif (/^DISTRIB_CODENAME=(.+)/) {
68 } elsif (/^DISTRIB_DESCRIPTION=(.+)/) {
74 if (defined $codename) {
75 $distro .= " $codename";
76 } elsif (defined $release) {
77 $distro .= " $release";
78 } elsif (defined $codename) {
83 } elsif (open F, "/etc/redhat-release") {
84 # e.g. "Red Hat Linux release 7.2 (Enigma)"
85 # or "Red Hat Enterprise Linux AS release 3 (Taroon Update 1)"
86 # or "Red Hat Enterprise Linux ES release 3 (Taroon Update 3)"
88 if (/^Red Hat Enterprise Linux ([AE]S) release ([0-9]\S*)\b/) {
89 $distro = "RHEL_$1 $2";
90 } elsif (/^Fedora Core release ([0-9]\S*)\b/) {
92 } elsif (/^(.+) release ([0-9]\S*)\b/) {
98 } elsif (open F, "/etc/SuSE-release") {
99 # e.g. "SuSE Linux 8.1 (i386)" "VERSION = 8.1"
104 } elsif (open F, "/etc/gentoo-release") {
105 # e.g. "Gentoo Base System version 1.4.2.8"
108 $distro = "Gentoo $1";
109 } elsif (open F, "/etc/slackware-version") {
110 # e.g. "Slackware 9.1.0"
113 $distro = "Slackware $1";
116 } elsif (lc $OS eq "darwin") {
117 $distro = join(' ', run_command("/usr/bin/sw_vers 2>/dev/null|sed 's/^Product[A-Za-z]*: *//p;d'"));
118 $distro =~ s/\s+/ /g;
125 if (lc $OS eq "MSWin32") {
128 $distro = Win32::GetOSName();
129 $version = Win32::GetOSVersion();
132 $version = run_command("uname -r");
133 $uname_m = run_command("uname -m");
136 my $SERVER_BUILD_NAME;
137 $SERVER_BUILD_NAME = "$OS $distro $version $uname_m";
138 $SERVER_BUILD_NAME =~ s/\n/ /g;
139 $SERVER_BUILD_NAME =~ s/^ +//;
140 $SERVER_BUILD_NAME =~ s/ +$//;
141 $SERVER_BUILD_NAME =~ s!/!_!g; # tinderbox doesn't like /
142 print $SERVER_BUILD_NAME;