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

(-)a/C4/Installer.pm (-1 lines)
Lines 22-28 use Modern::Perl; Link Here
22
use Encode qw( encode is_utf8 );
22
use Encode qw( encode is_utf8 );
23
use DBIx::RunSQL;
23
use DBIx::RunSQL;
24
use C4::Context;
24
use C4::Context;
25
use C4::Installer::PerlModules;
26
use DBI;
25
use DBI;
27
use Koha;
26
use Koha;
28
27
(-)a/C4/Installer/PerlModules.pm (-124 / +57 lines)
Lines 4-14 use warnings; Link Here
4
use strict;
4
use strict;
5
5
6
use File::Spec;
6
use File::Spec;
7
7
use File::Basename;
8
use C4::Installer::PerlDependencies;
8
use Module::CPANfile;
9
10
11
our $PERL_DEPS = $C4::Installer::PerlDependencies::PERL_DEPS;
12
9
13
sub new {
10
sub new {
14
    my $invocant = shift;
11
    my $invocant = shift;
Lines 17-60 sub new { Link Here
17
        upgrade_pm  => [],
14
        upgrade_pm  => [],
18
        current_pm  => [],
15
        current_pm  => [],
19
    };
16
    };
17
20
    my $type = ref($invocant) || $invocant;
18
    my $type = ref($invocant) || $invocant;
21
    bless ($self, $type);
19
    bless ($self, $type);
22
    return $self;
20
    return $self;
23
}
21
}
24
22
25
sub prereq_pm {
23
sub prereqs {
26
    my $self = shift;
24
    my $self = shift;
27
    my $prereq_pm = {};
25
28
    for (keys %$PERL_DEPS) {
26
    unless (defined $self->{prereqs}) {
29
        $prereq_pm->{$_} = $PERL_DEPS->{$_}->{'min_ver'};
27
        my $filename = $INC{'C4/Installer/PerlModules.pm'};
28
        my $path = dirname(dirname(dirname($filename)));
29
        $self->{prereqs} = Module::CPANfile->load("$path/cpanfile")->prereqs;
30
    }
30
    }
31
    return $prereq_pm;
31
32
    return $self->{prereqs};
32
}
33
}
33
34
34
sub required {
35
sub prereq_pm {
35
    my $self = shift;
36
    my $self = shift;
36
    my %params = @_;
37
37
    if ($params{'module'}) {
38
    my $prereq_pm = {};
38
        return -1 unless grep {m/$params{'module'}/} keys(%$PERL_DEPS);
39
    my $reqs = $self->prereqs->merged_requirements;
39
        return $PERL_DEPS->{$params{'module'}}->{'required'};
40
    foreach my $module ($reqs->required_modules) {
40
    }
41
        $prereq_pm->{$module} = $reqs->requirements_for_module($module);
41
    elsif ($params{'required'}) {
42
        my $required_pm = [];
43
        for (keys %$PERL_DEPS) {
44
            push (@$required_pm, $_) if $PERL_DEPS->{$_}->{'required'} == 1;
45
        }
46
        return $required_pm;
47
    }
48
    elsif ($params{'optional'}) {
49
        my $optional_pm = [];
50
        for (keys %$PERL_DEPS) {
51
            push (@$optional_pm, $_) if $PERL_DEPS->{$_}->{'required'} == 0;
52
        }
53
        return $optional_pm;
54
    }
55
    else {
56
        return -1; # unrecognized parameter passed in
57
    }
42
    }
43
44
    return $prereq_pm;
58
}
45
}
59
46
60
sub versions_info {
47
sub versions_info {
Lines 65-122 sub versions_info { Link Here
65
    $self->{'upgrade_pm'} = [];
52
    $self->{'upgrade_pm'} = [];
66
    $self->{'current_pm'} = [];
53
    $self->{'current_pm'} = [];
67
54
68
    for my $module ( sort keys %$PERL_DEPS ) {
55
    foreach my $phase ($self->prereqs->phases) {
69
        my $module_infos = $self->version_info($module);
56
        foreach my $type ($self->prereqs->types_in($phase)) {
70
        my $status       = $module_infos->{status};
57
            my $reqs = $self->prereqs->requirements_for($phase, $type);
71
        push @{ $self->{"${status}_pm"} }, { $module => $module_infos };
58
            foreach my $module ($reqs->required_modules) {
59
                no warnings;  # perl throws warns for invalid $VERSION numbers which some modules use
60
61
                my $module_infos = {
62
                    cur_ver  => 0,
63
                    min_ver  => $reqs->requirements_for_module($module),
64
                    required => $type eq 'requires',
65
                };
66
67
                my $attr;
68
69
                $Readonly::XS::MAGIC_COOKIE="Do NOT use or require Readonly::XS unless you're me.";
70
                eval "require $module";
71
                if ($@) {
72
                    $attr = 'missing_pm';
73
                } else {
74
                    my $pkg_version = $module->can("VERSION") ? $module->VERSION : 0;
75
                    $module_infos->{cur_ver} = $pkg_version;
76
                    if ($reqs->accepts_module($module => $pkg_version)) {
77
                        $attr = 'current_pm';
78
                    } else {
79
                        $attr = 'upgrade_pm';
80
                    }
81
                }
82
83
                push @{ $self->{$attr} }, { $module => $module_infos };
84
            }
85
        }
72
    }
86
    }
73
}
87
}
74
88
75
sub version_info {
76
    no warnings
77
      ;  # perl throws warns for invalid $VERSION numbers which some modules use
78
    my ( $self, $module ) = @_;
79
    return -1 unless grep { /^$module$/ } keys(%$PERL_DEPS);
80
81
    $Readonly::XS::MAGIC_COOKIE="Do NOT use or require Readonly::XS unless you're me.";
82
    eval "require $module";
83
    my $pkg_version = $module->can("VERSION") ? $module->VERSION : 0;
84
    my $min_version = $PERL_DEPS->{$module}->{'min_ver'} // 0;
85
86
    my ( $cur_ver, $upgrade, $status );
87
    if ($@) {
88
        ( $cur_ver, $upgrade, $status ) = ( 0, 0, 'missing' );
89
    }
90
    elsif ( version->parse("$pkg_version") < version->parse("$min_version") ) {
91
        ( $cur_ver, $upgrade, $status ) = ( $module->VERSION, 1, 'upgrade' );
92
    }
93
    else {
94
        ( $cur_ver, $upgrade, $status ) = ( $module->VERSION, 0, 'current' );
95
    }
96
97
    return {
98
        cur_ver  => $cur_ver,
99
        min_ver  => $PERL_DEPS->{$module}->{min_ver},
100
        required => $PERL_DEPS->{$module}->{required},
101
        usage    => $PERL_DEPS->{$module}->{usage},
102
        upgrade  => $upgrade,
103
        status   => $status,
104
    };
105
}
106
107
108
sub get_attr {
89
sub get_attr {
109
    return $_[0]->{$_[1]};
90
    return $_[0]->{$_[1]};
110
}
91
}
111
92
112
sub module_count {
113
    return scalar(keys(%$PERL_DEPS));
114
}
115
116
sub module_list {
117
    return keys(%$PERL_DEPS);
118
}
119
120
1;
93
1;
121
__END__
94
__END__
122
95
Lines 148-186 A module for manipulating Koha Perl dependency list objects. Link Here
148
121
149
        PREREQ_PM    => $perl_modules->prereq_pm,>
122
        PREREQ_PM    => $perl_modules->prereq_pm,>
150
123
151
=head2 required()
152
153
    This method accepts a single parameter with three possible values: a module name, the keyword 'required,' the keyword 'optional.' If passed the name of a module, a boolean value is returned indicating whether the module is required (1) or not (0). If on of the two keywords is passed in, it returns an arrayref to an array who's elements are the names of the modules specified either required or optional.
154
155
    example:
156
        C<my $is_required = $perl_modules->required(module => 'CGI::Carp');>
157
158
        C<my $optional_pm_names = $perl_modules->required(optional => 1);>
159
160
=head2 version_info()
161
162
    Depending on the parameters passed when invoking, this method will give the current status of modules currently used in Koha as well as the currently installed version if the module is installed, the current minimum required version, and the upgrade status. If passed C<module => module_name>, the method evaluates only that module. If passed C<all => 1>, all modules are evaluated.
163
124
164
    example:
125
=head2 versions_info
165
        C<my $module_status = $perl_modules->version_info('foo');>
166
167
        This usage returns a hashref with a single key/value pair. The key is the module name. The value is an anonymous hash with the following keys:
168
169
        cur_ver = version number of the currently installed version (This is 0 if the module is not currently installed.)
170
        min_ver = minimum version required by Koha
171
        upgrade = upgrade status of the module relative to Koha's requirements (0 if the installed module does not need upgrading; 1 if it does)
172
        required = 0 of the module is optional; 1 if required
173
174
        {
175
           'required' => 1,
176
           'cur_ver' => '1.30_01',
177
           'upgrade' => 0,
178
           'min_ver' => '1.29'
179
        };
180
126
181
        C<$perl_modules->version_info;>
127
        C<$perl_modules->versions_info;>
182
128
183
        This usage loads the same basic data as the previous usage into three accessors: missing_pm, upgrade_pm, and current_pm. Each of these may be accessed by using the C<get_attr> method. Each accessor returns an anonymous array who's elements are anonymous hashes. They follow this format (NOTE: Upgrade status is indicated by the accessor name.):
129
        This loads info of required modules into three accessors: missing_pm,
130
        upgrade_pm, and current_pm. Each of these may be accessed by using the
131
        C<get_attr> method. Each accessor returns an anonymous array who's
132
        elements are anonymous hashes. They follow this format (NOTE: Upgrade
133
        status is indicated by the accessor name.):
184
134
185
        [
135
        [
186
                  {
136
                  {
Lines 212-234 A module for manipulating Koha Perl dependency list objects. Link Here
212
    example:
162
    example:
213
        C<my $missing_pm = $perl_modules->get_attr('missing_pm');>
163
        C<my $missing_pm = $perl_modules->get_attr('missing_pm');>
214
164
215
=head2 module_count
216
217
    Returns a scalar value representing the current number of Perl modules used by Koha.
218
219
    example:
220
        C<my $module_count = $perl_modules->module_count;>
221
222
=head2 module_list
223
224
    Returns an array who's elements are the names of the Perl modules used by Koha.
225
226
    example:
227
        C<my @module_list = $perl_modules->module_list;>
228
229
    This is useful for commandline exercises such as:
230
231
        perl -MC4::Installer::PerlModules -e 'my $deps = C4::Installer::PerlModule->new; print (join("\n",$deps->module_list));'
232
165
233
=head1 AUTHOR
166
=head1 AUTHOR
234
167
(-)a/Makefile.PL (-1 / +2 lines)
Lines 29-35 use FindBin; # we need to enforce which C4::Installer::PerlModule is used in cas Link Here
29
29
30
use lib $FindBin::Bin;
30
use lib $FindBin::Bin;
31
31
32
use C4::Installer;
32
use C4::Installer::PerlModules;
33
33
34
my $koha_pm = C4::Installer::PerlModules->new;
34
my $koha_pm = C4::Installer::PerlModules->new;
35
35
Lines 314-319 my $target_map = { Link Here
314
  './circ'                      => 'INTRANET_CGI_DIR',
314
  './circ'                      => 'INTRANET_CGI_DIR',
315
  './clubs'                     => 'INTRANET_CGI_DIR',
315
  './clubs'                     => 'INTRANET_CGI_DIR',
316
  './course_reserves'           => 'INTRANET_CGI_DIR',
316
  './course_reserves'           => 'INTRANET_CGI_DIR',
317
  './cpanfile'                  => 'PERL_MODULE_DIR',
317
  './docs/history.txt'          => { target => 'DOC_DIR', trimdir => -1 },
318
  './docs/history.txt'          => { target => 'DOC_DIR', trimdir => -1 },
318
  './docs/contributors.yaml'    => { target => 'DOC_DIR', trimdir => -1 },
319
  './docs/contributors.yaml'    => { target => 'DOC_DIR', trimdir => -1 },
319
  './docs/teams.yaml'           => { target => 'DOC_DIR', trimdir => -1 },
320
  './docs/teams.yaml'           => { target => 'DOC_DIR', trimdir => -1 },
(-)a/about.pl (-1 / +1 lines)
Lines 37-43 use YAML qw/LoadFile/; Link Here
37
use C4::Output;
37
use C4::Output;
38
use C4::Auth;
38
use C4::Auth;
39
use C4::Context;
39
use C4::Context;
40
use C4::Installer;
40
use C4::Installer::PerlModules;
41
41
42
use Koha;
42
use Koha;
43
use Koha::DateUtils qw(dt_from_string output_pref);
43
use Koha::DateUtils qw(dt_from_string output_pref);
(-)a/cpanfile (+184 lines)
Line 0 Link Here
1
requires 'Algorithm::CheckDigits', '0.5';
2
requires 'Authen::CAS::Client', '0.05';
3
requires 'Biblio::EndnoteStyle', '0.05';
4
requires 'Business::ISBN', '2.05';
5
requires 'Business::ISSN', '0.91';
6
requires 'Bytes::Random::Secure', '0.28';
7
requires 'CGI', '3.15';
8
requires 'CGI::Carp', '1.29';
9
requires 'CGI::Compile', '0.17';
10
requires 'CGI::Emulate::PSGI', '0.20';
11
requires 'CGI::Session', '4.2';
12
requires 'CGI::Session::Serialize::yaml', '4.2';
13
requires 'CPAN::Meta', '2.150006';
14
requires 'Cache::Memcached', '1.30';
15
requires 'Class::Accessor', '0.3';
16
requires 'Class::Factory::Util', '1.6';
17
requires 'Class::Inspector', '1.31';
18
requires 'Clone', '0.37';
19
requires 'Crypt::Eksblowfish::Bcrypt', '0.008';
20
requires 'DBD::Mock', '1.39';
21
requires 'DBD::mysql', '4.004';
22
requires 'DBI', '1.53';
23
requires 'DBIx::Class::Schema::Loader', '0.07039';
24
requires 'DBIx::RunSQL', '0.14';
25
requires 'Data::Dumper', '2.121';
26
requires 'Data::ICal', '0.13';
27
requires 'Date::Calc', '5.4';
28
requires 'Date::Manip', '5.44';
29
requires 'DateTime', '0.58';
30
requires 'DateTime::Event::ICal', '0.08';
31
requires 'DateTime::Format::ICal', '0.09';
32
requires 'DateTime::Format::MySQL', '0.04';
33
requires 'DateTime::Set', '0.28';
34
requires 'DateTime::TimeZone', '1.20';
35
requires 'Digest::MD5', '2.36';
36
requires 'Digest::SHA', '5.43';
37
requires 'Email::Date', '1.103';
38
requires 'Email::Valid', '0.190';
39
requires 'Exception::Class', '1.38';
40
requires 'File::Slurp', '9999.13';
41
requires 'Font::TTF', '0.45';
42
requires 'GD::Barcode::UPCE', '1.1';
43
requires 'Getopt::Long', '2.35';
44
requires 'Getopt::Std', '1.05';
45
requires 'HTML::Entities', '3.69';
46
requires 'HTML::FormatText', '1.23';
47
requires 'HTML::Scrubber', '0.08';
48
requires 'HTTP::Cookies', '1.39';
49
requires 'HTTP::OAI', '3.2';
50
requires 'HTTP::Request::Common', '1.26';
51
requires 'IPC::Cmd', '0.46';
52
requires 'JSON', '2.07';
53
requires 'JSON::Validator', '0.97';
54
requires 'LWP::Simple', '1.41';
55
requires 'LWP::UserAgent', '2.033';
56
requires 'Library::CallNumber::LC', '0.22';
57
requires 'Lingua::Stem', '0.82';
58
requires 'Lingua::Stem::Snowball', '0.952';
59
requires 'List::MoreUtils', '0.21';
60
requires 'List::Util', '1.18';
61
requires 'Locale::Currency::Format', '1.28';
62
requires 'Locale::Language', '2.07';
63
requires 'Locale::Messages', '1.20';
64
requires 'Locale::PO', '0.17';
65
requires 'Log::Log4perl', '1.29';
66
requires 'MARC::Charset', '0.98';
67
requires 'MARC::File::XML', 'v1.0.1';
68
requires 'MARC::Record', 'v2.0.6';
69
requires 'MARC::Record::MiJ', '0.04';
70
requires 'MIME::Base64', '3.07';
71
requires 'MIME::Lite', '3';
72
requires 'MIME::QuotedPrint', '3.07';
73
requires 'Mail::Sendmail', '0.79';
74
requires 'Modern::Perl', '1.03';
75
requires 'Module::CPANfile', '1.1000';
76
requires 'Mojolicious', '7.21';
77
requires 'Mojolicious::Plugin::OpenAPI', '1.15';
78
requires 'Net::CIDR', '0.17';
79
requires 'Net::Netmask', '1.9022';
80
requires 'Net::Z3950::ZOOM', '1.16';
81
requires 'Number::Format', '1.52';
82
requires 'OpenOffice::OODoc', '2.125';
83
requires 'PDF::API2', '2';
84
requires 'PDF::API2::Page', '2';
85
requires 'PDF::API2::Simple', '1';
86
requires 'PDF::API2::Util', '2';
87
requires 'PDF::Reuse', '0.36';
88
requires 'PDF::Reuse::Barcode', '0.05';
89
requires 'PDF::Table', 'v0.9.3';
90
requires 'POSIX', '1.09';
91
requires 'Plack::Middleware::ReverseProxy', '0.14';
92
requires 'Schedule::At', '1.06';
93
requires 'Search::Elasticsearch', '5.01';
94
requires 'Sereal::Decoder', '3.0';
95
requires 'Sereal::Encoder', '3.0';
96
requires 'Storable', '2.20';
97
requires 'String::Random', '0.22';
98
requires 'Template', '2.22';
99
requires 'Template::Plugin::HtmlToText', '0.03';
100
requires 'Template::Plugin::JSON::Escape', '0.02';
101
requires 'Term::ANSIColor', '1.1';
102
requires 'Test', '1.25';
103
requires 'Test::Harness', '2.56';
104
requires 'Test::MockModule', '0.05';
105
requires 'Test::More', '1.302073';
106
requires 'Text::Bidi', '0.03';
107
requires 'Text::CSV', '0.01';
108
requires 'Text::CSV::Encoded', '0.09';
109
requires 'Text::CSV_XS', '0.32';
110
requires 'Text::Iconv', '1.7';
111
requires 'Text::PDF', '0.29';
112
requires 'Text::Wrap', '2005.082401';
113
requires 'Time::HiRes', '1.86';
114
requires 'Time::localtime', '1.02';
115
requires 'Try::Tiny', '0.22';
116
requires 'UNIVERSAL::can', '1.10';
117
requires 'URI::Escape', '3.31';
118
requires 'UUID', '0.05';
119
requires 'Unicode::Normalize', '0.32';
120
requires 'WWW::CSRF', '1.00';
121
requires 'XML::Dumper', '0.81';
122
requires 'XML::LibXML', '1.59';
123
requires 'XML::LibXSLT', '1.59';
124
requires 'XML::RSS', '1.31';
125
requires 'XML::SAX::ParserFactory', '1.01';
126
requires 'XML::SAX::Writer', '0.44';
127
requires 'XML::Simple', '2.14';
128
requires 'YAML', '0.71';
129
requires 'YAML::Syck', '0.71';
130
recommends 'AnyEvent', '5.0';
131
recommends 'AnyEvent::HTTP', '2.13';
132
recommends 'Archive::Extract', '0.60';
133
recommends 'Archive::Zip', '1.30';
134
recommends 'Array::Utils', '0.5';
135
recommends 'CGI::Session::Driver::memcached', '0.04';
136
recommends 'Cache::FastMmap', '1.34';
137
recommends 'Cache::Memcached::Fast', '0.19';
138
recommends 'Cache::Memcached::Fast::Safe', '0.06';
139
recommends 'DBD::SQLite2', '0.33';
140
recommends 'Devel::Cover', '0.89';
141
recommends 'File::Copy', '2.08';
142
recommends 'File::Path', '2.07';
143
recommends 'File::Temp', '0.22';
144
recommends 'GD', '2.39';
145
recommends 'Graphics::Magick', 'v1.3.5';
146
recommends 'Gravatar::URL', '1.03';
147
recommends 'HTTPD::Bench::ApacheBench', '0.73';
148
recommends 'LWP::Protocol::https', '5.836';
149
recommends 'Lingua::Ispell', '0.07';
150
recommends 'Module::Bundled::Files', '0.03';
151
recommends 'Module::Load::Conditional', '0.38';
152
recommends 'Module::Pluggable', '3.9';
153
recommends 'Moo', '1';
154
recommends 'Net::LDAP', '0.33';
155
recommends 'Net::LDAP::Filter', '0.14';
156
recommends 'Net::OAuth2::AuthorizationServer', '0.16';
157
recommends 'Net::SFTP::Foreign', '1.73';
158
recommends 'Net::Server', '0.97';
159
recommends 'Net::Z3950::SimpleServer', '1.15';
160
recommends 'PDF::FromHTML', '0.31';
161
recommends 'PPI', '1.215';
162
recommends 'Parallel::ForkManager', '0.75';
163
recommends 'Readonly', '0.01';
164
recommends 'Readonly::XS', '0.01';
165
recommends 'SMS::Send', '0.05';
166
recommends 'Selenium::Remote::Driver', '1.27';
167
recommends 'Sys::CPU', '0.52';
168
recommends 'Template::Plugin::Stash', '1.006';
169
recommends 'Test::DBIx::Class', '0.42';
170
recommends 'Test::Deep', '0.106';
171
recommends 'Test::Exception', '0.35';
172
recommends 'Test::MockObject', '1.09';
173
recommends 'Test::MockTime', '0.13';
174
recommends 'Test::Strict', '0.14';
175
recommends 'Test::WWW::Mechanize', '1.42';
176
recommends 'Test::Warn', '0.21';
177
recommends 'Test::YAML::Valid', '0.04';
178
recommends 'Text::CSV::Unicode', '0.40';
179
recommends 'Text::Unidecode', '0.04';
180
recommends 'Time::Fake', '0.11';
181
recommends 'UNIVERSAL::require', '0.13';
182
recommends 'WWW::YouTube::Download', '0.56';
183
recommends 'WebService::ILS', '0.17';
184
recommends 'XML::Writer', '0.614';
(-)a/debian/list-deps (-54 / +58 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
#
2
#
3
# Write dependency list from Koha PerlDependencies.pm, in Debian format.
3
# Write dependency list from Koha cpanfile, in Debian format.
4
#
4
#
5
# Copyright 2010  Catalyst IT, Ltd
5
# Copyright 2010  Catalyst IT, Ltd
6
#
6
#
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use C4::Installer::PerlDependencies;
22
use C4::Installer::PerlModules;
23
23
24
# These are packages that may not be in the apt archive in a way that
24
# These are packages that may not be in the apt archive in a way that
25
# apt-file can find, e.g. in the Koha repo rather than the regular
25
# apt-file can find, e.g. in the Koha repo rather than the regular
Lines 39-99 my %ignore = ( Link Here
39
    'CHI::Driver::Memcached' => 1,
39
    'CHI::Driver::Memcached' => 1,
40
);
40
);
41
41
42
my $deps = $C4::Installer::PerlDependencies::PERL_DEPS;
43
44
my $prefix = "^/usr/((lib|share)/perl5|(lib|share)/perl/[0-9.]+|(lib|share)/.*-linux-gnu.*/perl/[0-9.]+|(lib|share)/.*-linux-gnu.*/perl5/[0-9.]+)";
42
my $prefix = "^/usr/((lib|share)/perl5|(lib|share)/perl/[0-9.]+|(lib|share)/.*-linux-gnu.*/perl/[0-9.]+|(lib|share)/.*-linux-gnu.*/perl5/[0-9.]+)";
45
43
46
foreach my $module ( keys %$deps ) {
44
my $modules = C4::Installer::PerlModules->new();
47
    next if $ignore{$module};
45
my $prereqs = $modules->prereqs;
48
    my $ver     = $deps->{$module}->{'min_ver'};
46
foreach my $phase ($prereqs->phases) {
49
    my $subpath = $module;
47
    foreach my $type ($prereqs->types_in($phase)) {
50
    $subpath =~ s,::,/,g;
48
        my $reqs = $prereqs->requirements_for($phase, $type);
51
    my $output = qx(apt-file -l -x search "$prefix/$subpath.pm\$");
49
        foreach my $module ( $reqs->required_modules ) {
52
    my @temp   = split( /\n/, $output );
50
            next if $ignore{$module};
53
    my @lines  = ();
51
            my $subpath = $module;
52
            $subpath =~ s,::,/,g;
53
            my $output = qx(apt-file -l -x search "$prefix/$subpath.pm\$");
54
            my @temp   = split( /\n/, $output );
55
            my @lines  = ();
54
56
55
    # Remove packages that are required/essential and always installed on
57
            # Remove packages that are required/essential and always installed on
56
    # a Debian system. Debian packages should not have unversioned
58
            # a Debian system. Debian packages should not have unversioned
57
    # dependencies on such packages.
59
            # dependencies on such packages.
58
    foreach my $line (@temp) {
60
            foreach my $line (@temp) {
59
        if ( $line ne "perl-base" ) {
61
                if ( $line ne "perl-base" ) {
60
            @lines = ( @lines, $line );
62
                    @lines = ( @lines, $line );
61
        }
63
                }
62
    }
64
            }
63
    if ( exists $overrides{$module} ) {
65
            if ( exists $overrides{$module} ) {
64
        print "$overrides{$module}\n";
66
                print "$overrides{$module}\n";
65
    }
67
            }
66
    elsif ( scalar(@lines) == 1 && $lines[0] ne "" ) {
68
            elsif ( scalar(@lines) == 1 && $lines[0] ne "" ) {
67
        my $pkg = $lines[0];
69
                my $pkg = $lines[0];
68
        print "$pkg\n";
70
                print "$pkg\n";
69
    }
71
            }
70
    elsif ( scalar(@lines) > 1 ) {
72
            elsif ( scalar(@lines) > 1 ) {
71
        foreach my $pkg (@lines) {
73
                foreach my $pkg (@lines) {
72
            print " | " if ( $pkg ne $lines[0] );
74
                    print " | " if ( $pkg ne $lines[0] );
73
            print "$pkg";
75
                    print "$pkg";
74
            print " | $pkg" . "-5.22" if ( $pkg eq "perl-modules" );
76
                    print " | $pkg" . "-5.22" if ( $pkg eq "perl-modules" );
75
            print " | $pkg" . "-5.24" if ( $pkg eq "perl-modules" );
77
                    print " | $pkg" . "-5.24" if ( $pkg eq "perl-modules" );
76
        }
78
                }
77
        print "\n";
79
                print "\n";
78
    }
80
            }
79
    elsif ( scalar(@temp) != 0 ) {
81
            elsif ( scalar(@temp) != 0 ) {
80
82
81
        # I'm an Essential and I'm OK,
83
                # I'm an Essential and I'm OK,
82
        # I install all night, and work all day.
84
                # I install all night, and work all day.
83
        # I chomp up strings. I eat my bugs.
85
                # I chomp up strings. I eat my bugs.
84
        # I go to the base install.
86
                # I go to the base install.
85
        # On Fridays I go drinking,
87
                # On Fridays I go drinking,
86
        # and have buttered commits for git.
88
                # and have buttered commits for git.
87
        # (Beer O'Clock is more than two hours
89
                # (Beer O'Clock is more than two hours
88
        # away. I don't even drink beer. There
90
                # away. I don't even drink beer. There
89
        # is no reason to be suspicious of this
91
                # is no reason to be suspicious of this
90
        # commit.)
92
                # commit.)
91
        # RM note: suspicious?  me?  always!
93
                # RM note: suspicious?  me?  always!
92
    }
94
            }
93
    elsif ( ! $deps->{$module}->{'required'} ) {
95
            elsif ( $type ne 'requires' ) {
94
        # Ignore because we don't have it and we don't care.
96
                # Ignore because we don't have it and we don't care.
95
    }
97
            }
96
    else {
98
            else {
97
        print "EEEK: unknown package for $module\n";
99
                print "EEEK: unknown package for $module\n";
100
            }
101
        }
98
    }
102
    }
99
}
103
}
(-)a/installer/install.pl (+1 lines)
Lines 29-34 use C4::Output; Link Here
29
use C4::Templates;
29
use C4::Templates;
30
use C4::Languages qw(getAllLanguages getTranslatedLanguages);
30
use C4::Languages qw(getAllLanguages getTranslatedLanguages);
31
use C4::Installer;
31
use C4::Installer;
32
use C4::Installer::PerlModules;
32
33
33
use Koha;
34
use Koha;
34
35
(-)a/t/Installer_PerlDependencies.t (-14 lines)
Lines 1-14 Link Here
1
#!/usr/bin/perl
2
#
3
# This Koha test module is a stub!  
4
# Add more tests here!!!
5
6
use strict;
7
use warnings;
8
9
use Test::More tests => 1;
10
11
BEGIN {
12
        use_ok('C4::Installer::PerlDependencies');
13
}
14
(-)a/t/Installer_PerlModules.t (-41 / +1 lines)
Lines 5-62 Link Here
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
7
8
use Test::More tests => 22;
8
use Test::More tests => 6;
9
9
10
BEGIN {
10
BEGIN {
11
        use_ok('C4::Installer::PerlModules');
11
        use_ok('C4::Installer::PerlModules');
12
}
12
}
13
13
14
$C4::Installer::PerlModules::PERL_DEPS->{'Local::Module::Upgraded'} = {
15
    'required' => '1',
16
    'min_ver' => '0.9.3',
17
    'usage' => "Testing: make sure numbers are compared numerically and not lexicographically",
18
};
19
$Local::Module::Upgraded::VERSION = '0.9.13';
20
$INC{"Local/Module/Upgraded.pm"} = 1;
21
use_ok("Local::Module::Upgraded");
22
23
$C4::Installer::PerlModules::PERL_DEPS->{'Local::Module::NotUpgraded'} = {
24
    'required' => '1',
25
    'min_ver' => '0.9.3',
26
    'usage' => "Testing: make sure numbers are compared numerically and not lexicographically",
27
};
28
$Local::Module::NotUpgraded::VERSION = '0.9.1';
29
$INC{"Local/Module/NotUpgraded.pm"} = 1;
30
use_ok("Local::Module::NotUpgraded");
31
32
my $modules;
14
my $modules;
33
ok ($modules = C4::Installer::PerlModules->new(), 'Tests modules object');
15
ok ($modules = C4::Installer::PerlModules->new(), 'Tests modules object');
34
my $prereq_pm = $modules->prereq_pm();
16
my $prereq_pm = $modules->prereq_pm();
35
ok (exists($prereq_pm->{"DBI"}), 'DBI required for installer to run');
17
ok (exists($prereq_pm->{"DBI"}), 'DBI required for installer to run');
36
ok (exists($prereq_pm->{"CGI"}), 'CGI required for installer to run' );
18
ok (exists($prereq_pm->{"CGI"}), 'CGI required for installer to run' );
37
ok (exists($prereq_pm->{"YAML"}), 'YAML required for installer to run');
19
ok (exists($prereq_pm->{"YAML"}), 'YAML required for installer to run');
38
is ($modules->required('module'=>"DBI"),1, 'DBI should return 1 since required');
39
is ($modules->required('module'=>"thisdoesn'texist"),-1, 'string should return -1 since not in hash');
40
my $required = $modules->required('required'=>1);
41
my %params = map { $_ => 1 } @$required;
42
ok (exists($params{"DBI"}), 'DBI required for installer to run');
43
my $optional = $modules->required('optional'=>1);
44
%params = map { $_ => 1 } @$optional;
45
ok (exists($params{"Test::Strict"}), 'test::strict optional for installer to run');
46
is ($optional = $modules->required('spaghetti'=>1),-1, '-1 returned when parsing in unknown parameter');
47
my $version_info = $modules->version_info('DBI');
48
ok (exists($version_info->{"required"}), 'required exists');
49
ok (exists($version_info->{"upgrade"}), 'upgrade exists');
50
is ($modules->version_info("thisdoesn'texist"),-1, 'thisdoesntexist should return -1');
51
ok ($modules->module_count() >10 , 'count should be greater than 10');
52
my @module_list = $modules->module_list;
53
%params = map { $_ => 1 } @module_list;
54
ok (exists($params{"DBI"}), 'DBI exists in array');
55
is ($modules->required('module'=>"String::Random"),1, 'String::Random should return 1 since required');
56
is ($modules->version_info(), -1, "Testing empty modules");
57
58
is($modules->version_info("Local::Module::Upgraded")->{"upgrade"},0,"Version 0.9.13 is greater than 0.9.3, so no upgrade needed");
59
is($modules->version_info("Local::Module::NotUpgraded")->{"upgrade"},1,"Version 0.9.1 is smaller than 0.9.1, so no upgrade needed");
60
20
61
subtest 'versions_info' => sub {
21
subtest 'versions_info' => sub {
62
    plan tests => 4;
22
    plan tests => 4;
(-)a/t/Installer_pm.t (-12 / +1 lines)
Lines 3-9 Link Here
3
use strict;
3
use strict;
4
use warnings;
4
use warnings;
5
5
6
use Test::More tests => 4;
6
use Test::More tests => 2;
7
use Data::Dumper;
7
use Data::Dumper;
8
8
9
BEGIN {
9
BEGIN {
Lines 13-25 BEGIN { Link Here
13
my $obj = C4::Installer::PerlModules->new;
13
my $obj = C4::Installer::PerlModules->new;
14
14
15
isa_ok($obj,'C4::Installer::PerlModules');
15
isa_ok($obj,'C4::Installer::PerlModules');
16
17
my $module_info = $obj->version_info('Test::More');
18
19
my $control = $Test::More::VERSION;
20
21
like($module_info->{cur_ver}, qr/\d/, 'returns numeric version');
22
23
is($module_info->{cur_ver}, $control, 'returns correct version');
24
25
26
- 

Return to bug 19735