diff options
Diffstat (limited to 'SBO-Lib/lib/SBO/Lib/Util.pm')
-rw-r--r-- | SBO-Lib/lib/SBO/Lib/Util.pm | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/SBO-Lib/lib/SBO/Lib/Util.pm b/SBO-Lib/lib/SBO/Lib/Util.pm index c4128af..52f622a 100644 --- a/SBO-Lib/lib/SBO/Lib/Util.pm +++ b/SBO-Lib/lib/SBO/Lib/Util.pm @@ -4,7 +4,7 @@ use 5.016; use strict; use warnings; -our $VERSION = '2.1'; +our $VERSION = '2.5'; use Exporter 'import'; use Sort::Versions; @@ -350,7 +350,7 @@ sub print_failures { exit unless prompt "Should we continue?", default => "yes"; -C<prompt()> prompts the user for an answer, optinally specifying a default of +C<prompt()> prompts the user for an answer, optionally specifying a default of C<yes> or C<no>. If the default has been specified it returns a true value in case 'yes' was selected, and a false value if 'no' was selected. Otherwise it returns whatever the user answered. @@ -506,20 +506,32 @@ sub usage_error { C<version_cmp()> will compare C<$ver1> with C<$ver2> to try to determine which is bigger than the other, and returns 1 if C<$ver1> is bigger, -1 if C<$ver2> is bigger, and 0 if they are just as big. Before making the comparison, it will -strip off the version of your running kernel if it happens to be appended to -the version string being compared. +strip off the version of your running kernel as well as any locale information +if it happens to be appended to the version string being compared. =cut # wrapper around versioncmp for checking if versions have kernel version -# appended to them +# or locale info appended to them sub version_cmp { my ($v1, $v2) = @_; my $kv = get_kernel_version(); + # strip off kernel version if ($v1 =~ /(.+)_\Q$kv\E$/) { $v1 = $1 } if ($v2 =~ /(.+)_\Q$kv\E$/) { $v2 = $1 } + # if $v2 doesn't end in the same thing, strip off locale info from $v1 + if ($v1 =~ /(.*)_([a-z]{2})_([A-Z]{2})$/) { + my $v = $1; + if ($v2 !~ /_$2_$3$/) { $v1 = $v; } + } + # and vice versa... + if ($v2 =~ /(.*)_([a-z]{2})_([A-Z]{2})$/) { + my $v = $1; + if ($v1 !~ /_$2_$3$/) { $v2 = $v; } + } + versioncmp($v1, $v2); } @@ -537,7 +549,7 @@ Guldstrand <andreas.guldstrand@gmail.com>. The sbotools are licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING>. -Copyright (C) 2012-2016, Jacob Pipkin, Luke Williams, Andreas Guldstrand. +Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand. =cut |