File Coverage

blib/lib/Devel/Platform/Info/Solaris.pm
Criterion Covered Total %
statement 9 30 30.0
branch 0 8 0.0
condition n/a
subroutine 3 5 60.0
pod 2 2 100.0
total 14 45 31.1


line stmt bran cond sub pod time code
1             package Devel::Platform::Info::Solaris;
2              
3 4     4   7907 use strict;
  4         13  
  4         121  
4 4     4   20 use warnings;
  4         6  
  4         112  
5              
6 4     4   20 use vars qw($VERSION);
  4         7  
  4         2343  
7             $VERSION = '1.00';
8              
9             #----------------------------------------------------------------------------
10              
11             my %commands = (
12             '_uname1' => 'uname -a',
13             '_showrev' => 'showrev -a | grep -v "^Patch"',
14             '_release' => 'cat /etc/release',
15             '_isainfo' => '/usr/bin/isainfo -kv',
16             'kname' => 'uname -s',
17             'kvers' => 'uname -r',
18             'archname' => 'uname -m',
19             );
20              
21             #----------------------------------------------------------------------------
22              
23             sub new {
24 0     0 1   my ($class) = @_;
25 0           my $self = {};
26 0           bless $self, $class;
27              
28 0           return $self;
29             }
30              
31             sub get_info {
32 0     0 1   my $self = shift;
33              
34 0           for my $cmd (keys %commands) {
35 0           $self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
36 0           $self->{cmds}{$cmd} =~ s/\s+$//s;
37 0 0         $self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd !~ /^_/);
38             }
39              
40 0           $self->{info}{osflag} = $^O;
41 0           $self->{info}{kernel} = lc($self->{info}{kname}) . '-' . $self->{info}{kvers};
42 0 0         $self->{info}{is32bit} = $self->{cmds}{_isainfo} !~ /64-bit/s ? 1 : 0;
43 0 0         $self->{info}{is64bit} = $self->{cmds}{_isainfo} =~ /64-bit/s ? 1 : 0;
44              
45 0           ($self->{info}{osname}) = $self->{cmds}{_release} =~ /((?:Open)?Solaris|SunOS|OpenIndiana)/is;
46 0           $self->{info}{oslabel} = $self->{info}{osname};
47 0           $self->{info}{osvers} = $self->{info}{kvers};
48              
49             # Solaris versions are based on SunOS, but just slightly different!
50 0 0         if($self->{info}{osname} =~ /Solaris/) {
51 0           $self->{info}{osvers} =~ s/^5\.([0123456]\b)/2.$1/;
52 0           $self->{info}{osvers} =~ s/^5\.(\d+)/$1/;
53             }
54              
55             # Question: Anyone know how to get the real version number for OpenSolaris?
56             # i.e. "2008.05" or "2009.06"
57              
58 0           $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
59 0           return $self->{info};
60             }
61              
62             #----------------------------------------------------------------------------
63              
64             1;
65              
66             __END__