blob: 78ea31d611d7ce3117ac7af24583dcee242b7c3b [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 ) {
Alp Toker763b9392014-02-28 09:42:41 +0000142} elsif ( $^O eq "linux" or $^O eq "freebsd" ) {
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";
Jim Cownie5e8470a2013-09-27 10:38:44 +0000381} else {
Alp Toker763b9392014-02-28 09:42:41 +0000382 die "Unsupported kernel_name (\"$values{ kernel_name }\") returned by POSIX::uname(); stopped";
Jim Cownie5e8470a2013-09-27 10:38:44 +0000383}; # if
384
385# host_name and domain_name
386$values{ host_name } =
387 sub {
388 my $fqdn = value( "fqdn" );
389 $fqdn =~ m{\A([^.]*)(?:\.(.*))?\z};
390 my $host_name = $1;
391 if ( not defined( $host_name ) or $host_name eq "" ) {
392 die "Unexpected error: undefined or empty host name; stopped";
393 }; # if
394 return $host_name;
395 };
396$values{ domain_name } =
397 sub {
398 my $fqdn = value( "fqdn" );
399 $fqdn =~ m{\A([^.]*)(?:\.(.*))?\z};
400 my $domain_name = $2;
401 if ( not defined( $domain_name ) or $domain_name eq "" ) {
402 die "Unexpected error: undefined or empty domain name; stopped";
403 }; # if
404 return $domain_name;
405 };
406
407# Replace undefined values with "unknown".
408foreach my $name ( @all ) {
409 if ( not defined( $values{ $name } ) ) {
410 $values{ $name } = "unknown";
411 }; # if
412}; # foreach $name
413
414# Export functions reporting properties.
415foreach my $name ( @all ) {
416 no strict "refs";
417 *$name = sub { return value( $name ); };
418}; # foreach $name
419
420# This function returns base names.
421sub base_names {
422 return @base;
423}; # sub base_names
424
425# This function returns all the names.
426sub all_names {
427 return @all;
428}; # sub all_names
429
430# This function returns value by the specified name.
431sub value($) {
432 my $name = shift( @_ );
433 if ( ref( $values{ $name } ) ) {
434 my $value = $values{ $name }->();
435 $values{ $name } = $value;
436 }; # if
437 return $values{ $name };
438}; # sub value
439
440return 1;
441
442__END__
443
444=pod
445
446=head1 NAME
447
448B<Uname.pm> -- A few subroutines to get system information usually provided by
449C</bin/uname> and C<POSIX::uname()>.
450
451=head1 SYNOPSIS
452
453 use Uname;
454
455 # Base property functions.
456 $kernel_name = Uname::kernel_name();
457 $fqdn = Uname::fqdn();
458 $kernel_release = Uname::kernel_release();
459 $kernel_version = Uname::kernel_version();
460 $machine = Uname::machine();
461 $processor = Uname::processor();
462 $hardware_platform = Uname::hardware_platform();
463 $operating_system = Uname::operating_system();
464
Alp Toker8f2d3f02014-02-24 10:40:15 +0000465 # Auxiliary property functions.
Jim Cownie5e8470a2013-09-27 10:38:44 +0000466 $host_name = Uname::host_name();
467 $domain_name = Uname::domain_name();
468 $os_name = Uname::operating_system_name();
469 $os_release = Uname::operating_system_release();
470 $os_codename = Uname::operating_system_codename();
471 $os_description = Uname::operating_system_description();
472
473 # Meta functions.
474 @base_names = Uname::base_names();
475 @all_names = Uname::all_names();
476 $kernel_name = Uname::value( "kernel_name" );
477
478=head1 DESCRIPTION
479
480B<Uname.pm> resembles functionality found in C<POSIX::uname()> function or in C<uname> program.
481However, both C<POSIX::uname()> and C</bin/uname> have some disadvantages:
482
483=over
484
485=item *
486
487C<uname> may be not available in some environments, for example, in Windows* OS
488(C<uname> may be found in some third-party software packages, like MKS Toolkit or Cygwin, but it is
489not a part of OS).
490
491=item *
492
493There are many different versions of C<uname>. For example, C<uname> on OS X* does not
494recognize options C<-i>, C<-o>, and any long options.
495
496=item *
497
498Different versions of C<uname> may report the same property differently. For example,
499C<uname> on Linux* OS reports machine as C<i686>, while C<uname> on OS X* reports the same machine as
500C<x86>.
501
502=item *
503
504C<POSIX::uname()> returns list of values. I cannot recall what is the fourth element of the list.
505
506=back
507
508=head2 Base Functions
509
510Base property functions provide the information as C<uname> program.
511
512=over
513
514=item B<kernel_name()>
515
516Returns the kernel name, as reported by C<POSIX::uname()>.
517
518=item B<fqdn()>
519
520Returns the FQDN, fully qualified domain name. On some systems C<POSIX::uname()> reports short node
521name (with no domain name), on others C<POSIX::uname()> reports full node name. This
522function strive to return FQDN always (by refining C<POSIX::uname()> with
523C<Net::Domain::hostfqdn()>).
524
525=item B<kernel_release()>
526
527Returns the kernel release string, as reported by C<POSIX::uname()>. Usually the string consists of
528several numbers, separated by dots and dashes, but may also include some non-numeric substrings like
529"smp".
530
531=item B<kernel_version()>
532
533Returns the kernel version string, as reported by C<POSIX::uname()>. It is B<not> several
534dot-separated numbers but much longer string describing the kernel.
535For example, on Linux* OS it includes build date.
536If you look for something identifying the kernel, look at L<kernel_release>.
537
538=item B<machine()>
539
540Returns the machine hardware name, as reported by POSIX::uname(). Not reliable. Different OSes may
541report the same machine hardware name differently. For example, Linux* OS reports C<i686>, while OS X*
542reports C<x86> on the same machine.
543
544=item B<processor()>
545
546Returns the processor type. Not reliable. Usually the same as C<machine>.
547
548=item B<hardware_platform()>
549
550One of: C<i386> or C<x86_64>.
551
552=item B<operating_system()>
553
554One of: C<GNU/Linux>, C<OS X*>, or C<MS Windows>.
555
556=back
557
Alp Toker8f2d3f02014-02-24 10:40:15 +0000558=head2 Auxiliary Functions
Jim Cownie5e8470a2013-09-27 10:38:44 +0000559
Alp Toker8f2d3f02014-02-24 10:40:15 +0000560Auxiliary functions extends base functions with information not reported by C<uname> program.
Jim Cownie5e8470a2013-09-27 10:38:44 +0000561
Alp Toker8f2d3f02014-02-24 10:40:15 +0000562Auxiliary functions collect information from different sources. For example, on OS X*, they may
Jim Cownie5e8470a2013-09-27 10:38:44 +0000563call C<sw_vers> program to find out OS release; on Linux* OS they may parse C</etc/redhat-release> file,
564etc.
565
566=over
567
568=item B<host_name()>
569
570Returns host name (FQDN with dropped domain part).
571
572=item B<domain_name()>
573
574Returns domain name (FQDN with dropped host part).
575
576=item B<operating_system_name>
577
578Name of operating system or name of Linux* OS distribution, like "Fedora" or
579"Red Hat Enterprise Linux* OS Server".
580
581=item B<operating_system_release>
582
583Release (version) of operating system or Linux* OS distribution. Usually it is a series of
584dot-separated numbers.
585
586=item B<operating_system_codename>
587
588Codename of operating system release or Linux* OS distribution. For example, Fedora 10 is "Cambridge"
589while OS X* 10.4 is "Tiger".
590
591=item B<operating_system_description>
592
593Longer string. Usually it includes all the operating system properting mentioned above -- name,
594release, codename in parentheses.
595
596=back
597
598=head2 Meta Functions
599
600=over
601
602=item B<base_names()>
603
604This function returns the list of base property names.
605
606=item B<all_names()>
607
608This function returns the list of all property names.
609
610=item B<value(> I<name> B<)>
611
612This function returns the value of the property specified by I<name>.
613
614=back
615
616=head1 EXAMPLES
617
618 use Uname;
619
620 print( Uname::string(), "\n" );
621
622 foreach my $name ( Uname::all_names() ) {
623 print( "$name=\"" . Uname::value( $name ) . "\"\n" );
624 }; # foreach $name
625
626=head1 SEE ALSO
627
628L<POSIX::uname>, L<uname>.
629
630=cut
631
632# end of file #
633