From 98dd5ad4150c0608a7da9748dc76c08a021f23b9 Mon Sep 17 00:00:00 2001 From: Andreas Guldstrand Date: Tue, 14 Jun 2016 00:15:54 +0200 Subject: SBO::Lib: strip off kernel from version strings This fixes #43. --- SBO-Lib/lib/SBO/Lib.pm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'SBO-Lib/lib/SBO/Lib.pm') 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 }; } } -- cgit v1.2.3