From 74e95f8fe316e69f4a0c5cd534082a8e6f2e380e 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 | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/C4/Installer/PerlModules.pm b/C4/Installer/PerlModules.pm index 2f40cf5..723d66e 100644 --- a/C4/Installer/PerlModules.pm +++ b/C4/Installer/PerlModules.pm @@ -80,8 +80,38 @@ 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') { + eval { + use Readonly; + if ($Readonly::XSokay) { + if (-e "/usr/bin/dpkg") { + my @data = + `/usr/bin/dpkg -l libreadonly-xs-perl`; + my $line = pop @data; + # line is likely: + # ii libreadonly-xs {version} + # col0 col1 col2 + # handle the extra spaces to get col2 + $line =~ s/ / /g; + @data = split(/ /,$line); + $Readonly_XS_Version = $data[2]; + } + } + }; + 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'}}}); -- 2.1.4