+Installation mode);
+ $msg .= _add_valid_values_disp('INSTALL_MODE', $valid_values);
+ $config{'INSTALL_MODE'} = _get_value('INSTALL_MODE', $msg, $defaults->{'INSTALL_MODE'}, $valid_values, $install_log_values);
+
+ # set message and default value for INSTALL_BASE
+ # depending on value of INSTALL_MODE
+ my $install_base_default = $defaults->{'INSTALL_BASE'};
+ if ($config{'INSTALL_MODE'} eq 'dev') {
+ $msg = q(
+Please specify the directory in which to install Koha's
+active configuration files and (if applicable) the
+Zebra database. Koha's CGI scripts and templates will
+be run from the current directory.
+
+Configuration directory:);
+ # FIXME - home directory portability consideration apply
+ $install_base_default = (exists $ENV{'HOME'}) ? "$ENV{'HOME'}/koha-dev" : "$defaults->{'INSTALL_BASE'}-dev";
+ } elsif ($config{'INSTALL_MODE'} eq 'single') {
+ $msg = "\nPlease specify the directory in which to install Koha";
+ # FIXME -- we're assuming under a 'single' mode install
+ # that user will likely want to install under the home
+ # directory. This is OK in and of itself, but we should
+ # use File::HomeDir to locate the home directory portably.
+ # This is deferred for now because File::HomeDir is not yet
+ # core.
+ # --we must also keep this portable to the major OS's -fbcit
+ $install_base_default = (exists $ENV{'HOME'}) ? "$ENV{'HOME'}/koha" : $defaults->{'INSTALL_BASE'};
+ } else {
+ # must be standard
+ $msg = q(
+Please specify the directory under which most Koha files
+will be installed.
+
+Note that if you are planning in installing more than
+one instance of Koha, you may want to modify the last
+component of the directory path, which will be used
+as the package name in the FHS layout.
+
+Base installation directory);
+ }
+ $config{'INSTALL_BASE'} = _get_value('INSTALL_BASE', $msg, $install_base_default, $valid_values, $install_log_values);
+
+ $config{'INSTALL_BASE'} = File::Spec->rel2abs($config{'INSTALL_BASE'});
+ print "INSTALL_BASE=$config{'INSTALL_BASE'}\r\n" if $DEBUG;
+ if ($config{'INSTALL_MODE'} eq "standard") {
+ $msg = q(
+Since you are using the 'standard' install
+mode, you should run 'make install' as root.
+However, it is recommended that a non-root
+user (on Unix and Linux platforms) have
+ownership of Koha's files, including the
+Zebra indexes if applicable.
+
+Please specify a user account. This
+user account does not need to exist
+right now, but it needs to exist
+before you run 'make install'. Please
+note that for security reasons, this
+user should not be the same as the user
+account Apache runs under.
+
+User account);
+ $config{'KOHA_USER'} = _get_value('KOHA_USER', $msg, $defaults->{'KOHA_USER'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Please specify the group that should own
+Koha's files. As above, this group need
+not exist right now, but should be created
+before you run 'make install'.
+
+Group);
+ $config{'KOHA_GROUP'} = _get_value('KOHA_GROUP', $msg, $defaults->{'KOHA_GROUP'}, $valid_values, $install_log_values);
+ }
+
+ $msg = q(
+Please specify which database engine you will use
+to store data in Koha. The choices are MySQL and
+PostgreSQL; please note that at the moment
+PostgreSQL support is highly experimental.
+
+DBMS to use);
+ $msg .= _add_valid_values_disp('DB_TYPE', $valid_values);
+ $config{'DB_TYPE'} = _get_value('DB_TYPE', $msg, $defaults->{'DB_TYPE'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Please specify the name or address of your
+database server. Note that the database
+does not have to exist at this point, it
+can be created after running 'make install'
+and before you try using Koha for the first time.
+
+Database server);
+ $config{'DB_HOST'} = _get_value('DB_HOST', $msg, $defaults->{'DB_HOST'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Please specify the port used to connect to the
+DMBS);
+ my $db_port_default = $config{'DB_TYPE'} eq 'mysql' ? '3306' : '5432';
+ $config{'DB_PORT'} = _get_value('DB_PORT', $msg, $db_port_default, $valid_values, $install_log_values);
+
+ $msg = q(
+Please specify the name of the database to be
+used by Koha);
+ $config{'DB_NAME'} = _get_value('DB_NAME', $msg, $defaults->{'DB_NAME'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Please specify the user that owns the database to be
+used by Koha);
+ $config{'DB_USER'} = _get_value('DB_USER', $msg, $defaults->{'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{'DB_PASS'} = _get_value('DB_PASS', $msg, $defaults->{'DB_PASS'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Koha can use the Zebra search engine for high-performance
+searching of bibliographic and authority records. If you
+have installed the Zebra software and would like to use it,
+please answer 'yes' to the following question. Otherwise,
+Koha will default to using its internal search engine.
+
+Please note that if you choose *NOT* to install Zebra,
+koha-conf.xml will still contain some references to Zebra
+settings. Those references will be ignored by Koha.
+
+Install the Zebra configuration files?);
+ $msg .= _add_valid_values_disp('INSTALL_ZEBRA', $valid_values);
+ $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
+records to be indexed by Zebra.
+
+Koha provides Zebra configuration files for MARC 21
+and UNIMARC.
+
+MARC format for Zebra indexing);
+ $msg .= _add_valid_values_disp('ZEBRA_MARC_FORMAT', $valid_values);
+ $config{'ZEBRA_MARC_FORMAT'} = _get_value('ZEBRA_MARC_FORMAT', $msg, $defaults->{'ZEBRA_MARC_FORMAT'}, $valid_values, $install_log_values);
+ $msg = q(
+Koha supplies Zebra configuration files tuned for
+searching either English (en) or French (fr) MARC
+records.
+
+Primary language for Zebra indexing);
+ $msg .= _add_valid_values_disp('ZEBRA_LANGUAGE', $valid_values);
+ $config{'ZEBRA_LANGUAGE'} = _get_value('ZEBRA_LANGUAGE', $msg, $defaults->{'ZEBRA_LANGUAGE'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Koha can use one of two different indexing modes
+for the MARC authorities records:
+
+grs1 - uses the Zebra GRS-1 filter, available
+ for legacy support
+dom - uses the DOM XML filter; offers improved
+ functionality.
+
+Authorities indexing mode);
+ $msg .= _add_valid_values_disp('AUTH_INDEX_MODE', $valid_values);
+ $config{'AUTH_INDEX_MODE'} = _get_value('AUTH_INDEX_MODE', $msg, $defaults->{'AUTH_INDEX_MODE'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Please specify Zebra database user);
+ $config{'ZEBRA_USER'} = _get_value('ZEBRA_USER', $msg, $defaults->{'ZEBRA_USER'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Please specify the Zebra database password);
+ $config{'ZEBRA_PASS'} = _get_value('ZEBRA_PASS', $msg, $defaults->{'ZEBRA_PASS'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Since you've chosen to use Zebra, you can enable the SRU/
+Z39.50 Server if you so choose, but you must specify a
+few configuration options for it.
+
+Please note that if you choose *NOT* to configure SRU,
+koha-conf.xml will still contain some references to SRU
+settings. Those references will be ignored by Koha.
+
+Install the SRU configuration files?);
+ $msg .= _add_valid_values_disp('INSTALL_SRU', $valid_values);
+ $config{'INSTALL_SRU'} = _get_value('INSTALL_SRU', $msg, $defaults->{'INSTALL_SRU'}, $valid_values, $install_log_values);
+
+ if ($config{'INSTALL_SRU'} eq 'yes') {
+ $msg = q(
+Since you've chosen to configure SRU, you must
+specify the host and port(s) that the SRU
+Servers (bibliographic and authority) should run on.
+);
+ $msg = q(
+SRU Database host?);
+ $config{'ZEBRA_SRU_HOST'} = _get_value('ZEBRA_SRU_HOST', $msg, $defaults->{'ZEBRA_SRU_HOST'}, $valid_values, $install_log_values);
+
+ $msg = q(
+SRU port for bibliographic data?);
+ $config{'ZEBRA_SRU_BIBLIOS_PORT'} = _get_value('ZEBRA_SRU_BIBLIOS_PORT', $msg, $defaults->{'ZEBRA_SRU_BIBLIOS_PORT'}, $valid_values, $install_log_values);
+
+ $msg = q(
+SRU port for authority data?);
+ $config{'ZEBRA_SRU_AUTHORITIES_PORT'} = _get_value('ZEBRA_SRU_AUTHORITIES_PORT', $msg, $defaults->{'ZEBRA_SRU_AUTHORITIES_PORT'}, $valid_values, $install_log_values);
+
+ }
+
+ $msg = q(
+Since you've chosen to use Zebra, you can also choose to
+install PazPar2, which is a metasearch tool. With PazPar2,
+Koha can perform on-the-fly merging of bibliographic
+records during searching, allowing for FRBRization of
+the results list.
+
+Install the PazPar2 configuration files?);
+ $msg .= _add_valid_values_disp('INSTALL_PAZPAR2', $valid_values);
+ $config{'INSTALL_PAZPAR2'} = _get_value('INSTALL_PAZPAR2', $msg, $defaults->{'INSTALL_PAZPAR2'}, $valid_values, $install_log_values);
+
+ if ($config{'INSTALL_PAZPAR2'} eq 'yes') {
+ $msg = q(
+Since you've chosen to configure PazPar2, you must
+specify the host and port(s) that PazPar2
+uses:
+);
+ $msg = q(
+Zebra bibliographic server host?);
+ $config{'MERGE_SERVER_HOST'} = _get_value('MERGE_SERVER_HOST', $msg, $defaults->{'MERGE_SERVER_HOST'}, $valid_values, $install_log_values);
+
+ $msg = q(
+Zebra bibliographic port for PazPar2 to use?);
+ $config{'MERGE_SERVER_PORT'} = _get_value('MERGE_SERVER_PORT', $msg, $defaults->{'MERGE_SERVER_PORT'}, $valid_values, $install_log_values);
+
+ $msg = q(
+PazPar2 host?);
+ $config{'PAZPAR2_HOST'} = _get_value('PAZPAR2_HOST', $msg, $defaults->{'PAZPAR2_HOST'}, $valid_values, $install_log_values);
+
+ $msg = q(
+PazPar2 port?);
+ $config{'PAZPAR2_PORT'} = _get_value('PAZPAR2_PORT', $msg, $defaults->{'PAZPAR2_PORT'}, $valid_values, $install_log_values);
+
+ }
+ }
+
+ $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
+ my $version = "no_version_found";
+ eval {
+ require 'kohaversion.pl';
+ $version = kohaversion();
+ };
+ $config{'KOHA_INSTALLED_VERSION'} = $version;
+
+ return %config;
+}
+
+sub _add_valid_values_disp {
+ my $key = shift;
+ my $valid_values = shift;
+
+ my $disp = "";
+ if (exists $valid_values->{$key}) {
+ $disp = " (" . join(", ", sort keys %{ $valid_values->{$key} }) . ")";
+ }
+ return $disp;
+}
+
+sub _get_value {
+ my $key = shift;
+ my $msg = shift;
+ my $default = shift;
+ my $valid_values = shift;
+ my $install_log_values = shift;
+
+ # take value from install log if present
+ if (exists $install_log_values{$key}) {
+ return $install_log_values{$key};
+ }
+
+ # override default value from environment
+ if (exists $ENV{$key}) {
+ $default = $ENV{$key};
+ $msg .= " (default from environment)";
+ }
+
+ my $val = prompt($msg, $default);
+
+ while (exists $valid_values->{$key} and
+ $val ne $default and
+ not exists $valid_values->{$key}->{$val}) {
+ my $retry_msg = "Value '$val' is not a valid option.\n";
+ $retry_msg .= "Please enter a value";
+ $retry_msg .= _add_valid_values_disp($key, $valid_values);
+ $val = prompt($retry_msg, $default);
+ }
+ return $val;
+}
+
+=head2 get_target_directories
+
+Creates a hash mapping from symbols for installation target
+directories to actual directory paths.
+
+Also returns a hash indicating targets for which
+files need not be copied -- this is used for the 'dev'
+mode installation, where some files are installed in place.