Bug 19735: Add support for max_ver
This patchset adds support for extracting 'max_ver' from the cpanfile so we can use version ranges properly and report errors if we have modules installed that do not fit within that version range. Test plan: 1) Manually modify the module version of a required module in the cpanfile to have a max version greater than the version you have installed. 2) Run through the install proceedure and note the new warning that a module needs upgrade for the module in question. 3) The module should also be reported in the about page Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
faa89f406d
commit
cc595325d6
|
|
@ -60,10 +60,20 @@ sub versions_info {
|
|||
|
||||
my $module_infos = {
|
||||
cur_ver => 0,
|
||||
min_ver => $reqs->requirements_for_module($module),
|
||||
required => $type eq 'requires',
|
||||
};
|
||||
|
||||
my $vers = $reqs->structured_requirements_for_module($module);
|
||||
for my $req (@$vers) {
|
||||
if ( $req->[0] eq '>=' || $req->[0] eq '>' ) {
|
||||
$module_infos->{min_ver} = $req->[1];
|
||||
} elsif ( $req->[0] eq '<=' || $req->[0] eq '<' ) {
|
||||
$module_infos->{max_ver} = $req->[1];
|
||||
} else {
|
||||
push @{$module_infos->{exc_ver}}, $req->[1];
|
||||
}
|
||||
}
|
||||
|
||||
my $attr;
|
||||
|
||||
$Readonly::XS::MAGIC_COOKIE="Do NOT use or require Readonly::XS unless you're me.";
|
||||
|
|
|
|||
1
about.pl
1
about.pl
|
|
@ -558,6 +558,7 @@ foreach my $pm_type(@pm_types) {
|
|||
current => ($pm_type eq 'current_pm' ? 1 : 0),
|
||||
require => $stats->{'required'},
|
||||
reqversion => $stats->{'min_ver'},
|
||||
maxversion => $stats->{'max_ver'}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,24 +101,42 @@ if ( $step && $step == 1 ) {
|
|||
my $perl_modules = C4::Installer::PerlModules->new;
|
||||
$perl_modules->versions_info;
|
||||
|
||||
my $modules = $perl_modules->get_attr('missing_pm');
|
||||
if ( scalar(@$modules) ) {
|
||||
my @components = ();
|
||||
foreach (@$modules) {
|
||||
my $missing_modules = $perl_modules->get_attr('missing_pm');
|
||||
my $upgrade_modules = $perl_modules->get_attr('upgrade_pm');
|
||||
if ( scalar(@$missing_modules) || scalar(@$upgrade_modules) ) {
|
||||
my @missing = ();
|
||||
my @upgrade = ();
|
||||
foreach (@$missing_modules) {
|
||||
my ( $module, $stats ) = each %$_;
|
||||
$checkmodule = 0 if $stats->{'required'};
|
||||
push(
|
||||
@components,
|
||||
@missing,
|
||||
{
|
||||
name => $module,
|
||||
version => $stats->{'min_ver'},
|
||||
min_version => $stats->{'min_ver'},
|
||||
max_version => $stats->{'max_ver'},
|
||||
require => $stats->{'required'}
|
||||
}
|
||||
);
|
||||
}
|
||||
@components = sort { $a->{'name'} cmp $b->{'name'} } @components;
|
||||
foreach (@$upgrade_modules) {
|
||||
my ( $module, $stats ) = each %$_;
|
||||
$checkmodule = 0 if $stats->{'required'};
|
||||
push(
|
||||
@upgrade,
|
||||
{
|
||||
name => $module,
|
||||
min_version => $stats->{'min_ver'},
|
||||
max_version => $stats->{'max_ver'},
|
||||
require => $stats->{'required'}
|
||||
}
|
||||
);
|
||||
}
|
||||
@missing = sort { $a->{'name'} cmp $b->{'name'} } @missing;
|
||||
@upgrade = sort { $a->{'name'} cmp $b->{'name'} } @upgrade;
|
||||
$template->param(
|
||||
missing_modules => \@components,
|
||||
missing_modules => \@missing,
|
||||
upgrade_modules => \@upgrade,
|
||||
checkmodule => $checkmodule,
|
||||
op => $op
|
||||
);
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@
|
|||
[% END %]
|
||||
[% END %]
|
||||
[% IF ( ro.name ) %]
|
||||
[% ro.name | html %] <span style="font-weight:normal; font-size:smaller"> ([% ro.reqversion | html %])</span>
|
||||
[% ro.name | html %] <span style="font-weight:normal; font-size:smaller"> ([% ro.reqversion | html %][% IF ro.maxversion %] - [% ro.maxversion | html %][% END %])</span>
|
||||
[% END %]
|
||||
</th>
|
||||
[% IF ( ro.name == '' ) %]
|
||||
|
|
|
|||
|
|
@ -61,7 +61,21 @@
|
|||
<ul>
|
||||
[% FOREACH missing_module IN missing_modules %]
|
||||
<li><strong>[% missing_module.name | html %]</strong> [% IF ( missing_module.require ) %]<span class="label label-danger">Required</span>[% END %]
|
||||
<br /> Version: [% missing_module.version | html %]
|
||||
<br /> Version: [% missing_module.min_version | html %]
|
||||
</li>
|
||||
[% END %]
|
||||
</ul>
|
||||
[% END %]
|
||||
|
||||
[% IF ( upgrade_modules ) %]
|
||||
<h2>Web installer › Perl modules due for upgrade</h2>
|
||||
<p>Some Perl modules require upgrade. <span class="label label-danger">Important: </span>Required modules must be installed at the correct version before you may continue.<br />
|
||||
<ul>
|
||||
[% FOREACH upgrade_module IN upgrade_modules %]
|
||||
<li><strong>[% upgrade_module.name | html %]</strong> [% IF ( upgrade_module.require ) %]<span class="label label-danger">Required</span>[% END %]
|
||||
<br /> Installed version: [% upgrade_module.version | html %]
|
||||
<br /> Minimum version: [% upgrade_module.min_version | html %]
|
||||
<br /> Maximum version: [% upgrade_module.max_version | html %]
|
||||
</li>
|
||||
[% END %]
|
||||
</ul>
|
||||
|
|
|
|||
Loading…
Reference in New Issue