diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-06-14 00:15:54 +0200 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-06-14 00:15:54 +0200 |
commit | 98dd5ad4150c0608a7da9748dc76c08a021f23b9 (patch) | |
tree | ed1d5a454a6df3967a010f3c52b46f481713874c /SBO-Lib | |
parent | 0a9ab6575506cd8bf529f832db3af28d6cd8885d (diff) | |
download | sbotools2-98dd5ad4150c0608a7da9748dc76c08a021f23b9.tar.xz |
SBO::Lib: strip off kernel from version strings
This fixes #43.
Diffstat (limited to 'SBO-Lib')
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 79e4acd..1041aa8 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -562,7 +562,7 @@ sub get_local_outdated_versions { foreach my $sbo (@local) { my $orig = get_orig_version($sbo->{name}); next if not defined $orig; - next if not versioncmp($orig, $sbo->{version}); + next if not version_cmp($orig, $sbo->{version}); push @outdated, { %$sbo, orig => $orig }; } @@ -572,6 +572,19 @@ sub get_local_outdated_versions { } } +# wrapper around versioncmp for checking if versions have kernel version +# appended to them +sub version_cmp { + my ($v1, $v2) = @_; + my $kv = `uname -r`; + chomp $kv; + + if ($v1 =~ /(.+)_\Q$kv\E$/) { $v1 = $1 } + if ($v2 =~ /(.+)_\Q$kv\E$/) { $v2 = $1 } + + versioncmp($v1, $v2); +} + # pull the sbo name from a $location: $repo_path/system/wine, etc. sub get_sbo_from_loc { script_error('get_sbo_from_loc requires an argument.') unless @_ == 1; @@ -635,7 +648,7 @@ sub get_available_updates { next unless $location; my $version = get_sbo_version($location); - if (versioncmp($version, $pkg->{version}) != 0) { + if (version_cmp($version, $pkg->{version}) != 0) { push @updates, { name => $pkg->{name}, installed => $pkg->{version}, update => $version }; } } |