File: ostype.pl

package info (click to toggle)
tct 1.07-9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,828 kB
  • ctags: 1,128
  • sloc: perl: 9,604; ansic: 4,861; makefile: 516; sh: 77
file content (60 lines) | stat: -rw-r--r-- 1,218 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#
#  Simple test that uses uname to determine what we're running on...
#

sub determine_os {

print "Determining OS (in determine_os())\n" if $verbose;

# Order does not matter, table is sorted.
%OS_INFO = (
    "FREEBSD2", "FreeBSD.2",
    "FREEBSD3", "FreeBSD.3",
    "FREEBSD4", "FreeBSD.4",
    "OPENBSD2", "OpenBSD.2",
    "BSDI2", "BSD\/OS.2",
    "BSDI3", "BSD\/OS.3",
    "BSDI4", "BSD\/OS.4",
    "SUNOS4", "SunOS.4",
    "SUNOS5", "SunOS.5",
    "LINUX2", "Linux.2",
);

if (!$CORPSE) {
	chop($SYSTEM = &command_to_string($UNAME, "-s"));
	chop($RELEASE = &command_to_string($UNAME, "-r"));

	for (sort keys %OS_INFO) {
		if ("$SYSTEM.$RELEASE" =~ /$OS_INFO{$_}/) { $OS = "$_"; }
	}
	if (!$OS) { $OS = "unknown operating system"; }

	# return $OS;
	}

if (!$OS_INFO{$OS}) {
	print <<EOLIST;
Unknown operating system ($OS) - choose one from the following list:

EOLIST
	for (sort keys %OS_INFO) { print "\t$_\n"; }
	die;
	}

print "OS is: $OS\n" if $verbose;

}

# Scaffolding for stand-alone testing...

if ($running_under_grave_robber) {
	require "command.pl";
} else {
	$running_under_grave_robber = 1;
	require "../conf/coroner.cf";
	require "command.pl";
	&determine_os() . "\n";
	print $OS . "\n";
}

1;