=item SCRIPT_DIR
-Directory for command-line scripts and daemons.
+Directory for command-line scripts and daemons to
+be set up all for installation modes.
+
+=item SCRIPT_NONDEV_DIR
+
+Directory for command-line scripts that should
+be installed in the same directory as the
+SCRIPT_DIR target except 'dev' installs.
=item MAN_DIR
'./Makefile.PL' => 'NONE',
'./MANIFEST.SKIP' => 'NONE',
'./members' => 'INTRANET_CGI_DIR',
- './misc' => { target => 'SCRIPT_DIR', trimdir => -1 },
+ './misc' => { target => 'SCRIPT_NONDEV_DIR', trimdir => -1 },
'./misc/bin' => { target => 'SCRIPT_DIR', trimdir => -1 },
'./misc/release_notes' => { target => 'DOC_DIR', trimdir => 2 },
'./misc/translator' => { target => 'MISC_DIR', trimdir => 2 },
'MERGE_SERVER_PORT' => '11001',
'PAZPAR2_HOST' => 'localhost',
'PAZPAR2_PORT' => '11002',
+ 'RUN_DATABASE_TESTS' => 'no',
+ 'PATH_TO_ZEBRA' => '',
);
# set some default configuratio options based on OS
'AUTH_INDEX_MODE' => { 'grs1' => 1, 'dom' => 1 },
'ZEBRA_MARC_FORMAT' => { 'marc21' => 1, 'unimarc' => 1 }, # FIXME should generate from contents of distributation
'ZEBRA_LANGUAGE' => { 'en' => 1, 'fr' => 1 }, # FIXME should generate from contents of distribution
+ 'RUN_DATABASE_TESTS' => { 'yes' => 1, 'no' => 1 },
);
# get settings from command-line
'blib/ZEBRA_CONF_DIR/retrieval-info-auth-grs1.xml',
'blib/ZEBRA_CONF_DIR/retrieval-info-auth-dom.xml',
);
- if ($config{'INSTALL_MODE'} ne 'dev') {
- push @{ $pl_files->{'rewrite-config.PL'} }, (
- 'blib/SCRIPT_DIR/koha-zebra-ctl.sh',
- 'blib/SCRIPT_DIR/koha-pazpar2-ctl.sh',
- 'blib/SCRIPT_DIR/koha-zebraqueue-ctl.sh',
- );
- }
+ push @{ $pl_files->{'rewrite-config.PL'} }, (
+ 'blib/SCRIPT_DIR/koha-zebra-ctl.sh',
+ 'blib/SCRIPT_DIR/koha-pazpar2-ctl.sh',
+ 'blib/SCRIPT_DIR/koha-zebraqueue-ctl.sh',
+ );
if ($config{'INSTALL_PAZPAR2'} eq 'yes') {
push @{ $pl_files->{'rewrite-config.PL'} }, (
'blib/PAZPAR2_CONF_DIR/koha-biblios.xml',
if ($config{'INSTALL_MODE'} ne "dev") {
push @{ $pl_files->{'rewrite-config.PL'} }, (
'blib/PERL_MODULE_DIR/C4/Context.pm',
- 'blib/SCRIPT_DIR/kohalib.pl'
+ 'blib/SCRIPT_NONDEV_DIR/kohalib.pl'
);
}
+my %test_suite_override_dirs = (
+ KOHA_CONF_DIR => ['etc'],
+ ZEBRA_CONF_DIR => ['etc', 'zebradb'],
+ LOG_DIR => ['var', 'log'],
+ SCRIPT_DIR => ['bin'],
+ ZEBRA_LOCK_DIR => ['var', 'lock', 'zebradb'],
+ ZEBRA_DATA_DIR => ['var', 'lib', 'zebradb'],
+ ZEBRA_RUN_DIR => ['var', 'run', 'zebradb'],
+);
+
WriteMakefile(
NAME => 'koha',
#VERSION => strftime('2.9.%Y%m%d%H',gmtime),
'DBD::mysql' => 4.004,
'DBI' => 1.53,
'Data::ICal' => 0.13,
-'Data::Dumper' => 2.121_08,
+'Data::Dumper' => 2.121,
'Date::Calc' => 5.4,
'Date::ICal' => 1.72,
'Date::Manip' => 5.44,
'Getopt::Long' => 2.35,
'Getopt::Std' => 1.05,
'HTML::Template::Pro' => 0.69,
+'HTML::Scrubber' => 0.08,
'HTTP::Cookies' => 1.39,
'HTTP::Request::Common' => 1.26,
+'Image::Magick' => 6.2,
'LWP::Simple' => 1.41,
'LWP::UserAgent' => 2.033,
'Lingua::Stem' => 0.82,
$config{'INSTALL_ZEBRA'} = _get_value('INSTALL_ZEBRA', $msg, $defaults->{'INSTALL_ZEBRA'}, $valid_values, $install_log_values);
if ($config{'INSTALL_ZEBRA'} eq 'yes') {
+
+ if (defined(my $zebra_path = find_zebra())) {
+ $config{'PATH_TO_ZEBRA'} = $zebra_path;
+ print qq(
+Found 'zebrasrv' and 'zebraidx' in $zebra_path.
+);
+ } else {
+ print q(
+Unable to find the Zebra programs 'zebrasrv' and 'zebraidx'
+in your PATH or in some of the usual places. If you haven't
+installed Zebra yet, please do so and run Makefile.PL again.
+
+);
+ }
+
$msg = q(
Since you've chosen to use Zebra with Koha,
you must specify the primary MARC format of the
}
}
+ $msg = q(
+Would you like to run the database-dependent test suite?);
+ $msg .= _add_valid_values_disp( 'RUN_DATABASE_TESTS', $valid_values );
+ $config{'RUN_DATABASE_TESTS'} = _get_value( 'RUN_DATABASE_TESTS', $msg, $defaults->{'RUN_DATABASE_TESTS'}, $valid_values, $install_log_values );
+
+ if ( $config{'RUN_DATABASE_TESTS'} eq 'yes' ) {
+ $config{'TEST_DB_TYPE'} = $config{'DB_TYPE'};
+ $config{'TEST_DB_HOST'} = $config{'DB_HOST'};
+ $msg = q(TEST DATABASE
+
+THE DATA IN THIS DATABASE WILL BE DESTROYED during the process of
+testing. Please don't do this on your production database. It is not
+reversable.
+
+YOU WILL SUFFER DATA LOSS if you run this test suite on your test
+database. You are better off not running this optional test suite than
+doing it in a database that you don't want to lose.
+
+Please specify the name of the test database to be
+used by Koha);
+
+ $config{'TEST_DB_NAME'} = _get_value('TEST_DB_NAME', $msg, $defaults->{'TEST_DB_NAME'}, $valid_values, $install_log_values);
+ while ( $config{'TEST_DB_NAME'} eq $config{'DB_NAME'} ) {
+ $msg = q(Please do not use the same database for testing as you do for production. You run the severe risk of data loss.);
+ $config{'TEST_DB_NAME'} = _get_value('TEST_DB_NAME', $msg, $defaults->{'TEST_DB_NAME'}, $valid_values, $install_log_values);
+ }
+
+ $msg = q(
+Please specify the user that owns the database to be
+used by Koha);
+ $config{'TEST_DB_USER'} = _get_value('TEST_DB_USER', $msg, $defaults->{'TEST_DB_USER'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Please specify the password of the user that owns the
+database to be used by Koha);
+ $config{'TEST_DB_PASS'} = _get_value('TEST_DB_PASS', $msg, $defaults->{'TEST_DB_PASS'}, $valid_values, $install_log_values);
+ }
+
print "\n\n";
# add version number
$dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'pazpar2');
$dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc');
$dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
+ $dirmap{'SCRIPT_NONDEV_DIR'} = $dirmap{'SCRIPT_DIR'};
$dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
$dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
$dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
$dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'pazpar2');
$dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc');
$dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
- $skipdirs{'SCRIPT_DIR'} = 1;
+ $dirmap{'SCRIPT_NONDEV_DIR'} = $dirmap{'SCRIPT_DIR'};
+ $skipdirs{'SCRIPT_NONDEV_DIR'} = 1;
$dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
$dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
$dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
$dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package, 'pazpar2');
$dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc');
$dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
+ $dirmap{'SCRIPT_NONDEV_DIR'} = $dirmap{'SCRIPT_DIR'};
$dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
$dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
$dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lock', $package, 'zebradb');
return \%dirmap, \%skipdirs;
}
+=head2 get_test_dir
+
+Map a directory target to the corresponding path for
+the test suite.
+
+=cut
+
+sub get_test_dir {
+ my ($dirname) = @_;
+
+ my @basedir = (File::Spec->rel2abs(File::Spec->curdir()), 't', 'run');
+ if (exists $test_suite_override_dirs{$dirname}) {
+ return File::Spec->catdir(@basedir, @{ $test_suite_override_dirs{$dirname} });
+ } else {
+ return;
+ }
+
+}
+
sub _get_env_overrides {
my $dirmap = shift;
print "'dmake -x MAXLINELENGTH=300000'\n\n";
}
+=head2 find_zebra
+
+Attempt to find Zebra - check user's PATH and
+a few other directories for zebrasrv and zebraidx.
+
+FIXME: doesn't handle Win32
+
+=cut
+
+sub find_zebra {
+ my @search_dirs = map {
+ my $abs = File::Spec->rel2abs($_);
+ my ($toss, $directories);
+ ($toss, $directories, $toss) = File::Spec->splitpath($abs, 1);
+ $directories;
+ } split /:/, $ENV{PATH};
+ push @search_dirs, qw(/usr/local/bin /opt/local/bin /usr/bin);
+ my @zebrasrv_dirs = grep { -x File::Spec->catpath('', $_, 'zebrasrv') } @search_dirs;
+ return unless @zebrasrv_dirs;
+ # verify that directory that contains zebrasrv also contains zebraidx
+ foreach my $dir (@zebrasrv_dirs) {
+ return $dir if -x File::Spec->catpath('', $dir, 'zebraidx');
+ }
+ return;
+}
+
package MY;
# This will have to be reworked in order to accommodate Win32...
$config{'ZEBRA_PASS'} =~ s/\$/\$\$/g;
}
+ my $env;
# Hereagain, we must alter syntax per platform...
if ( $^O eq 'MSWin32' ) {
# NOTE: it is imperative that there be no whitespaces in ENV=value...
- my $env = join("\n", map { "__${_}__=$target_directories->{$_}" } keys %$target_directories);
+ $env = join("\n", map { "__${_}__=$target_directories->{$_}" } keys %$target_directories);
$env .= "\n\n";
$env .= join("\n", map { "__${_}__=$config{$_}" } keys %config);
- return "$env\n";
}
else {
- my $env = join("\n", map { "export __${_}__ := $target_directories->{$_}" } keys %$target_directories);
+ $env = join("\n", map { "export __${_}__ := $target_directories->{$_}" } keys %$target_directories);
$env .= "\n\n";
$env .= join("\n", map { "export __${_}__ := $config{$_}" } keys %config);
- return "$env\n";
}
+
+ if ( $config{'RUN_DATABASE_TESTS'} eq 'yes' ) {
+ if ( open( my $confhandle, '>', 't/test-config.txt' ) ) {
+ print $confhandle "# This configuration file lets the t/Makefile prepare a test koha-conf.xml file.\n";
+ print $confhandle "# It is generated by the top-level Makefile.PL.\n";
+ print $confhandle "# It is separate from the standard koha-conf.xml so that you can edit this by hand and test with different configurations.\n";
+
+ # these directories will be relocated to the 't' directory
+ foreach my $dirname ( keys %$target_directories ) {
+ my $dir = $target_directories->{$dirname};
+ if ( exists $test_suite_override_dirs{$dirname} ) {
+ $dir = main::get_test_dir($dirname);
+ }
+ print $confhandle "$dirname = $dir\n"
+ }
+ print $confhandle "\n";
+
+ print $confhandle join( "\n", map { "$_ = $config{$_}" } keys( %config ) ), "\n";
+ close( $confhandle );
+ } else {
+ warn 'unable to open conf file for database dependent tests: $!';
+ }
+
+ }
+ return "$env\n";
}