Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of http://github.com/barbie/devel-platform-info

  • Loading branch information...
commit 7b5bd274f92389d155e6239cba8c26381c8cacb0 2 parents bba614f + 0200d6a
@colinnewell colinnewell authored
View
12 Changes
@@ -1,6 +1,18 @@
Revision history for Perl library Devel-Platform-Info
=====================================================
+0.04 04/07/2010
+ - fixed Solaris internal references.
+ - fixed BSD kernel version formatting.
+ - changed 'source' to be a hash not a string. (Colin's suggestion).
+
+0.03 02/07/2010
+ - added support for more known Linux distributions.
+ - better pattern matching for osvers and oslabel in Linux.pm
+ - added reference links.
+ - reimplemented use tests for plugins.
+ - added specific support plugin for Solaris family.
+
0.02 01/07/2010
- added support for Irix and the BSD family.
View
1  MANIFEST
@@ -6,6 +6,7 @@ lib/Devel/Platform/Info/Irix.pm
lib/Devel/Platform/Info/Linux.pm
lib/Devel/Platform/Info/Mac.pm
lib/Devel/Platform/Info/SCO.pm
+lib/Devel/Platform/Info/Solaris.pm
lib/Devel/Platform/Info/Win32.pm
Makefile.PL
MANIFEST
View
28 META.json
@@ -1,6 +1,6 @@
{
"name": "Devel-Platform-Info",
- "version": "0.02",
+ "version": "0.04",
"abstract": "Unified framework for obtaining common platform metadata.",
"author": [
"Barbie (BARBIE) <barbie@cpan.org>",
@@ -24,7 +24,7 @@
],
"optional_features" : {
- "win32" : {
+ "windows" : {
"description" : "for Win32 support",
"prereqs" : {
"runtime" : {
@@ -35,7 +35,7 @@
}
}
}
- }
+ },
"prereqs" : {
"test" : {
@@ -56,31 +56,35 @@
"provides": {
"Devel::Platform::Info": {
"file": "lib/Devel/Platform/Info.pm",
- "version": "0.02"
+ "version": "0.04"
},
"Devel::Platform::Info::BSD": {
"file": "lib/Devel/Platform/Info/BSD.pm",
- "version": "0.02"
- }
+ "version": "0.04"
+ },
"Devel::Platform::Info::Irix": {
"file": "lib/Devel/Platform/Info/Irix.pm",
- "version": "0.02"
- }
+ "version": "0.04"
+ },
"Devel::Platform::Info::Linux": {
"file": "lib/Devel/Platform/Info/Linux.pm",
- "version": "0.02"
+ "version": "0.04"
},
"Devel::Platform::Info::Mac": {
"file": "lib/Devel/Platform/Info/Mac.pm",
- "version": "0.02"
+ "version": "0.04"
},
"Devel::Platform::Info::SCO": {
"file": "lib/Devel/Platform/Info/SCO.pm",
- "version": "0.02"
+ "version": "0.04"
+ },
+ "Devel::Platform::Info::Solaris": {
+ "file": "lib/Devel/Platform/Info/Solaris.pm",
+ "version": "0.04"
},
"Devel::Platform::Info::Win32": {
"file": "lib/Devel/Platform/Info/Win32.pm",
- "version": "0.02"
+ "version": "0.04"
}
},
"no_index": {
View
19 META.yml
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Devel-Platform-Info
-version: 0.02
+version: 0.04
abstract: Unified framework for obtaining common platform metadata
author:
- Barbie (BARBIE) <barbie@cpan.org>
@@ -27,25 +27,28 @@ build_requires:
provides:
Devel::Platform::Info:
file: lib/Devel/Platform/Info.pm
- version: 0.02
+ version: 0.04
Devel::Platform::Info::BSD:
file: lib/Devel/Platform/Info/BSD.pm
- version: 0.02
+ version: 0.04
Devel::Platform::Info::Irix:
file: lib/Devel/Platform/Info/Irix.pm
- version: 0.02
+ version: 0.04
Devel::Platform::Info::Linux:
file: lib/Devel/Platform/Info/Linux.pm
- version: 0.02
+ version: 0.04
Devel::Platform::Info::Mac:
file: lib/Devel/Platform/Info/Mac.pm
- version: 0.02
+ version: 0.04
Devel::Platform::Info::SCO:
file: lib/Devel/Platform/Info/SCO.pm
- version: 0.02
+ version: 0.04
+ Devel::Platform::Info::Solaris:
+ file: lib/Devel/Platform/Info/Solaris.pm
+ version: 0.04
Devel::Platform::Info::Win32:
file: lib/Devel/Platform/Info/Win32.pm
- version: 0.02
+ version: 0.04
no_index:
directory:
View
10 lib/Devel/Platform/Info.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '0.02';
+$VERSION = '0.04';
#----------------------------------------------------------------------------
@@ -24,12 +24,12 @@ my %map = (
'svr4' => 'Linux',
'unicos' => 'Linux',
'unicosmk' => 'Linux',
- 'solaris' => 'Linux',
'sunos' => 'Linux',
'ultrix' => 'Linux',
'sco_sv' => 'SCO',
'sco3' => 'SCO',
'sco' => 'SCO',
+ 'solaris' => 'Solaris',
# Windows family OSes
'dos' => 'Win32',
@@ -151,6 +151,12 @@ to the specific operating system.
=back
+=head1 REFERENCES
+
+The following links were used to understand how to retrieve the metadata:
+
+ * http://alma.ch/perl/perloses.htm
+
=head1 BUGS, PATCHES & FIXES
There are no known bugs at the time of this release. However, if you spot a
View
5 lib/Devel/Platform/Info/BSD.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '0.02';
+$VERSION = '0.04';
#----------------------------------------------------------------------------
@@ -32,12 +32,12 @@ sub get_info {
for my $cmd (keys %commands) {
$self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
- $self->{info}{source} .= "$commands{$cmd}\n$self->{cmds}{$cmd}\n";
$self->{cmds}{$cmd} =~ s/\s+$//s;
$self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd =~ /^[^_]/);
}
$self->{info}{osflag} = $^O;
+ $self->{info}{kvers} = lc $self->{info}{kvers};
$self->{info}{kernel} = lc($self->{info}{kname}) . '-' . $self->{info}{kvers};
$self->{info}{osname} = $self->{info}{kname};
$self->{info}{oslabel} = $self->{info}{kname};
@@ -46,6 +46,7 @@ sub get_info {
$self->{info}{is32bit} = $self->{info}{kname} !~ /64/ ? 1 : 0;
$self->{info}{is64bit} = $self->{info}{kname} =~ /64/ ? 1 : 0;
+ $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
return $self->{info};
}
View
4 lib/Devel/Platform/Info/Irix.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '0.02';
+$VERSION = '0.04';
#----------------------------------------------------------------------------
@@ -35,7 +35,6 @@ sub get_info {
for my $cmd (keys %commands) {
$self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
- $self->{info}{source} .= "$commands{$cmd}\n$self->{cmds}{$cmd}\n";
$self->{cmds}{$cmd} =~ s/\s+$//s;
$self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd =~ /^[^_]/);
}
@@ -48,6 +47,7 @@ sub get_info {
$self->{info}{is32bit} = $self->{info}{kname} !~ /64/ ? 1 : 0;
$self->{info}{is64bit} = $self->{info}{kname} =~ /64/ ? 1 : 0;
+ $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
return $self->{info};
}
View
163 lib/Devel/Platform/Info/Linux.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '0.02';
+$VERSION = '0.04';
#----------------------------------------------------------------------------
@@ -17,8 +17,6 @@ my %commands = (
'kvers' => 'uname -r',
'osname' => 'uname -o',
'archname' => 'uname -m',
-
- '_irix1' => 'uname -R', # IRIX specific
);
my %default = ();
@@ -100,41 +98,76 @@ my %mandriva = (
'2010.0' => 'Mandriva Linux 2010 (Adélie)',
);
+my %ubuntu = (
+ '4.10' => 'Warty Warthog',
+ '5.04' => 'Hoary Hedgehog',
+ '5.10' => 'Breezy Badger',
+ '6.06' => 'Dapper Drake',
+ '6.10' => 'Edgy Eft',
+ '7.04' => 'Feisty Fawn',
+ '7.10' => 'Gutsy Gibbon',
+ '8.04' => 'Hardy Heron',
+ '8.10' => 'Intrepid Ibex',
+ '9.04' => 'Jaunty Jackalope',
+ '9.10' => 'Karmic Koala',
+ '10.04' => 'Lucid Lynx',
+);
+
my %distributions = (
- 'Annvix' => { codenames => \%default, files => [ qw( /etc/annvix-release ) ] },
- 'Arch Linux' => { codenames => \%archlinux, files => [ qw( /etc/arch-release ) ] },
- 'Arklinux' => { codenames => \%default, files => [ qw( /etc/arklinux-release ) ] },
- 'Aurox Linux' => { codenames => \%default, files => [ qw( /etc/aurox-release ) ] },
- 'BlackCat' => { codenames => \%default, files => [ qw( /etc/blackcat-release ) ] },
- 'Cobalt' => { codenames => \%default, files => [ qw( /etc/cobalt-release ) ] },
- 'Conectiva' => { codenames => \%default, files => [ qw( /etc/conectiva-release ) ] },
- 'Debian' => { codenames => \%debian, files => [ qw( /etc/debian_version /etc/debian_release ) ] },
- 'Fedora Core' => { codenames => \%fedora, files => [ qw( /etc/fedora-release ) ] },
- 'Gentoo Linux' => { codenames => \%default, files => [ qw( /etc/gentoo-release ) ] },
- 'Immunix' => { codenames => \%default, files => [ qw( /etc/immunix-release ) ] },
- 'Knoppix' => { codenames => \%default, files => [ qw( /etc/knoppix_version ) ] },
- 'Linux-From-Scratch' => { codenames => \%default, files => [ qw( /etc/lfs-release ) ] },
- 'Linux-PPC' => { codenames => \%default, files => [ qw( /etc/linuxppc-release ) ] },
- 'Mandrake' => { codenames => \%mandriva, files => [ qw( /etc/mandrake-release ) ] },
- 'Mandriva' => { codenames => \%mandriva, files => [ qw( /etc/mandriva-release /etc/mandrake-release /etc/mandakelinux-release ) ] },
- 'Mandrake Linux' => { codenames => \%mandriva, files => [ qw( /etc/mandriva-release /etc/mandrake-release /etc/mandakelinux-release ) ] },
- 'MkLinux' => { codenames => \%default, files => [ qw( /etc/mklinux-release ) ] },
- 'Novell Linux Desktop' => { codenames => \%default, files => [ qw( /etc/nld-release ) ] },
- 'PLD Linux' => { codenames => \%default, files => [ qw( /etc/pld-release ) ] },
- 'Red Hat' => { codenames => \%default, files => [ qw( /etc/redhat-release /etc/redhat_version ) ] },
- 'Slackware' => { codenames => \%default, files => [ qw( /etc/slackware-version /etc/slackware-release ) ] },
- 'SME Server' => { codenames => \%default, files => [ qw( /etc/e-smith-release ) ] },
- 'Solaris SPARC' => { codenames => \%default, files => [ qw( /etc/release ) ] },
- 'Sun JDS' => { codenames => \%default, files => [ qw( /etc/sun-release ) ] },
- 'SUSE Linux' => { codenames => \%default, files => [ qw( /etc/SuSE-release /etc/novell-release ) ] },
- 'SUSE Linux ES9' => { codenames => \%default, files => [ qw( /etc/sles-release ) ] },
- 'Tiny Sofa' => { codenames => \%default, files => [ qw( /etc/tinysofa-release ) ] },
- 'TurboLinux' => { codenames => \%default, files => [ qw( /etc/turbolinux-release ) ] },
- 'Ubuntu Linux' => { codenames => \%default, files => [ qw( /etc/lsb-release ) ] },
- 'UltraPenguin' => { codenames => \%default, files => [ qw( /etc/ultrapenguin-release ) ] },
- 'UnitedLinux' => { codenames => \%default, files => [ qw( /etc/UnitedLinux-release ) ] },
- 'VA-Linux/RH-VALE' => { codenames => \%default, files => [ qw( /etc/va-release ) ] },
- 'Yellow Dog' => { codenames => \%default, files => [ qw( /etc/yellowdog-release ) ] },
+ 'Adamantix' => { codenames => \%default, files => [ qw( /etc/adamantix_version ) ] },
+ 'Annvix' => { codenames => \%default, files => [ qw( /etc/annvix-release ) ] },
+ 'Arch Linux' => { codenames => \%archlinux, files => [ qw( /etc/arch-release ) ] },
+ 'Arklinux' => { codenames => \%default, files => [ qw( /etc/arklinux-release ) ] },
+ 'Aurox Linux' => { codenames => \%default, files => [ qw( /etc/aurox-release ) ] },
+ 'BlackCat' => { codenames => \%default, files => [ qw( /etc/blackcat-release ) ] },
+ 'Cobalt' => { codenames => \%default, files => [ qw( /etc/cobalt-release ) ] },
+ 'Conectiva' => { codenames => \%default, files => [ qw( /etc/conectiva-release ) ] },
+ 'Debian' => { codenames => \%debian, key => 'debian', files => [ qw( /etc/debian_version /etc/debian_release ) ] },
+ 'Fedora Core' => { codenames => \%fedora, key => 'fedora', files => [ qw( /etc/fedora-release ) ] },
+ 'Gentoo Linux' => { codenames => \%default, key => 'gentoo', files => [ qw( /etc/gentoo-release ) ] },
+ 'Immunix' => { codenames => \%default, files => [ qw( /etc/immunix-release ) ] },
+ 'Knoppix' => { codenames => \%default, files => [ qw( /etc/knoppix_version ) ] },
+ 'Libranet' => { codenames => \%default, files => [ qw( /etc/libranet_version ) ] },
+ 'Linux-From-Scratch' => { codenames => \%default, files => [ qw( /etc/lfs-release ) ] },
+ 'Linux-PPC' => { codenames => \%default, files => [ qw( /etc/linuxppc-release ) ] },
+ 'Mandrake' => { codenames => \%mandriva, files => [ qw( /etc/mandrake-release ) ] },
+ 'Mandriva' => { codenames => \%mandriva, files => [ qw( /etc/mandriva-release /etc/mandrake-release /etc/mandakelinux-release ) ] },
+ 'Mandrake Linux' => { codenames => \%mandriva, files => [ qw( /etc/mandriva-release /etc/mandrake-release /etc/mandakelinux-release ) ] },
+ 'MkLinux' => { codenames => \%default, files => [ qw( /etc/mklinux-release ) ] },
+ 'Novell Linux Desktop' => { codenames => \%default, files => [ qw( /etc/nld-release ) ] },
+ 'Pardus' => { codenames => \%default, key => 'pardus', files => [ qw( /etc/pardus-release ) ] },
+ 'PLD Linux' => { codenames => \%default, files => [ qw( /etc/pld-release ) ] },
+ 'Red Flag' => { codenames => \%default, key => 'redflag', files => [ qw( /etc/redflag-release ) ] },
+ 'Red Hat' => { codenames => \%default, key => 'redhat', files => [ qw( /etc/redhat-release /etc/redhat_version ) ] },
+ 'Slackware' => { codenames => \%default, key => 'slackware', files => [ qw( /etc/slackware-version /etc/slackware-release ) ] },
+ 'SME Server' => { codenames => \%default, files => [ qw( /etc/e-smith-release ) ] },
+ 'Sun JDS' => { codenames => \%default, files => [ qw( /etc/sun-release ) ] },
+ 'SUSE Linux' => { codenames => \%default, key => 'suse', files => [ qw( /etc/SuSE-release /etc/novell-release ) ] },
+ 'SUSE Linux ES9' => { codenames => \%default, key => 'suse', files => [ qw( /etc/sles-release ) ] },
+ 'Tiny Sofa' => { codenames => \%default, files => [ qw( /etc/tinysofa-release ) ] },
+ 'Trustix Secure Linux' => { codenames => \%default, files => [ qw( /etc/trustix-release ) ] },
+ 'TurboLinux' => { codenames => \%default, files => [ qw( /etc/turbolinux-release ) ] },
+ 'Ubuntu Linux' => { codenames => \%ubuntu, files => [ qw( /etc/lsb-release ) ] },
+ 'UltraPenguin' => { codenames => \%default, files => [ qw( /etc/ultrapenguin-release ) ] },
+ 'UnitedLinux' => { codenames => \%default, files => [ qw( /etc/UnitedLinux-release ) ] },
+ 'VA-Linux/RH-VALE' => { codenames => \%default, files => [ qw( /etc/va-release ) ] },
+ 'Yellow Dog' => { codenames => \%default, files => [ qw( /etc/yellowdog-release ) ] },
+ 'Yoper' => { codenames => \%default, files => [ qw( /etc/yoper-release ) ] },
+);
+
+my %version_pattern = (
+ 'gentoo' => 'Gentoo Base System version (.*)',
+ 'debian' => '(.+)',
+ 'suse' => 'VERSION = (.*)',
+ 'fedora' => 'Fedora Core release (\d+) \(',
+ 'redflag' => 'Red Flag (?:Desktop|Linux) (?:release |\()(.*?)(?: \(.+)?\)',
+ 'redhat' => 'Red Hat Linux release (.*) \(',
+ 'slackware' => '^Slackware (.+)$',
+ 'pardus' => '^Pardus (.+)$',
+);
+
+my %oslabel_pattern = (
+ 'suse' => '^(\S+)',
);
#----------------------------------------------------------------------------
@@ -152,7 +185,6 @@ sub get_info {
for my $cmd (keys %commands) {
$self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
- $self->{info}{source} .= "$commands{$cmd}\n$self->{cmds}{$cmd}\n";
$self->{cmds}{$cmd} =~ s/\s+$//s;
$self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd =~ /^[^_]/);
}
@@ -171,6 +203,7 @@ sub get_info {
$self->_release_version();
}
+ $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
return $self->{info};
}
@@ -179,44 +212,46 @@ sub get_info {
sub _release_version {
my $self = shift;
- if($self->{info}{kname} =~ /irix/i) {
- $self->{info}{osname} = 'IRIX';
- $self->{info}{oslabel} = 'IRIX';
- $self->{info}{is32bit} = $self->{info}{kname} !~ /64/ ? 1 : 0;
- $self->{info}{is64bit} = $self->{info}{kname} =~ /64/ ? 1 : 0;
- return;
- }
-
for my $label (keys %distributions) {
for my $file (@{ $distributions{$label}->{files} }) {
next unless(-f $file);
my $line = `cat $file 2>/dev/null`;
- my ($version) = $line =~ /VERSION\s*=\s*(.*)\n?/si;
+ my ($version,$oslabel);
+ if($distributions{$label}->{key}) {
+ if($version_pattern{ $distributions{$label}->{key} }) {
+ ($version) = $line =~ /$version_pattern{ $distributions{$label}->{key} }/si;
+ }
+ if($oslabel_pattern{ $distributions{$label}->{key} }) {
+ ($oslabel) = $line =~ /$oslabel_pattern{ $distributions{$label}->{key} }/si;
+ }
+ }
+
$version = $line unless($version);
$version =~ s/\s*$//;
- my $oslabel;
- if($label eq 'SUSE Linux') {
- ($oslabel) = $line =~ /^(\S*)/;
- } elsif($self->{cmds}{'_issue1'}) {
- ($oslabel) = $self->{cmds}{'_issue1'} =~ /^(\S*)/;
- } elsif($self->{cmds}{'_issue2'}) {
- ($oslabel) = $self->{cmds}{'_issue2'} =~ /^(\S*)/;
+ unless($oslabel) {
+ if($self->{cmds}{'_issue1'}) {
+ ($oslabel) = $self->{cmds}{'_issue1'} =~ /^(\S*)/;
+ } elsif($self->{cmds}{'_issue2'}) {
+ ($oslabel) = $self->{cmds}{'_issue2'} =~ /^(\S*)/;
+ }
+ $oslabel ||= $label; # a last resort
}
- $oslabel ||= $label; # just in case
+
+ $self->{info}{oslabel} = $oslabel;
+ $self->{info}{osvers} = $version;
+ $commands{'_cat'} = "cat $file";
+ $self->{cmds}{'_cat'} = $line;
for my $vers (keys %{ $distributions{$label}->{codenames} }) {
if($version =~ /^$vers\b/) {
$self->{info}{codename} = $distributions{$label}->{codenames}{$vers};
- $self->{info}{oslabel} = $oslabel;
- $self->{info}{osvers} = $version;
-
- $self->{info}{source} .= "cat $file\n$line\n";
-
return;
}
}
+
+ return;
}
}
}
@@ -279,6 +314,14 @@ Returns the following keys:
=back
+=head1 REFERENCES
+
+The following links were used to understand how to retrieve the metadata:
+
+ * http://distrowatch.com/
+ * Wikipedia pages for various Linux and Unix based OSes
+ * http://search.cpan.org/dist/Sys-Info-Driver-Linux
+
=head1 BUGS, PATCHES & FIXES
There are no known bugs at the time of this release. However, if you spot a
View
9 lib/Devel/Platform/Info/Mac.pm
@@ -4,8 +4,7 @@ use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '0.02';
-
+$VERSION = '0.04';
#-------------------------------------------------------------------------------
@@ -63,10 +62,7 @@ sub _command {
my $command = shift;
my $result = `$command`;
- $self->{info}{source} .= $command;
- $self->{info}{source} .= "\n";
- $self->{info}{source} .= $result;
- $self->{info}{source} .= "\n";
+ $self->{info}{source}{$command} = $result;
chomp $result;
return $result;
@@ -86,7 +82,6 @@ sub _macos_versions {
};
}
-
#-------------------------------------------------------------------------------
1;
View
11 lib/Devel/Platform/Info/SCO.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '0.02';
+$VERSION = '0.04';
#----------------------------------------------------------------------------
@@ -48,21 +48,22 @@ sub get_info {
my $self = shift;
for my $cmd (keys %commands) {
- $self->{info}{$cmd} = `$commands{$cmd}`;
- $self->{info}{source} .= "$commands{$cmd}\n$self->{info}{$cmd}\n";
- $self->{info}{$cmd} =~ s/\s+$//s;
+ $self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
+ $self->{cmds}{$cmd} =~ s/\s+$//s;
+ $self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd =~ /^[^_]/);
}
$self->{info}{osflag} = $^O;
$self->{info}{osname} = 'SCO';
$self->{info}{kernel} = lc($self->{info}{kname}) . '-' . $self->{info}{kvers};
- ($self->{info}{osvers}) = $self->{info}{'_lsb'} =~ /Release\s*=\s*(.*?)\n/s;
+ ($self->{info}{osvers}) = $self->{cmds}{'_lsb'} =~ /Release\s*=\s*(.*?)\n/s;
($self->{info}{oslabel}) = $releases{ $self->{info}{osvers} }->{oslabel};
($self->{info}{codename}) = $releases{ $self->{info}{osvers} }->{codename};
$self->{info}{is32bit} = $self->{info}{archname} !~ /_(64)$/ ? 1 : 0;
$self->{info}{is64bit} = $self->{info}{archname} =~ /_(64)$/ ? 1 : 0;
+ $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
return $self->{info};
}
View
146 lib/Devel/Platform/Info/Solaris.pm
@@ -0,0 +1,146 @@
+package Devel::Platform::Info::Solaris;
+
+use strict;
+use warnings;
+
+use vars qw($VERSION);
+$VERSION = '0.04';
+
+#----------------------------------------------------------------------------
+
+my %commands = (
+ '_uname1' => 'uname -a',
+ '_showrev' => 'showrev -a | grep -v "^Patch"',
+ '_release' => 'cat /etc/release',
+ '_isainfo' => '/usr/bin/isainfo -kv',
+ 'kname' => 'uname -s',
+ 'kvers' => 'uname -r',
+ 'archname' => 'uname -m',
+);
+
+#----------------------------------------------------------------------------
+
+sub new {
+ my ($class) = @_;
+ my $self = {};
+ bless $self, $class;
+
+ return $self;
+}
+
+sub get_info {
+ my $self = shift;
+
+ for my $cmd (keys %commands) {
+ $self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
+ $self->{cmds}{$cmd} =~ s/\s+$//s;
+ $self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd =~ /^[^_]/);
+ }
+
+ $self->{info}{osflag} = $^O;
+ $self->{info}{kernel} = lc($self->{info}{kname}) . '-' . $self->{info}{kvers};
+ $self->{info}{is32bit} = $self->{cmds}{_isainfo} !~ /64-bit/s ? 1 : 0;
+ $self->{info}{is64bit} = $self->{cmds}{_isainfo} =~ /64-bit/s ? 1 : 0;
+
+ ($self->{info}{osname}) = $self->{cmds}{_release} =~ /^(\S+)/;
+ $self->{info}{oslabel} = $self->{info}{osname};
+ $self->{info}{osvers} = $self->{info}{kname};
+ $self->{info}{osvers} =~ s/^5/2/; # a bit of a hack :(
+
+ # Question: Anyone know how to get the real version number for OpenSolaris?
+ # i.e. "2008.05" or "2009.06"
+
+ $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
+ return $self->{info};
+}
+
+#----------------------------------------------------------------------------
+
+1;
+
+__END__
+
+=head1 NAME
+
+Devel::Platform::Info::Solaris - Retrieve Solaris platform metadata
+
+=head1 SYNOPSIS
+
+ use Devel::Platform::Info::Solaris;
+ my $info = Devel::Platform::Info::Solaris->new();
+ my $data = $info->get_info();
+
+=head1 DESCRIPTION
+
+This module is a driver to determine platform metadata regarding the Solaris
+operating system. It should be called indirectly via it's parent
+Devel::Platform::Info
+
+=head1 INTERFACE
+
+=head2 The Constructor
+
+=over
+
+=item * new
+
+Simply constructs the object.
+
+=back
+
+=head2 Methods
+
+=over 4
+
+=item * get_info
+
+Returns a hash reference to the Solaris platform metadata.
+
+Returns the following keys:
+
+ source
+ archname
+ osname
+ osvers
+ oslabel
+ is32bit
+ is64bit
+ osflag
+
+ kernel
+ kname
+ kvers
+
+=back
+
+=head1 REFERENCES
+
+The following links were used to understand how to retrieve the metadata:
+
+ * http://www.symantec.com/connect/blogs/commands-find-out-solaris-os-version-ralus-rmal-issues
+ * http://docs.sun.com/app/docs/doc/816-0211/6m6nc676p?a=view
+ * http://docs.sun.com/app/docs/doc/816-5138/6mba6ua58?a=view
+
+=head1 BUGS, PATCHES & FIXES
+
+There are no known bugs at the time of this release. However, if you spot a
+bug or are experiencing difficulties, that is not explained within the POD
+documentation, please send bug reports and patches to the RT Queue (see below).
+
+RT Queue: http://rt.cpan.org/Public/Dist/Display.html?Name=Devel-Platform-Info
+
+=head1 AUTHORS
+
+ Barbie (BARBIE) <barbie@cpan.org>
+ Brian McCauley (NOBULL) <nobull67@gmail.com>
+ Colin Newell http://colinnewell.wordpress.com/
+ Jon 'JJ' Allen (JONALLEN) <jj@jonallen.info>
+
+=head1 COPYRIGHT & LICENSE
+
+ Copyright (C) 2010 Birmingham Perl Mongers
+
+ This module is free software; you can redistribute it and/or
+ modify it under the Artistic License 2.0.
+
+=cut
View
2  lib/Devel/Platform/Info/Win32.pm
@@ -5,7 +5,7 @@ use warnings;
use POSIX;
use vars qw($VERSION);
-$VERSION = '0.02';
+$VERSION = '0.04';
#----------------------------------------------------------------------------
View
3  t/01base.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 7;
+use Test::More tests => 8;
BEGIN {
use_ok( 'Devel::Platform::Info' );
@@ -10,5 +10,6 @@ BEGIN {
use_ok( 'Devel::Platform::Info::Linux' );
use_ok( 'Devel::Platform::Info::Mac' );
use_ok( 'Devel::Platform::Info::SCO' );
+ use_ok( 'Devel::Platform::Info::Solaris' );
use_ok( 'Devel::Platform::Info::Win32' );
}
View
6 t/02diag.t
@@ -10,7 +10,11 @@ my $data = $info->get_info();
isnt($data,undef);
diag("OS: $^O");
+
if($data) {
- diag(".. $_ => " . (defined $data->{$_} ? $data->{$_} : '')) for(keys %$data);
+ diag('.. source => ');
+ diag(" .. $_ => " . (defined $data->{source}{$_} ? $data->{source}{$_} : '')) for(sort keys %{$data->{source}});
+
+ diag(".. $_ => " . (defined $data->{$_} ? $data->{$_} : '')) for(grep {!/source/} keys %$data);
}
Please sign in to comment.
Something went wrong with that request. Please try again.