From b732963e2f91a54894f12cd5fd964c21e1c6f533 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 12 Jan 2017 11:15:22 +1100 Subject: [PATCH] Bug 17880 - Use version.pm to parse version numbers in C4::Installer::PerlModules Signed-off-by: Mark Tompsett Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- C4/Installer/PerlModules.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/C4/Installer/PerlModules.pm b/C4/Installer/PerlModules.pm index fac0fec2bd..9d8d1c8825 100644 --- a/C4/Installer/PerlModules.pm +++ b/C4/Installer/PerlModules.pm @@ -68,10 +68,12 @@ sub version_info { if ($params{'module'}) { return -1 unless grep {m/$params{'module'}/} keys(%$PERL_DEPS); eval "require $params{'module'}"; + my $pkg_version = $params{'module'} && $params{'module'}->can("VERSION") ? $params{'module'}->VERSION : 0; + my $min_version = $PERL_DEPS->{$params{'module'}}->{'min_ver'} // 0; if ($@) { return {$params{'module'} => {cur_ver => 0, min_ver => $PERL_DEPS->{$_}->{'min_ver'}, upgrade => 0, required => $PERL_DEPS->{$_}->{'required'}, usage => $PERL_DEPS->{$_}->{'usage'}}}; } - elsif ($params{'module'}->VERSION lt $PERL_DEPS->{$params{'module'}}->{'min_ver'}) { + elsif (version->parse("$pkg_version") < version->parse("$min_version")) { return {$params{'module'} => {cur_ver => $params{'module'}->VERSION, min_ver => $PERL_DEPS->{$params{'module'}}->{'min_ver'}, upgrade => 1, required => $PERL_DEPS->{$params{'module'}}->{'required'}, usage => $PERL_DEPS->{$_}->{'usage'}}}; } else { @@ -82,10 +84,12 @@ sub version_info { for (sort keys(%{$PERL_DEPS})) { my $pkg = $_; # $_ holds the string eval "require $pkg"; + my $pkg_version = $params{'module'} && $params{'module'}->can("VERSION") ? $params{'module'}->VERSION : 0; + my $min_version = $PERL_DEPS->{$_}->{'min_ver'} // 0; if ($@) { push (@{$self->{'missing_pm'}}, {$_ => {cur_ver => 0, min_ver => $PERL_DEPS->{$_}->{'min_ver'}, required => $PERL_DEPS->{$_}->{'required'}, usage => $PERL_DEPS->{$_}->{'usage'}}}); } - elsif ($pkg->VERSION lt $PERL_DEPS->{$_}->{'min_ver'}) { + elsif (version->parse("$pkg_version") < version->parse("$min_version")) { push (@{$self->{'upgrade_pm'}}, {$_ => {cur_ver => $pkg->VERSION, min_ver => $PERL_DEPS->{$_}->{'min_ver'}, required => $PERL_DEPS->{$_}->{'required'}, usage => $PERL_DEPS->{$_}->{'usage'}}}); } else { -- 2.39.5