Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Get proper $*DISTRO info for Mac OS X
  • Loading branch information
lizmat committed May 28, 2014
1 parent 0a70378 commit 3438956
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
22 changes: 19 additions & 3 deletions src/core/Distro.pm
Expand Up @@ -7,8 +7,9 @@ class Distro does Systemic{
has Bool $.is-win;
has Str $.release;

submethod BUILD (:$name, :$version) {
$!name = $name.lc;
submethod BUILD (:$name, :$version, :$!release) {
$!name = $name.lc; # lowercase
$!name ~~ s:g/" "//; # spaceless
$!auth = "unknown";
$!version = Version.new($version);
$!is-win = so $!name eq any <mswin32 mingw msys cygwin>;
Expand Down Expand Up @@ -44,9 +45,24 @@ class Distro does Systemic{
#?if !jvm
$*VM.config<osvers>;
#?endif
my Str $release;

# darwin specific info
if $name eq 'darwin' {
if qx/sw_vers/ ~~ m/ProductName\: \s+ (<[\w\ ]>+) \s+ ProductVersion\: \s+ (<[\d\.]>+) \s+ BuildVersion\: \s+ (<[\w\d]>+)/ {
$name = ~$0;
$version = ~$1;
$release = ~$2;
}
else {
$name = 'Mac OS X'; # we assume
$version = "unknown";
$release = "unknown";
}
}

# set up $*DISTRO and deprecated $*OS and $*OSVER
PROCESS::<$DISTRO> = Distro.new( :$name, :$version );
PROCESS::<$DISTRO> = Distro.new( :$name, :$version, :$release );
PROCESS::<$OS> = Deprecation.obsolete(
:name('$*OS'),
:value($name),
Expand Down
10 changes: 5 additions & 5 deletions src/core/Kernel.pm
Expand Up @@ -13,8 +13,8 @@ class Kernel does Systemic {
method name {
$!name //= do {
given $*DISTRO.name {
when any <linux darwin> { # needs adapting
qx/uname -s/.chomp;
when any <linux macosx> { # needs adapting
qx/uname -s/.chomp.lc;
}
default {
"unknown";
Expand All @@ -26,7 +26,7 @@ class Kernel does Systemic {
method version {
$!version //= Version.new( do {
given $*DISTRO.name {
when any <linux darwin> { # needs adapting
when any <linux macosx> { # needs adapting
qx/uname -v/.chomp;
}
default {
Expand All @@ -39,7 +39,7 @@ class Kernel does Systemic {
method hardware {
$!hardware //= do {
given $*DISTRO.name {
when any <linux darwin> { # needs adapting
when any <linux macosx> { # needs adapting
qx/uname -m/.chomp;
}
default {
Expand All @@ -52,7 +52,7 @@ class Kernel does Systemic {
method arch {
$!arch //= do {
given $*DISTRO.name {
when any <linux darwin> { # needs adapting
when any <linux macosx> { # needs adapting
qx/uname -p/.chomp;
}
default {
Expand Down

0 comments on commit 3438956

Please sign in to comment.