X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;ds=sidebyside;f=Makefile.PL;h=5438aeece49f915bd6da88d8b76f35fa81a2444d;hb=0f5fa1bf2d083b0799e16cf15d90574543492e31;hp=b94f2fe5f08bdfb12dd172a3660436fc0b39c72c;hpb=742ff2f47717a17abd1c3d6bde92889fac788216;p=koha_fer diff --git a/Makefile.PL b/Makefile.PL index b94f2fe5f0..5438aeece4 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -82,11 +82,6 @@ Hash of perl modules and versions required. Hash of file mappings -=head2 CONFIGURE - -Maybe use prompt() here in future to get configuration values -interactively at installation time. - =head2 PL_FILES This is a hash of PL scripts to run after installation and @@ -111,8 +106,8 @@ contents will be copied to the installation target directory. its target overrides the parent's target for that subdirectory. =item The value of each map entry may either be a scalar containing -one target or a reference to an array of targets, in which case -the directory or file is copied to each target. +one target or a reference to a hash containing 'target' and 'trimdir' +keys. =item Any files at the top level of the source tree that are not included in the map will not be installed. @@ -231,18 +226,19 @@ my $target_map = { './C4/tests' => 'NONE', './catalogue' => 'INTRANET_CGI_DIR', './cataloguing' => 'INTRANET_CGI_DIR', - './changelanguage.pl' => [ 'INTRANET_CGI_DIR', 'OPAC_CGI_DIR' ], + './changelanguage.pl' => 'INTRANET_CGI_DIR', './check_sysprefs.pl' => 'NONE', './circ' => 'INTRANET_CGI_DIR', './edithelp.pl' => 'INTRANET_CGI_DIR', './etc' => { target => 'KOHA_CONF_DIR', trimdir => -1 }, './etc/zebradb' => { target => 'ZEBRA_CONF_DIR', trimdir => -1 }, + './help.pl' => 'NONE', # FIXME './installer-CPAN.pl' => 'NONE', './installer' => 'INTRANET_CGI_DIR', - './koha-tmpl' => 'NONE', + './koha-tmpl/errors' => {target => 'INTRANET_CGI_DIR', trimdir => 2}, './koha-tmpl/intranet-tmpl' => {target => 'INTRANET_TMPL_DIR', trimdir => -1}, - './koha-tmpl/opac-tmpl' => {target => 'OPAC_TMPL_DIR', trimdir => -11}, - './koha-version.pl' => 'INTRANET_CGI_DIR', # FIXME this may need to be in OPAC_CGI_DIR as well, with an update to C4::Context + './koha-tmpl/opac-tmpl' => {target => 'OPAC_TMPL_DIR', trimdir => -1}, + './kohaversion.pl' => 'INTRANET_CGI_DIR', # FIXME this may need to be in OPAC_CGI_DIR as well, with an update to C4::Context './labels' => 'INTRANET_CGI_DIR', './mainpage.pl' => 'INTRANET_CGI_DIR', './Makefile.PL' => 'NONE', @@ -262,6 +258,18 @@ my $target_map = { './reviews' => 'INTRANET_CGI_DIR', './rss' => 'NONE', # FIXME deal with a little later './serials' => 'INTRANET_CGI_DIR', + './skel' => 'NONE', + './skel/var/run/koha/zebradb' => { target => 'ZEBRA_RUN_DIR', trimdir => -1 }, + './skel/var/lock/koha/zebradb/authorities' => { target => 'ZEBRA_LOCK_DIR', trimdir => 6 }, + './skel/var/lib/koha/zebradb/authorities/key' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 }, + './skel/var/lib/koha/zebradb/authorities/register' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 }, + './skel/var/lib/koha/zebradb/authorities/shadow' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 }, + './skel/var/lib/koha/zebradb/authorities/tmp' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 }, + './skel/var/lock/koha/zebradb/biblios' => { target => 'ZEBRA_LOCK_DIR', trimdir => 6 }, + './skel/var/lib/koha/zebradb/biblios/key' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 }, + './skel/var/lib/koha/zebradb/biblios/register' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 }, + './skel/var/lib/koha/zebradb/biblios/shadow' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 }, + './skel/var/lib/koha/zebradb/biblios/tmp' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 }, './sms' => 'INTRANET_CGI_DIR', './suggestion' => 'INTRANET_CGI_DIR', './svc' => 'INTRANET_CGI_DIR', @@ -316,14 +324,22 @@ indexed by Zebra. my %config_defaults = ( 'INSTALL_MODE' => 'standard', 'INSTALL_BASE' => '/usr/share/koha', + 'DB_TYPE' => 'mysql', + 'DB_HOST' => 'localhost', + 'DB_NAME' => 'koha', + 'DB_USER' => 'kohaadmin', + 'DB_PASS' => 'katikoan', 'INSTALL_ZEBRA' => 'yes', 'ZEBRA_MARC_FORMAT' => 'marc21', 'ZEBRA_LANGUAGE' => 'en', + 'ZEBRA_USER' => 'kohauser', + 'ZEBRA_PASS' => 'zebrastripes', ); # valid values for certain configuration options my %valid_config_values = ( 'INSTALL_MODE' => { 'standard' => 1, 'single' => 1, 'dev' => 1 }, + 'DB_TYPE' => { 'mysql' => 1, 'Pg' => 1 }, 'INSTALL_ZEBRA' => { 'yes' => 1, 'no' => 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 @@ -331,6 +347,7 @@ my %valid_config_values = ( my %config = get_configuration(\%config_defaults, \%valid_config_values); my %target_directories = get_target_directories(\%config); +display_configuration(\%config, \%target_directories); my $file_map = {}; get_file_map($target_map, $dirtree, $file_map); @@ -447,7 +464,7 @@ sub hashdir{ opendir my $dh, $dir or die $!; my $tree = {}->{$dir} = {}; while( my $file = readdir($dh) ) { - next if $file =~ m/^\.{1,2}/; + next if $file =~ m/^\.{1,2}/ and $file !~ /^\.htaccess/; # .htaccess is a special case my $path = $dir .'/' . $file; $tree->{$file} = hashdir($path), next if -d $path; push @{$tree->{'.'}}, $file; @@ -528,16 +545,11 @@ sub _add_to_file_map { # The target can be one of the following: # 1. scalar representing target symbol # 2. hash ref containing target and trimdir keys - # 3. array ref containing list of #1 and #2 # # Consequently, this routine traverses this structure, # calling itself recursively, until it deals with # all of the scalar target symbols. - if (ref $targetdir eq 'ARRAY') { - foreach my $subtarget (sort @$targetdir) { - _add_to_file_map($file_map, $subtarget, $curr_path, $file, $matchlevel); - } - } elsif (ref $targetdir eq 'HASH') { + if (ref $targetdir eq 'HASH') { my $subtarget = $targetdir->{target}; if (exists $targetdir->{trimdir}) { # if we get here, we've specified that @@ -572,7 +584,7 @@ sub _add_to_file_map { # spaces and shell metacharacters from all file names $source =~ s/ /\\ /g; $destination =~ s/ /\\ /g; - + $file_map->{$source} = $destination; } } @@ -647,6 +659,47 @@ as the package name in the FHS layout.); $config{'INSTALL_BASE'} = File::Spec->rel2abs($config{'INSTALL_BASE'}); $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); + + $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); + + $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); + + $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); + + $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); + + $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); + + $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, @@ -677,6 +730,15 @@ records. Please specify the primary language of the MARC records); $msg .= _add_valid_values_disp('ZEBRA_LANGUAGE', $valid_values); $config{'ZEBRA_LANGUAGE'} = _get_value('ZEBRA_LANGUAGE', $msg, $defaults->{'ZEBRA_LANGUAGE'}, $valid_values); + + $msg = q( +Please specify Zebra database user); + $config{'ZEBRA_USER'} = _get_value('ZEBRA_USER', $msg, $defaults->{'ZEBRA_USER'}, $valid_values); + + $msg = q( +Please specify the Zebra database password); + $config{'ZEBRA_PASS'} = _get_value('ZEBRA_PASS', $msg, $defaults->{'ZEBRA_PASS'}, $valid_values); + } return %config; } @@ -730,11 +792,11 @@ sub get_target_directories { my %dirmap = (); if ($mode eq 'single') { $dirmap{'INTRANET_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'cgi-bin'); - $dirmap{'INTRANET_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'templates'); - $dirmap{'INTRANET_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'www'); + $dirmap{'INTRANET_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs', 'intranet-tmpl'); + $dirmap{'INTRANET_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs'); $dirmap{'OPAC_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'cgi-bin'); - $dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'templates'); - $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'www'); + $dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs', 'opac-tmpl'); + $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs'); $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir(@basedir, $package, 'lib'); $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc'); $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'zebradb'); @@ -768,11 +830,11 @@ sub get_target_directories { } else { # mode is standard, i.e., 'fhs' $dirmap{'INTRANET_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'cgi-bin'); - $dirmap{'INTRANET_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'templates'); - $dirmap{'INTRANET_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'www'); + $dirmap{'INTRANET_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs', 'intranet-tmpl'); + $dirmap{'INTRANET_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs'); $dirmap{'OPAC_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'cgi-bin'); - $dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'templates'); - $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'www'); + $dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs', 'opac-tmpl'); + $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs'); $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir(@basedir, $package, 'lib'); $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package); $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package, 'zebradb'); @@ -786,12 +848,43 @@ sub get_target_directories { $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'run', $package, 'zebradb'); } - foreach my $key (sort keys %dirmap) { - print sprintf("%-25.25s%s\n", $key, $dirmap{$key}); - } + _get_argv_overrides(\%dirmap); + return %dirmap; } +sub _get_argv_overrides { + my $dirmap = shift; + + my @new_argv = (); + for (my $i = 0; $i <= $#ARGV; $i++) { + if ($ARGV[$i] =~ /^([^=]+)=([^=]+)$/ and exists $dirmap->{$1}) { + $dirmap->{$1} = $2; + } else { + push @new_argv, $ARGV[$i]; + } + } + @ARGV = @new_argv; +} + +sub display_configuration { + my $config = shift; + my $dirmap = shift; + print "\n\nKoha will be installed with the following configuration parameters:\n\n"; + foreach my $key (sort keys %$config) { + print sprintf("%-25.25s%s\n", $key, $config->{$key}); + } + + print "\nand in the following directories:\n\n"; + foreach my $key (sort keys %$dirmap) { + print sprintf("%-25.25s%s\n", $key, $dirmap->{$key}); + } + print "\n\nTo change any configuration setting, please run\n"; + print "perl Makefile.PL again. To override one of the target\n"; + print "directories, you can do so on the command line like this:\n"; + print "\nperl Makefile.PL PERL_MODULE_DIR=/usr/share/perl/5.8\n\n"; +} + package MY; sub test { @@ -834,6 +927,8 @@ sub postamble { # variables -- this is for the use of # rewrite-confg.PL my $env = join("\n", map { "export __${_}__ = $target_directories{$_}" } keys %target_directories); + $env .= "\n\n"; + $env .= join("\n", map { "export __${_}__ = $config{$_}" } keys %config); return "$env\n"; }