View | Details | Raw Unified | Return to bug 41651
Collapse All | Expand All

(-)a/Koha/Plugins.pm (-21 / +28 lines)
Lines 23-33 use Array::Utils qw( array_minus ); Link Here
23
use Class::Inspector;
23
use Class::Inspector;
24
use CPAN::Meta;
24
use CPAN::Meta;
25
use CPAN::Meta::Check qw( verify_dependencies );
25
use CPAN::Meta::Check qw( verify_dependencies );
26
use File::Basename qw( fileparse );
26
use File::Basename    qw( fileparse );
27
use File::Copy qw( copy );
27
use File::Copy        qw( copy );
28
use File::Find qw( find );
28
use File::Find        qw( find );
29
use File::Path qw( make_path );
29
use File::Path        qw( make_path );
30
use List::MoreUtils           qw( any none );
30
use List::MoreUtils   qw( any none );
31
use Module::CPANfile;
31
use Module::CPANfile;
32
use Module::Load::Conditional qw( can_load );
32
use Module::Load::Conditional qw( can_load );
33
use Module::Load;
33
use Module::Load;
Lines 242-249 sub GetPlugins { Link Here
242
                    {
242
                    {
243
                        enable_plugins => $self->{'enable_plugins'}
243
                        enable_plugins => $self->{'enable_plugins'}
244
244
245
                            # loads even if plugins are disabled
245
                        # loads even if plugins are disabled
246
                            # FIXME: is this for testing without bothering to mock config?
246
                        # FIXME: is this for testing without bothering to mock config?
247
                    }
247
                    }
248
                );
248
                );
249
            } catch {
249
            } catch {
Lines 311-334 sub InstallPlugins { Link Here
311
    my $verbose = $params->{verbose} // $self->_verbose;
311
    my $verbose = $params->{verbose} // $self->_verbose;
312
312
313
    if ( $params->{from} ) {
313
    if ( $params->{from} ) {
314
314
        # We have "staged" plugin(s) passed in; check the dependencies,
315
        # We have "staged" plugin(s) passed in; check the dependencies,
315
        # copy to the regular location if we're happy
316
        # copy to the regular location if we're happy
316
        $self->_check_dependencies($params->{from});
317
        $self->_check_dependencies( $params->{from} );
317
318
318
        my $plugins_dir = C4::Context->config("pluginsdir");
319
        my $plugins_dir = C4::Context->config("pluginsdir");
319
        $plugins_dir = ref($plugins_dir) eq 'ARRAY' ? $plugins_dir->[0] : $plugins_dir;
320
        $plugins_dir = ref($plugins_dir) eq 'ARRAY' ? $plugins_dir->[0] : $plugins_dir;
320
321
321
        find({
322
        my @copy_errors;
322
            wanted => sub {
323
        find(
323
                return unless -f $_;
324
            {
324
                my ($basename) = fileparse($_);
325
                wanted => sub {
325
                return if $basename =~ /^cpanfile|META/;
326
                    return unless -f $_;
326
                my $destdir = $File::Find::dir =~ s/^$params->{from}//r;
327
                    my ($basename) = fileparse($_);
327
                $destdir = "$plugins_dir/$destdir";
328
                    return if $basename =~ /^(cpanfile|META\.(json|yml))$/;
328
                make_path($destdir);
329
                    my $destdir = $File::Find::dir =~ s/^\Q$params->{from}\E//r;
329
                copy($File::Find::name, $destdir);
330
                    $destdir = "$plugins_dir/$destdir";
331
                    make_path($destdir);
332
                    unless ( copy( $File::Find::name, $destdir ) ) {
333
                        push @copy_errors, "Failed to copy $File::Find::name to $destdir: $!";
334
                    }
335
                },
330
            },
336
            },
331
        }, $params->{from});
337
            $params->{from}
338
        );
339
        die join( "\n", @copy_errors ) . "\n" if @copy_errors;
332
    }
340
    }
333
341
334
    my @plugin_classes = $self->plugins();
342
    my @plugin_classes = $self->plugins();
Lines 493-499 sub get_valuebuilders_installed { Link Here
493
}
501
}
494
502
495
sub _check_dependencies {
503
sub _check_dependencies {
496
    my ($self, $path) = @_;
504
    my ( $self, $path ) = @_;
497
505
498
    my $prereqs;
506
    my $prereqs;
499
507
Lines 512-518 sub _check_dependencies { Link Here
512
    return unless $prereqs;
520
    return unless $prereqs;
513
521
514
    # Good for both file variants: per the docs, "$meta should be a CPAN::Meta::Prereqs or CPAN::Meta object"
522
    # Good for both file variants: per the docs, "$meta should be a CPAN::Meta::Prereqs or CPAN::Meta object"
515
    die "$_\n" for verify_dependencies($prereqs, 'runtime', 'requires');
523
    die "$_\n" for verify_dependencies( $prereqs, 'runtime', 'requires' );
516
}
524
}
517
525
518
1;
526
1;
519
- 

Return to bug 41651