|
Lines 21-27
use Modern::Perl;
Link Here
|
| 21 |
|
21 |
|
| 22 |
use Array::Utils qw( array_minus ); |
22 |
use Array::Utils qw( array_minus ); |
| 23 |
use Class::Inspector; |
23 |
use Class::Inspector; |
|
|
24 |
use CPAN::Meta; |
| 25 |
use CPAN::Meta::Check qw( verify_dependencies ); |
| 26 |
use File::Basename qw( fileparse ); |
| 27 |
use File::Copy qw( copy ); |
| 28 |
use File::Find qw( find ); |
| 29 |
use File::Path qw( make_path ); |
| 24 |
use List::MoreUtils qw( any none ); |
30 |
use List::MoreUtils qw( any none ); |
|
|
31 |
use Module::CPANfile; |
| 25 |
use Module::Load::Conditional qw( can_load ); |
32 |
use Module::Load::Conditional qw( can_load ); |
| 26 |
use Module::Load; |
33 |
use Module::Load; |
| 27 |
use Module::Pluggable search_path => ['Koha::Plugin'], |
34 |
use Module::Pluggable search_path => ['Koha::Plugin'], |
|
Lines 303-308
sub InstallPlugins {
Link Here
|
| 303 |
my ( $self, $params ) = @_; |
310 |
my ( $self, $params ) = @_; |
| 304 |
my $verbose = $params->{verbose} // $self->_verbose; |
311 |
my $verbose = $params->{verbose} // $self->_verbose; |
| 305 |
|
312 |
|
|
|
313 |
if ( $params->{from} ) { |
| 314 |
# We have "staged" plugin(s) passed in; check the dependencies, |
| 315 |
# copy to the regular location if we're happy |
| 316 |
$self->_check_dependencies($params->{from}); |
| 317 |
|
| 318 |
my $plugins_dir = C4::Context->config("pluginsdir"); |
| 319 |
$plugins_dir = ref($plugins_dir) eq 'ARRAY' ? $plugins_dir->[0] : $plugins_dir; |
| 320 |
|
| 321 |
find({ |
| 322 |
wanted => sub { |
| 323 |
return unless -f $_; |
| 324 |
my ($basename) = fileparse($_); |
| 325 |
return if $basename =~ /^cpanfile|META/; |
| 326 |
my $destdir = $File::Find::dir =~ s/^$params->{from}//r; |
| 327 |
$destdir = "$plugins_dir/$destdir"; |
| 328 |
make_path($destdir); |
| 329 |
copy($File::Find::name, $destdir); |
| 330 |
}, |
| 331 |
}, $params->{from}); |
| 332 |
} |
| 333 |
|
| 306 |
my @plugin_classes = $self->plugins(); |
334 |
my @plugin_classes = $self->plugins(); |
| 307 |
my @plugins; |
335 |
my @plugins; |
| 308 |
|
336 |
|
|
Lines 464-469
sub get_valuebuilders_installed {
Link Here
|
| 464 |
return @valuebuilders; |
492 |
return @valuebuilders; |
| 465 |
} |
493 |
} |
| 466 |
|
494 |
|
|
|
495 |
sub _check_dependencies { |
| 496 |
my ($self, $path) = @_; |
| 497 |
|
| 498 |
my $prereqs; |
| 499 |
|
| 500 |
if ( -f "$path/cpanfile" ) { |
| 501 |
my $cpanfile = Module::CPANfile->load("$path/cpanfile"); |
| 502 |
$prereqs = $cpanfile->prereqs; |
| 503 |
} else { |
| 504 |
my @metafiles = qw( META.json META.yml ); |
| 505 |
for (@metafiles) { |
| 506 |
if ( -f "$path/$_" ) { |
| 507 |
$prereqs = CPAN::Meta->load_file("$path/$_"); |
| 508 |
} |
| 509 |
} |
| 510 |
} |
| 511 |
|
| 512 |
return unless $prereqs; |
| 513 |
|
| 514 |
# 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'); |
| 516 |
} |
| 517 |
|
| 467 |
1; |
518 |
1; |
| 468 |
__END__ |
519 |
__END__ |
| 469 |
|
520 |
|