From 05514f70e0a056b3fe1b488bf6bad99026cf225e Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Sun, 26 Apr 2015 21:15:29 -0400 Subject: [PATCH] Bug 13767: Fix Readonly::XS version detection The about.pl screen is unable to see that version 1.05-1+b1 is installed because eval "require Readonly::XS" returns an error message telling you that you can't use Readonly::XS directly. Since it is the only one, we attempt to use /usr/bin/dpkg to determine the version number. TEST PLAN --------- 1) $ dpkg -l libreadonly-xs-perl -- note the version number 2) Log in to staff client 3) About Koha -> Perl modules -- note it says Readonly::XS is not installed. -- note the versions and colours of the other modules. 4) Apply patch 5) Reload page and go to Perl modules tab -- Readonly::XS should list the version noted in step 1. -- the other modules' output should be unchanged. 6) Run koha qa test tools For non-debian systems lacking a /usr/bin/dpkg, the output would be identical since the version number variable is left undefined, which is true for the criteria used for the missing logic. --- C4/Installer/PerlModules.pm | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/C4/Installer/PerlModules.pm b/C4/Installer/PerlModules.pm index 2f40cf5..c40adc0 100644 --- a/C4/Installer/PerlModules.pm +++ b/C4/Installer/PerlModules.pm @@ -4,6 +4,7 @@ use warnings; use strict; use File::Spec; +use Data::Dumper; use C4::Installer::PerlDependencies; @@ -80,8 +81,40 @@ sub version_info { } } else { - for (sort keys(%{$PERL_DEPS})) { + my $Readonly_XS_Version; + PERLDEP: for (sort keys(%{$PERL_DEPS})) { my $pkg = $_; # $_ holds the string + if ($pkg eq 'Readonly::XS') { + my @data; + eval { + @data = + `/usr/bin/dpkg -l libreadonly-xs-perl`; + }; + if (@data) { + my $line = pop @data; + if ($line =~ /libreadonly/) { + # line is likely: + # ii libreadonly-xs {version} + # col0 col1 col2 + # handle the extra spaces to get col2 + $line =~ s/\s\s*/ /g; + @data = split(/ /,$line); + $line = $data[2]; + @data = split(/-/,$line); + $Readonly_XS_Version = $data[0]; + } + } + if (!$Readonly_XS_Version) { + push (@{$self->{'missing_pm'}}, {$_ => {cur_ver => 0, min_ver => $PERL_DEPS->{$_}->{'min_ver'}, required => $PERL_DEPS->{$_}->{'required'}, usage => $PERL_DEPS->{$_}->{'usage'}}}); + } + elsif ($Readonly_XS_Version lt $PERL_DEPS->{$_}->{'min_ver'}) { + push (@{$self->{'upgrade_pm'}}, {$_ => {cur_ver => $Readonly_XS_Version, min_ver => $PERL_DEPS->{$_}->{'min_ver'}, required => $PERL_DEPS->{$_}->{'required'}, usage => $PERL_DEPS->{$_}->{'usage'}}}); + } + else { + push (@{$self->{'current_pm'}}, {$_ => {cur_ver => $Readonly_XS_Version, min_ver => $PERL_DEPS->{$_}->{'min_ver'}, required => $PERL_DEPS->{$_}->{'required'}, usage => $PERL_DEPS->{$_}->{'usage'}}}); + } + next PERLDEP; + } eval "require $pkg"; if ($@) { push (@{$self->{'missing_pm'}}, {$_ => {cur_ver => 0, min_ver => $PERL_DEPS->{$_}->{'min_ver'}, required => $PERL_DEPS->{$_}->{'required'}, usage => $PERL_DEPS->{$_}->{'usage'}}}); -- 1.7.10.4