blob: 415070b7d3c2524167f49fc100b0327bf9759e31 [file] [log] [blame]
Jim Cownie5e8470a2013-09-27 10:38:44 +00001#
2# This is not a runnable script, it is a Perl module, a collection of variables, subroutines, etc.
3# To get help about exported variables and subroutines, execute the following command:
4#
5# perldoc Uname.pm
6#
7# or see POD (Plain Old Documentation) embedded to the source...
8#
9#
10#//===----------------------------------------------------------------------===//
11#//
12#// The LLVM Compiler Infrastructure
13#//
14#// This file is dual licensed under the MIT and the University of Illinois Open
15#// Source Licenses. See LICENSE.txt for details.
16#//
17#//===----------------------------------------------------------------------===//
18#
19
20package Uname;
21
22use strict;
23use warnings;
24use warnings::register;
25use Exporter;
26
27use POSIX;
28use File::Glob ":glob";
29use Net::Domain qw{};
30
31# Following code does not work with Perl 5.6 on Linux* OS and Windows* OS:
32#
33# use if $^O eq "darwin", tools => qw{};
34#
35# The workaround for Perl 5.6:
36#
37BEGIN {
38 if ( $^O eq "darwin" or $^O eq "linux" ) {
39 require tools;
40 import tools;
41 }; # if
42 if ( $^O eq "MSWin32" ) {
43 require Win32;
44 }; # if
45}; # BEGIN
46
47my $mswin = qr{\A(?:MSWin32|Windows_NT)\z};
48
49my @posix = qw{ kernel_name fqdn kernel_release kernel_version machine };
50 # Properties supported by POSIX::uname().
51my @linux =
52 qw{ processor hardware_platform operating_system };
53 # Properties reported by uname in Linux* OS.
54my @base = ( @posix, @linux );
55 # Base properties.
56my @aux =
57 (
58 qw{ host_name domain_name },
59 map( "operating_system_$_", qw{ name release codename description } )
60 );
Alp Toker8f2d3f02014-02-24 10:40:15 +000061 # Auxiliary properties.
Jim Cownie5e8470a2013-09-27 10:38:44 +000062my @all = ( @base, @aux );
63 # All the properties.
64my @meta = qw{ base_names all_names value };
65 # Meta functions.
66
67our $VERSION = "0.07";
68our @ISA = qw{ Exporter };
69our @EXPORT = qw{};
70our @EXPORT_OK = ( @all, @meta );
71our %EXPORT_TAGS =
72 (
73 base => [ @base ],
74 all => [ @all ],
75 meta => [ @meta ],
76 );
77
78my %values;
79 # Hash of values. Some values are strings, some may be references to code which should be
80 # evaluated to get real value. This trick is implemented because call to Net::Domain::hostfqdn()
81 # is relatively slow.
82
83# Get values from POSIX::uname().
84@values{ @posix } = POSIX::uname();
85
86# On some systems POSIX::uname() returns "short" node name (without domain name). To be consistent
87# on all systems, we will get node name from alternative source.
88if ( $^O =~ m/cygwin/i ) {
89 # Function from Net::Domain module works well, but on Cygwin it prints to
90 # stderr "domainname: not found". So we will use environment variables for now.
91 $values{ fqdn } = lc( $ENV{ COMPUTERNAME } . "." . $ENV{ USERDNSDOMAIN } );
92} else {
93 # On systems other than Cygwin, let us use Net::Domain::hostfqdn(), but do it only node name
94 # is really requested.
95 $values{ fqdn } =
96 sub {
97 my $fqdn = Net::Domain::hostfqdn(); # "fqdn" stands for "fully qualified doamain name".
98 # On some systems POSIX::uname() and Net::Domain::hostfqdn() reports different names.
99 # Let us issue a warning if they significantly different. Names are insignificantly
100 # different if POSIX::uname() matches the beginning of Net::Domain::hostfqdn().
101 if (
102 $fqdn eq substr( $fqdn, 0, length( $fqdn ) )
103 &&
104 (
105 length( $fqdn ) == length( $fqdn )
106 ||
107 substr( $fqdn, length( $fqdn ), 1 ) eq "."
108 )
109 ) {
110 # Ok.
111 } else {
112 warnings::warnif(
113 "POSIX::uname() and Net::Domain::hostfqdn() reported different names: " .
114 "\"$values{ fqdn }\" and \"$fqdn\" respectively\n"
115 );
116 }; # if
117 return $fqdn;
118 }; # sub
119}; # if
120
121if ( $^O =~ $mswin ) {
122 if (
123 $values{ machine } =~ m{\A(?:x86|[56]86)\z}
124 and
125 exists( $ENV{ PROCESSOR_ARCHITECTURE } ) and $ENV{ PROCESSOR_ARCHITECTURE } eq "x86"
126 and
127 exists( $ENV{ PROCESSOR_ARCHITEW6432 } )
128 ) {
129 if ( $ENV{ PROCESSOR_ARCHITEW6432 } eq "AMD64" ) {
130 $values{ machine } = "x86_64";
131 }; # if
132 }; # if
133}; # if
134
135# Some values are not returned by POSIX::uname(), let us compute them.
136
137# processor.
138$values{ processor } = $values{ machine };
139
140# hardware_platform.
141if ( 0 ) {
Joerg Sonnenberger40252ce2015-09-21 19:42:05 +0000142} elsif ( $^O eq "linux" or $^O eq "freebsd" or $^O eq "netbsd" ) {
Jim Cownie5e8470a2013-09-27 10:38:44 +0000143 if ( 0 ) {
144 } elsif ( $values{ machine } =~ m{\Ai[3456]86\z} ) {
145 $values{ hardware_platform } = "i386";
Alp Toker763b9392014-02-28 09:42:41 +0000146 } elsif ( $values{ machine } =~ m{\A(x86_64|amd64)\z} ) {
Jim Cownie5e8470a2013-09-27 10:38:44 +0000147 $values{ hardware_platform } = "x86_64";
Jim Cownie181b4bb2013-12-23 17:28:57 +0000148 } elsif ( $values{ machine } =~ m{\Aarmv7\D*\z} ) {
149 $values{ hardware_platform } = "arm";
Andrey Churbanovd1c55042015-01-19 18:29:35 +0000150 } elsif ( $values{ machine } =~ m{\Appc64le\z} ) {
151 $values{ hardware_platform } = "ppc64le";
Jim Cownie3051f972014-08-07 10:12:54 +0000152 } elsif ( $values{ machine } =~ m{\Appc64\z} ) {
153 $values{ hardware_platform } = "ppc64";
Andrey Churbanovcbda8682015-01-13 14:43:35 +0000154 } elsif ( $values{ machine } =~ m{\Aaarch64\z} ) {
155 $values{ hardware_platform } = "aarch64";
Jim Cownie5e8470a2013-09-27 10:38:44 +0000156 } else {
157 die "Unsupported machine (\"$values{ machine }\") returned by POSIX::uname(); stopped";
158 }; # if
159} elsif ( $^O eq "darwin" ) {
160 if ( 0 ) {
161 } elsif ( $values{ machine } eq "x86" or $values{ machine } eq "i386" ) {
162 $values{ hardware_platform } =
163 sub {
164 my $platform = "i386";
165 # Some OSes on Intel(R) 64 still reports "i386" machine. Verify it by using
166 # the value returned by 'sysctl -n hw.optional.x86_64'. On Intel(R) 64-bit systems the
167 # value == 1; on 32-bit systems the 'hw.optional.x86_64' property either does not exist
168 # or the value == 0. The path variable does not contain a path to sysctl when
169 # started by crontab.
170 my $sysctl = ( which( "sysctl" ) or "/usr/sbin/sysctl" );
171 my $output;
172 debug( "Executing $sysctl..." );
173 execute( [ $sysctl, "-n", "hw.optional.x86_64" ], -stdout => \$output, -stderr => undef );
174 chomp( $output );
175 if ( 0 ) {
176 } elsif ( "$output" eq "" or "$output" eq "0" ) {
177 $platform = "i386";
178 } elsif ( "$output" eq "1" ) {
179 $platform = "x86_64";
180 } else {
181 die "Unsupported value (\"$output\") returned by \"$sysctl -n hw.optional.x86_64\"; stopped";
182 }; # if
183 return $platform;
184 }; # sub {
185 } elsif ( $values{ machine } eq "x86_64" ) {
186 # Some OS X* versions report "x86_64".
187 $values{ hardware_platform } = "x86_64";
188 } else {
189 die "Unsupported machine (\"$values{ machine }\") returned by POSIX::uname(); stopped";
190 }; # if
191} elsif ( $^O =~ $mswin ) {
192 if ( 0 ) {
193 } elsif ( $values{ machine } =~ m{\A(?:x86|[56]86)\z} ) {
194 $values{ hardware_platform } = "i386";
195 } elsif ( $values{ machine } eq "x86_64" or $values{ machine } eq "amd64" ) {
196 # ActivePerl for IA-32 architecture returns "x86_64", while ActivePerl for Intel(R) 64 returns "amd64".
197 $values{ hardware_platform } = "x86_64";
198 } else {
199 die "Unsupported machine (\"$values{ machine }\") returned by POSIX::uname(); stopped";
200 }; # if
201} elsif ( $^O eq "cygwin" ) {
202 if ( 0 ) {
203 } elsif ( $values{ machine } =~ m{\Ai[3456]86\z} ) {
204 $values{ hardware_platform } = "i386";
205 } elsif ( $values{ machine } eq "x86_64" ) {
206 $values{ hardware_platform } = "x86_64";
207 } else {
208 die "Unsupported machine (\"$values{ machine }\") returned by POSIX::uname(); stopped";
209 }; # if
210} else {
211 die "Unsupported OS (\"$^O\"); stopped";
212}; # if
213
214# operating_system.
215if ( 0 ) {
216} elsif ( $values{ kernel_name } eq "Linux" ) {
217 $values{ operating_system } = "GNU/Linux";
Alp Toker8f2d3f02014-02-24 10:40:15 +0000218 my $release; # Name of chosen "*-release" file.
Jim Cownie5e8470a2013-09-27 10:38:44 +0000219 my $bulk; # Content of release file.
220 # On Ubuntu, lsb-release is quite informative, e. g.:
221 # DISTRIB_ID=Ubuntu
222 # DISTRIB_RELEASE=9.04
223 # DISTRIB_CODENAME=jaunty
224 # DISTRIB_DESCRIPTION="Ubuntu 9.04"
225 # Try lsb-release first. But on some older systems lsb-release is not informative.
226 # It may contain just one line:
227 # LSB_VERSION="1.3"
228 $release = "/etc/lsb-release";
229 if ( -e $release ) {
230 $bulk = read_file( $release );
231 } else {
232 $bulk = "";
233 }; # if
234 if ( $bulk =~ m{^DISTRIB_} ) {
235 # Ok, this lsb-release is informative.
236 $bulk =~ m{^DISTRIB_ID\s*=\s*(.*?)\s*$}m
237 or runtime_error( "$release: There is no DISTRIB_ID:", $bulk, "(eof)" );
238 $values{ operating_system_name } = $1;
239 $bulk =~ m{^DISTRIB_RELEASE\s*=\s*(.*?)\s*$}m
240 or runtime_error( "$release: There is no DISTRIB_RELEASE:", $bulk, "(eof)" );
241 $values{ operating_system_release } = $1;
242 $bulk =~ m{^DISTRIB_CODENAME\s*=\s*(.*?)\s*$}m
243 or runtime_error( "$release: There is no DISTRIB_CODENAME:", $bulk, "(eof)" );
244 $values{ operating_system_codename } = $1;
245 $bulk =~ m{^DISTRIB_DESCRIPTION\s*="?\s*(.*?)"?\s*$}m
246 or runtime_error( "$release: There is no DISTRIB_DESCRIPTION:", $bulk, "(eof)" );
247 $values{ operating_system_description } = $1;
248 } else {
249 # Oops. lsb-release is missed or not informative. Try other *-release files.
250 $release = "/etc/system-release";
251 if ( not -e $release ) { # Use /etc/system-release" if such file exists.
252 # Otherwise try other "/etc/*-release" files, but ignore "/etc/lsb-release".
253 my @releases = grep( $_ ne "/etc/lsb-release", bsd_glob( "/etc/*-release" ) );
254 # On some Fedora systems there are two files: fedora-release and redhat-release
255 # with identical content. If fedora-release present, ignore redjat-release.
256 if ( grep( $_ eq "/etc/fedora-release", @releases ) ) {
257 @releases = grep( $_ ne "/etc/redhat-release", @releases );
258 }; # if
259 if ( @releases == 1 ) {
260 $release = $releases[ 0 ];
261 } else {
262 if ( @releases == 0 ) {
263 # No *-release files found, try debian_version.
264 $release = "/etc/debian_version";
265 if ( not -e $release ) {
266 $release = undef;
267 warning( "No release files found in \"/etc/\" directory." );
268 }; # if
269 } else {
270 $release = undef;
271 warning( "More than one release files found in \"/etc/\" directory:", @releases );
272 }; # if
273 }; # if
274 }; # if
275 if ( defined( $release ) ) {
276 $bulk = read_file( $release );
277 if ( $release =~ m{system|redhat|fedora} ) {
278 # Red Hat or Fedora. Parse the first line of file.
279 # Typical values of *-release (one of):
280 # Red Hat Enterprise Linux* OS Server release 5.2 (Tikanga)
281 # Red Hat Enterprise Linux* OS AS release 3 (Taroon Update 4)
282 # Fedora release 10 (Cambridge)
283 $bulk =~ m{\A(.*)$}m
284 or runtime_error( "$release: Cannot find the first line:", $bulk, "(eof)" );
285 my $first_line = $1;
286 $values{ operating_system_description } = $first_line;
Jim Cownie181b4bb2013-12-23 17:28:57 +0000287 $first_line =~ m{\A(.*?)\s+release\s+(.*?)(?:\s+\((.*?)(?:\s+Update\s+(.*?))?\))?\s*$}
Jim Cownie5e8470a2013-09-27 10:38:44 +0000288 or runtime_error( "$release:1: Cannot parse line:", $first_line );
289 $values{ operating_system_name } = $1;
290 $values{ operating_system_release } = $2 . ( defined( $4 ) ? ".$4" : "" );
291 $values{ operating_system_codename } = $3;
292 } elsif ( $release =~ m{SuSE} ) {
293 # Typical SuSE-release:
294 # SUSE Linux* OS Enterprise Server 10 (x86_64)
295 # VERSION = 10
296 # PATCHLEVEL = 2
297 $bulk =~ m{\A(.*)$}m
298 or runtime_error( "$release: Cannot find the first line:", $bulk, "(eof)" );
299 my $first_line = $1;
300 $values{ operating_system_description } = $first_line;
301 $first_line =~ m{^(.*?)\s*(\d+)\s*\(.*?\)\s*$}
302 or runtime_error( "$release:1: Cannot parse line:", $first_line );
303 $values{ operating_system_name } = $1;
304 $bulk =~ m{^VERSION\s*=\s*(.*)\s*$}m
305 or runtime_error( "$release: There is no VERSION:", $bulk, "(eof)" );
306 $values{ operating_system_release } = $1;
307 if ( $bulk =~ m{^PATCHLEVEL\s*=\s*(.*)\s*$}m ) {
308 $values{ operating_system_release } .= ".$1";
309 }; # if
310 } elsif ( $release =~ m{debian_version} ) {
311 # Debian. The file debian_version contains just version number, nothing more:
312 # 4.0
313 my $name = "Debian";
314 $bulk =~ m{\A(.*)$}m
315 or runtime_error( "$release: Cannot find the first line:", $bulk, "(eof)" );
316 my $version = $1;
317 $values{ operating_system_name } = $name;
318 $values{ operating_system_release } = $version;
319 $values{ operating_system_codename } = "unknown";
320 $values{ operating_system_description } = sprintf( "%s %s", $name, $version );
321 }; # if
322 }; # if
323 }; # if
324 if ( not defined( $values{ operating_system_name } ) ) {
325 $values{ operating_system_name } = "GNU/Linux";
326 }; # if
327} elsif ( $values{ kernel_name } eq "Darwin" ) {
328 my %codenames = (
329 10.4 => "Tiger",
330 10.5 => "Leopard",
331 10.6 => "Snow Leopard",
332 );
333 my $darwin;
334 my $get_os_info =
335 sub {
336 my ( $name ) = @_;
337 if ( not defined $darwin ) {
338 $darwin->{ operating_system } = "Darwin";
339 # sw_vers prints OS X* version to stdout:
340 # ProductName: OS X*
341 # ProductVersion: 10.4.11
342 # BuildVersion: 8S2167
343 # It does not print codename, so we code OS X* codenames here.
344 my $sw_vers = which( "sw_vers" ) || "/usr/bin/sw_vers";
345 my $output;
346 debug( "Executing $sw_vers..." );
347 execute( [ $sw_vers ], -stdout => \$output, -stderr => undef );
348 $output =~ m{^ProductName:\s*(.*)\s*$}m
349 or runtime_error( "There is no ProductName in sw_vers output:", $output, "(eof)" );
350 my $name = $1;
351 $output =~ m{^ProductVersion:\s*(.*)\s*$}m
352 or runtime_error( "There is no ProductVersion in sw_vers output:", $output, "(eof)" );
353 my $release = $1;
354 # Sometimes release reported as "10.4.11" (3 componentes), sometimes as "10.6".
355 # Handle both variants.
356 $release =~ m{^(\d+.\d+)(?:\.\d+)?(?=\s|$)}
357 or runtime_error( "Cannot parse OS X* version: $release" );
358 my $version = $1;
359 my $codename = ( $codenames{ $version } or "unknown" );
360 $darwin->{ operating_system_name } = $name;
361 $darwin->{ operating_system_release } = $release;
362 $darwin->{ operating_system_codename } = $codename;
363 $darwin->{ operating_system_description } = sprintf( "%s %s (%s)", $name, $release, $codename );
364 }; # if
365 return $darwin->{ $name };
366 }; # sub
367 $values{ operating_system } = sub { $get_os_info->( "operating_system" ); };
368 $values{ operating_system_name } = sub { $get_os_info->( "operating_system_name" ); };
369 $values{ operating_system_release } = sub { $get_os_info->( "operating_system_release" ); };
370 $values{ operating_system_codename } = sub { $get_os_info->( "operating_system_codename" ); };
371 $values{ operating_system_description } = sub { $get_os_info->( "operating_system_description" ); };
372} elsif ( $values{ kernel_name } =~ m{\AWindows[ _]NT\z} ) {
373 $values{ operating_system } = "MS Windows";
374 # my @os_name = Win32::GetOSName();
375 # $values{ operating_system_release } = $os_name[ 0 ];
376 # $values{ operating_system_update } = $os_name[ 1 ];
377} elsif ( $values{ kernel_name } =~ m{\ACYGWIN_NT-} ) {
378 $values{ operating_system } = "MS Windows";
Alp Toker763b9392014-02-28 09:42:41 +0000379} elsif ( $values{ kernel_name } =~ m{\AFreeBSD} ) {
380 $values{ operating_system } = "FreeBSD";
Joerg Sonnenberger40252ce2015-09-21 19:42:05 +0000381} elsif ( $values{ kernel_name } =~ m{\ANetBSD} ) {
382 $values{ operating_system } = "NetBSD";
Jim Cownie5e8470a2013-09-27 10:38:44 +0000383} else {
Alp Toker763b9392014-02-28 09:42:41 +0000384 die "Unsupported kernel_name (\"$values{ kernel_name }\") returned by POSIX::uname(); stopped";
Jim Cownie5e8470a2013-09-27 10:38:44 +0000385}; # if
386
387# host_name and domain_name
388$values{ host_name } =
389 sub {
390 my $fqdn = value( "fqdn" );
391 $fqdn =~ m{\A([^.]*)(?:\.(.*))?\z};
392 my $host_name = $1;
393 if ( not defined( $host_name ) or $host_name eq "" ) {
394 die "Unexpected error: undefined or empty host name; stopped";
395 }; # if
396 return $host_name;
397 };
398$values{ domain_name } =
399 sub {
400 my $fqdn = value( "fqdn" );
401 $fqdn =~ m{\A([^.]*)(?:\.(.*))?\z};
402 my $domain_name = $2;
403 if ( not defined( $domain_name ) or $domain_name eq "" ) {
404 die "Unexpected error: undefined or empty domain name; stopped";
405 }; # if
406 return $domain_name;
407 };
408
409# Replace undefined values with "unknown".
410foreach my $name ( @all ) {
411 if ( not defined( $values{ $name } ) ) {
412 $values{ $name } = "unknown";
413 }; # if
414}; # foreach $name
415
416# Export functions reporting properties.
417foreach my $name ( @all ) {
418 no strict "refs";
419 *$name = sub { return value( $name ); };
420}; # foreach $name
421
422# This function returns base names.
423sub base_names {
424 return @base;
425}; # sub base_names
426
427# This function returns all the names.
428sub all_names {
429 return @all;
430}; # sub all_names
431
432# This function returns value by the specified name.
433sub value($) {
434 my $name = shift( @_ );
435 if ( ref( $values{ $name } ) ) {
436 my $value = $values{ $name }->();
437 $values{ $name } = $value;
438 }; # if
439 return $values{ $name };
440}; # sub value
441
442return 1;
443
444__END__
445
446=pod
447
448=head1 NAME
449
450B<Uname.pm> -- A few subroutines to get system information usually provided by
451C</bin/uname> and C<POSIX::uname()>.
452
453=head1 SYNOPSIS
454
455 use Uname;
456
457 # Base property functions.
458 $kernel_name = Uname::kernel_name();
459 $fqdn = Uname::fqdn();
460 $kernel_release = Uname::kernel_release();
461 $kernel_version = Uname::kernel_version();
462 $machine = Uname::machine();
463 $processor = Uname::processor();
464 $hardware_platform = Uname::hardware_platform();
465 $operating_system = Uname::operating_system();
466
Alp Toker8f2d3f02014-02-24 10:40:15 +0000467 # Auxiliary property functions.
Jim Cownie5e8470a2013-09-27 10:38:44 +0000468 $host_name = Uname::host_name();
469 $domain_name = Uname::domain_name();
470 $os_name = Uname::operating_system_name();
471 $os_release = Uname::operating_system_release();
472 $os_codename = Uname::operating_system_codename();
473 $os_description = Uname::operating_system_description();
474
475 # Meta functions.
476 @base_names = Uname::base_names();
477 @all_names = Uname::all_names();
478 $kernel_name = Uname::value( "kernel_name" );
479
480=head1 DESCRIPTION
481
482B<Uname.pm> resembles functionality found in C<POSIX::uname()> function or in C<uname> program.
483However, both C<POSIX::uname()> and C</bin/uname> have some disadvantages:
484
485=over
486
487=item *
488
489C<uname> may be not available in some environments, for example, in Windows* OS
490(C<uname> may be found in some third-party software packages, like MKS Toolkit or Cygwin, but it is
491not a part of OS).
492
493=item *
494
495There are many different versions of C<uname>. For example, C<uname> on OS X* does not
496recognize options C<-i>, C<-o>, and any long options.
497
498=item *
499
500Different versions of C<uname> may report the same property differently. For example,
501C<uname> on Linux* OS reports machine as C<i686>, while C<uname> on OS X* reports the same machine as
502C<x86>.
503
504=item *
505
506C<POSIX::uname()> returns list of values. I cannot recall what is the fourth element of the list.
507
508=back
509
510=head2 Base Functions
511
512Base property functions provide the information as C<uname> program.
513
514=over
515
516=item B<kernel_name()>
517
518Returns the kernel name, as reported by C<POSIX::uname()>.
519
520=item B<fqdn()>
521
522Returns the FQDN, fully qualified domain name. On some systems C<POSIX::uname()> reports short node
523name (with no domain name), on others C<POSIX::uname()> reports full node name. This
524function strive to return FQDN always (by refining C<POSIX::uname()> with
525C<Net::Domain::hostfqdn()>).
526
527=item B<kernel_release()>
528
529Returns the kernel release string, as reported by C<POSIX::uname()>. Usually the string consists of
530several numbers, separated by dots and dashes, but may also include some non-numeric substrings like
531"smp".
532
533=item B<kernel_version()>
534
535Returns the kernel version string, as reported by C<POSIX::uname()>. It is B<not> several
536dot-separated numbers but much longer string describing the kernel.
537For example, on Linux* OS it includes build date.
538If you look for something identifying the kernel, look at L<kernel_release>.
539
540=item B<machine()>
541
542Returns the machine hardware name, as reported by POSIX::uname(). Not reliable. Different OSes may
543report the same machine hardware name differently. For example, Linux* OS reports C<i686>, while OS X*
544reports C<x86> on the same machine.
545
546=item B<processor()>
547
548Returns the processor type. Not reliable. Usually the same as C<machine>.
549
550=item B<hardware_platform()>
551
552One of: C<i386> or C<x86_64>.
553
554=item B<operating_system()>
555
556One of: C<GNU/Linux>, C<OS X*>, or C<MS Windows>.
557
558=back
559
Alp Toker8f2d3f02014-02-24 10:40:15 +0000560=head2 Auxiliary Functions
Jim Cownie5e8470a2013-09-27 10:38:44 +0000561
Alp Toker8f2d3f02014-02-24 10:40:15 +0000562Auxiliary functions extends base functions with information not reported by C<uname> program.
Jim Cownie5e8470a2013-09-27 10:38:44 +0000563
Alp Toker8f2d3f02014-02-24 10:40:15 +0000564Auxiliary functions collect information from different sources. For example, on OS X*, they may
Jim Cownie5e8470a2013-09-27 10:38:44 +0000565call C<sw_vers> program to find out OS release; on Linux* OS they may parse C</etc/redhat-release> file,
566etc.
567
568=over
569
570=item B<host_name()>
571
572Returns host name (FQDN with dropped domain part).
573
574=item B<domain_name()>
575
576Returns domain name (FQDN with dropped host part).
577
578=item B<operating_system_name>
579
580Name of operating system or name of Linux* OS distribution, like "Fedora" or
581"Red Hat Enterprise Linux* OS Server".
582
583=item B<operating_system_release>
584
585Release (version) of operating system or Linux* OS distribution. Usually it is a series of
586dot-separated numbers.
587
588=item B<operating_system_codename>
589
590Codename of operating system release or Linux* OS distribution. For example, Fedora 10 is "Cambridge"
591while OS X* 10.4 is "Tiger".
592
593=item B<operating_system_description>
594
595Longer string. Usually it includes all the operating system properting mentioned above -- name,
596release, codename in parentheses.
597
598=back
599
600=head2 Meta Functions
601
602=over
603
604=item B<base_names()>
605
606This function returns the list of base property names.
607
608=item B<all_names()>
609
610This function returns the list of all property names.
611
612=item B<value(> I<name> B<)>
613
614This function returns the value of the property specified by I<name>.
615
616=back
617
618=head1 EXAMPLES
619
620 use Uname;
621
622 print( Uname::string(), "\n" );
623
624 foreach my $name ( Uname::all_names() ) {
625 print( "$name=\"" . Uname::value( $name ) . "\"\n" );
626 }; # foreach $name
627
628=head1 SEE ALSO
629
630L<POSIX::uname>, L<uname>.
631
632=cut
633
634# end of file #
635