1 # Copyright 2007 MJ Ray
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
18 # Current maintainer MJR http://mjr.towers.org.uk/
19 # See http://www.koha.org/wiki/?page=KohaInstaller
24 use ExtUtils::MakeMaker;
29 die "perl 5.6.1 or later required" unless ($] >= 5.006001);
31 # Hash up directory structure & files beginning with the directory we were called from (should be the base of koha)...
33 my $dirtree = hashdir('.');
38 Makefile.PL - Koha packager and installer
42 =head2 BASIC INSTALLATION
48 =head2 PACKAGING RELEASE TARBALLS
59 This is a packager and installer that uses
60 ExtUtils::MakeMaker, which is fairly common
62 As well as building tar or zip files
63 and installing with the above commands,
64 it allows us to check pre-requisites
65 and generate configuration files.
69 =head2 NAME, VERSION_FROM, ABSTRACT, AUTHOR
71 Basic metadata about this software.
75 Suppress generation of META.yml file.
79 Hash of perl modules and versions required.
87 This is a hash of PL scripts to run after installation and
88 the files to ask them to generate.
89 Maybe use the values from CONFIGURE
90 to generate initial configuration files in future.
96 This is a hash mapping directories and files in the
97 source tree to installation target directories. The rules
102 =item If a directory or file is specified, it and its
103 contents will be copied to the installation target directory.
105 =item If a subdirectory of a mapped directory is specified,
106 its target overrides the parent's target for that subdirectory.
108 =item The value of each map entry may either be a scalar containing
109 one target or a reference to a hash containing 'target' and 'trimdir'
112 =item Any files at the top level of the source tree that are
113 not included in the map will not be installed.
115 =item Any directories at the top level of the source tree
116 that are not included in the map will be installed in
117 INTRANET_CGI_DIR. This is a sensible default given the
118 current organization of the source tree, but (FIXME) it
119 would be better to reorganize the source tree to better
120 match the installation system, to allow adding new directories
121 without having to adjust Makefile.PL each time. The idea
122 is to make the C<$target_map> hash as minimal as possible.
126 The permitted installation targets are:
130 =item INTRANET_CGI_DIR
132 CGI scripts for intranet (staff) interface.
134 =item INTRANET_TMPL_DIR
136 HTML templates for the intranet interface.
138 =item INTRANET_WWW_DIR
140 HTML files, images, etc. for DocumentRoot for the intranet interface.
144 CGI scripts for OPAC (public) interface.
148 HTML templates for the OPAC interface.
152 HTML files, images, etc. for DocumentRoot for the OPAC interface.
154 =item PERL_MODULE_DIR
156 Perl modules (at present just the C4 modules) that are intimately
157 tied to Koha. Depending on the installation options, these
158 may or may not be installed one of the standard directories
159 in Perl's default @LIB.
163 Directory for Koha configuration files.
167 Directory for Zebra configuration files.
171 Directory for Zebra's lock files.
175 Directory for Zebra's data files.
179 Directory for Zebra's UNIX-domain sockets.
183 Directory for example configuration files. This directory
184 exists primarily to make it easier to change the
185 MARC format or language of the active Zebra
190 Directory for command-line scripts and daemons.
194 Directory for man pages created from POD -- will mostly
195 contain information of interest to Koha developers.
199 Directory for Koha documentation accessed from the
200 command-line, e.g., READMEs.
204 Directory for Apache and Zebra logs produced by Koha.
208 This is a dummy target used to explicitly state
209 that a given file or directory is not to be installed.
210 This is used either for parts of the installer itself
211 or for development tools that are not applicable to a
212 production installation.
219 './about.pl' => 'INTRANET_CGI_DIR',
220 './acqui' => 'INTRANET_CGI_DIR',
221 './admin' => 'INTRANET_CGI_DIR',
222 './authorities' => 'INTRANET_CGI_DIR',
223 './C4' => 'PERL_MODULE_DIR',
224 './C4/SIP/t' => 'NONE',
225 './C4/SIP/koha_test' => 'NONE',
226 './C4/tests' => 'NONE',
227 './catalogue' => 'INTRANET_CGI_DIR',
228 './cataloguing' => 'INTRANET_CGI_DIR',
229 './changelanguage.pl' => 'INTRANET_CGI_DIR',
230 './check_sysprefs.pl' => 'NONE',
231 './circ' => 'INTRANET_CGI_DIR',
232 './edithelp.pl' => 'INTRANET_CGI_DIR',
233 './etc' => { target => 'KOHA_CONF_DIR', trimdir => -1 },
234 './etc/zebradb' => { target => 'ZEBRA_CONF_DIR', trimdir => -1 },
235 './help.pl' => 'NONE', # FIXME
236 './installer-CPAN.pl' => 'NONE',
237 './installer' => 'INTRANET_CGI_DIR',
238 './koha-tmpl/errors' => {target => 'INTRANET_CGI_DIR', trimdir => 2},
239 './koha-tmpl/intranet-tmpl' => {target => 'INTRANET_TMPL_DIR', trimdir => -1},
240 './koha-tmpl/opac-tmpl' => {target => 'OPAC_TMPL_DIR', trimdir => -1},
241 './kohaversion.pl' => 'INTRANET_CGI_DIR', # FIXME this may need to be in OPAC_CGI_DIR as well, with an update to C4::Context
242 './labels' => 'INTRANET_CGI_DIR',
243 './mainpage.pl' => 'INTRANET_CGI_DIR',
244 './Makefile.PL' => 'NONE',
245 './MANIFEST.SKIP' => 'NONE',
246 './members' => 'INTRANET_CGI_DIR',
247 './misc' => { target => 'SCRIPT_DIR', trimdir => -1 },
248 './misc/info' => { target => 'DOC_DIR', trimdir => 2 },
249 './misc/release notes' => { target => 'DOC_DIR', trimdir => 2 },
250 './misc/translator' => { target => 'EXAMPLE_DIR', trimdir => 2 },
251 './misc/installer_devel_notes' => 'NONE',
252 './opac' => 'OPAC_CGI_DIR',
253 './README.txt' => 'NONE',
254 './reports' => 'INTRANET_CGI_DIR',
255 './reserve' => 'INTRANET_CGI_DIR',
256 './reviews' => 'INTRANET_CGI_DIR',
257 './rewrite-config.PL' => 'NONE',
258 './reviews' => 'INTRANET_CGI_DIR',
259 './rss' => 'NONE', # FIXME deal with a little later
260 './serials' => 'INTRANET_CGI_DIR',
262 './skel/var/run/koha/zebradb' => { target => 'ZEBRA_RUN_DIR', trimdir => -1 },
263 './skel/var/lock/koha/zebradb/authorities' => { target => 'ZEBRA_LOCK_DIR', trimdir => 6 },
264 './skel/var/lib/koha/zebradb/authorities/key' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
265 './skel/var/lib/koha/zebradb/authorities/register' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
266 './skel/var/lib/koha/zebradb/authorities/shadow' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
267 './skel/var/lib/koha/zebradb/authorities/tmp' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
268 './skel/var/lock/koha/zebradb/biblios' => { target => 'ZEBRA_LOCK_DIR', trimdir => 6 },
269 './skel/var/lib/koha/zebradb/biblios/key' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
270 './skel/var/lib/koha/zebradb/biblios/register' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
271 './skel/var/lib/koha/zebradb/biblios/shadow' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
272 './skel/var/lib/koha/zebradb/biblios/tmp' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
273 './sms' => 'INTRANET_CGI_DIR',
274 './suggestion' => 'INTRANET_CGI_DIR',
275 './svc' => 'INTRANET_CGI_DIR',
277 './tmp' => 'NONE', # FIXME deal with later
278 './tools' => 'INTRANET_CGI_DIR',
279 './virtualshelves' => 'INTRANET_CGI_DIR',
280 # ignore files and directories created by the install itself
281 './pm_to_blib' => 'NONE',
285 =head1 CONFIGURATION OPTIONS
287 The following configuration options are used by the installer.
293 Specifies whether installation will be FHS-compliant (default,
294 assumes user has root), put everything under
295 a single directory (for users installing on a web host
296 that allows CGI scripts and a MySQL database but not root
297 access), or development (for a developer who wants to run
298 Koha from a git clone with no fuss).
302 Directory under which most components will go. Default
303 value will vary depending on INSTALL_MODE.
307 Whether to install Zebra configuration files and data
310 =item ZEBRA_MARC_FORMAT
312 Specifies format of MARC records to be indexed by Zebra.
316 Specifies primary language of records that will be
323 # default configuration options
324 my %config_defaults = (
325 'INSTALL_MODE' => 'standard',
326 'INSTALL_BASE' => '/usr/share/koha',
327 'DB_TYPE' => 'mysql',
328 'DB_HOST' => 'localhost',
330 'DB_USER' => 'kohaadmin',
331 'DB_PASS' => 'katikoan',
332 'INSTALL_ZEBRA' => 'yes',
333 'ZEBRA_MARC_FORMAT' => 'marc21',
334 'ZEBRA_LANGUAGE' => 'en',
335 'ZEBRA_USER' => 'kohauser',
336 'ZEBRA_PASS' => 'zebrastripes',
339 # valid values for certain configuration options
340 my %valid_config_values = (
341 'INSTALL_MODE' => { 'standard' => 1, 'single' => 1, 'dev' => 1 },
342 'DB_TYPE' => { 'mysql' => 1, 'Pg' => 1 },
343 'INSTALL_ZEBRA' => { 'yes' => 1, 'no' => 1 },
344 'ZEBRA_MARC_FORMAT' => { 'marc21' => 1, 'unimarc' => 1 }, # FIXME should generate from contents of distributation
345 'ZEBRA_LANGUAGE' => { 'en' => 1, 'fr' => 1 }, # FIXME should generate from contents of distribution
348 my %config = get_configuration(\%config_defaults, \%valid_config_values);
349 my %target_directories = get_target_directories(\%config);
350 display_configuration(\%config, \%target_directories);
352 get_file_map($target_map, $dirtree, $file_map);
356 #VERSION => strftime('2.9.%Y%m%d%H',gmtime),
357 VERSION_FROM => 'C4/Context.pm',
358 ABSTRACT => 'Award-winning integrated library system (ILS) and Web OPAC',
359 AUTHOR => 'Koha Developers <koha-devel@nongnu.org>',
364 'CGI::Session' => '4.10',
365 'Class::Factory::Util' => 1.7,
366 'Class::Accessor' => 0.30,
367 'DBD::mysql' => 3.0008,
369 'Data::Dumper' => 2.121_08,
371 'Date::Manip' => 5.44,
372 'Digest::MD5' => 2.36,
373 'File::Temp' => 0.16,
374 'GD::Barcode::UPCE' => 1.1,
375 'Getopt::Long' => 2.35,
376 'Getopt::Std' => 1.05,
377 'HTML::Template::Pro' => 0.65,
378 'HTTP::Cookies' => 1.39,
379 'HTTP::Request::Common' => 1.26,
380 'LWP::Simple' => 1.41,
381 'LWP::UserAgent' => 2.033,
382 'Lingua::Stem' => 0.82,
383 'List::Util' => 1.18,
384 'Locale::Language' => 2.07,
385 'MARC::Charset' => 0.98,
386 'MARC::Crosswalk::DublinCore' => 0.03,
387 'MARC::File::XML' => 0.88,
388 'MARC::Record' => 2.00,
389 'MIME::Base64' => 3.07,
390 'MIME::QuotedPrint' => 3.07,
391 'Mail::Sendmail' => 0.79,
392 'PDF::API2' => 2.000,
393 'PDF::API2::Page' => 2.000,
394 'PDF::API2::Util' => 2.000,
395 'PDF::Reuse' => 0.33,
396 'PDF::Reuse::Barcode' => 0.05,
398 'Schedule::At' => 1.06,
399 'Term::ANSIColor' => 1.10,
401 'Test::Harness' => 2.56,
402 'Test::More' => 0.62,
404 'Text::CSV_XS' => 0.32,
405 'Text::Wrap' => 2005.082401,
406 'Time::HiRes' => 1.86,
407 'Time::localtime' => 1.02,
408 'Unicode::Normalize' => 0.32,
409 'XML::Dumper' => 0.81,
410 'XML::LibXML' => 1.59,
411 'XML::SAX::ParserFactory' => 1.01,
412 'XML::Simple' => 2.14,
420 # Man pages generated from POD
421 INSTALLMAN1DIR => File::Spec->catdir($target_directories{'MAN_DIR'}, 'man1'),
422 INSTALLMAN3DIR => File::Spec->catdir($target_directories{'MAN_DIR'}, 'man3'),
425 # # Ask for options with prompt($question,$default) calls here?
426 # return { macro => { 'export TEST' => '755' } }
429 PL_FILES => { # generator => target(s)
430 'rewrite-config.PL' => [
431 'blib/KOHA_CONF_DIR/koha-conf.xml',
432 'blib/KOHA_CONF_DIR/koha-httpd.conf',
433 'blib/ZEBRA_CONF_DIR/etc/passwd',
434 'blib/ZEBRA_CONF_DIR/zebra-biblios.cfg',
435 'blib/ZEBRA_CONF_DIR/zebra-authorities.cfg'
438 # 'opac/getfromintranet.PL' => ['$(INST_LIBDIR)/opac/cgi-bin/detail.pl','$(INST_LIBDIR)/opac/cgi-bin/moredetail.pl','$(INST_LIBDIR)/opac/cgi-bin/search.pl','$(INST_LIBDIR)/opac/cgi-bin/subjectsearch.pl','$(INST_LIBDIR)/opac/cgi-bin/logout.pl'],
439 # 'misc/koha.conf.PL' => '$(INST_LIBDIR)/../etc/koha.conf',
440 # 'misc/apache-koha.conf.PL' => '$(INST_LIBDIR)/../etc/apache-koha.conf',
441 # 'misc/koha.sql.PL' => '$(INST_LIBDIR)/intranet/scripts/koha.sql',
442 # 'z3950/z3950-daemon-options.PL' => '$(INST_LIBDIR)/intranet/scripts/z3950daemon/z3950-daemon-options',
443 # # fake target to check permissions
444 # 'misc/chmod.PL' => '$(INST_LIBDIR)/fake-target'
446 # need to set ownerships
447 # need to load koha.sql
448 # need to link koha-httpd.conf
449 # need to start z3950-daemon
456 This function recurses through the directory structure and builds
457 a hash of hashes containing the structure with arrays holding filenames.
458 This directory hashing routine was taken from BrowserUK @ http://www.perlmonks.org/?node_id=219919
464 opendir my $dh, $dir or die $!;
465 my $tree = {}->{$dir} = {};
466 while( my $file = readdir($dh) ) {
467 next if $file =~ m/^\.{1,2}/ and $file !~ /^\.htaccess/; # .htaccess is a special case
468 my $path = $dir .'/' . $file;
469 $tree->{$file} = hashdir($path), next if -d $path;
470 push @{$tree->{'.'}}, $file;
477 This function combines the target_map and file hash to
478 map each source file to its destination relative to
479 the set of installation targets.
481 Output will be a hash mapping from each source file
482 to its destination value, like this:
484 'mainpage.pl' => '$(INTRANET_CGI_DIR)/mainpage.pl'
489 my $target_map = shift;
491 my $file_map = shift;
492 my $curr_path = @_ ? shift : ['.'];
494 # Traverse the directory tree.
495 # For each file or directory, identify the
496 # most specific match in the target_map
497 foreach my $dir (sort keys %{ $dirtree }) {
499 # deal with files in directory
500 foreach my $file (sort @{ $dirtree->{$dir} }) {
501 my $targetdir = undef;
502 my $matchlevel = undef;
503 # first, see if there is a match on this specific
504 # file in the target map
505 my $filepath = join("/", @$curr_path, $file);
506 if (exists $target_map->{$filepath}) {
507 $targetdir = $target_map->{$filepath};
508 $matchlevel = scalar(@$curr_path) + 1;
510 # no match on the specific file; look for
512 for (my $i = scalar(@$curr_path) - 1; $i >= 0; $i--) {
513 my $dirpath = join("/", @$curr_path[0..$i]);
514 if (exists $target_map->{$dirpath}) {
515 $targetdir = $target_map->{$dirpath};
516 $matchlevel = $i + 1;
521 if (defined $targetdir) {
522 _add_to_file_map($file_map, $targetdir, $curr_path, $file, $matchlevel);
524 my $path = join("/", @$curr_path);
525 print "failed to map: $path/$file\n" if $DEBUG;
529 # dealing with subdirectory
530 push @$curr_path, $dir;
531 get_file_map($target_map, $dirtree->{$dir}, $file_map, $curr_path);
537 sub _add_to_file_map {
538 my $file_map = shift;
539 my $targetdir = shift;
540 my $curr_path = shift;
542 my $matchlevel = shift;
543 my $dest_path = @_ ? shift : $curr_path;
545 # The target can be one of the following:
546 # 1. scalar representing target symbol
547 # 2. hash ref containing target and trimdir keys
549 # Consequently, this routine traverses this structure,
550 # calling itself recursively, until it deals with
551 # all of the scalar target symbols.
552 if (ref $targetdir eq 'HASH') {
553 my $subtarget = $targetdir->{target};
554 if (exists $targetdir->{trimdir}) {
555 # if we get here, we've specified that
556 # rather than installing the file to
557 # $(TARGET)/matching/dirs/subdirs/file,
558 # we want to install it to
559 # $(TARGET)/subdirs/file
561 # Note that this the only place where
562 # $matchlevel is used.
563 my @new_dest_path = @$dest_path;
564 if ($targetdir->{trimdir} == -1) {
565 splice @new_dest_path, 0, $matchlevel;
567 splice @new_dest_path, 0, $targetdir->{trimdir};
569 _add_to_file_map($file_map, $subtarget, $curr_path, $file, $matchlevel, \@new_dest_path);
571 # actually getting here means that the
572 # target was unnecessarily listed
573 # as a hash, but we'll forgive that
574 _add_to_file_map($file_map, $subtarget, $curr_path, $file, $matchlevel);
576 } elsif ($targetdir ne 'NONE' and $targetdir ne '') {
577 my $source = File::Spec->catfile(@$curr_path, $file);
578 my $destination = File::Spec->catfile('blib', $targetdir, @$dest_path, $file);
579 #print "$source => $destination\n"; # DEBUG
580 # quote spaces in file names
581 # FIXME: this is of questionable portability and
582 # probably depends on user's make recognizing this
583 # quoting syntax -- probably better to remove
584 # spaces and shell metacharacters from all file names
585 $source =~ s/ /\\ /g;
586 $destination =~ s/ /\\ /g;
588 $file_map->{$source} = $destination;
592 =head2 get_configuration_options
594 This prompts the user for various configuration options.
598 sub get_configuration {
599 my $defaults = shift;
600 my $valid_values = shift;
604 By default, Koha can be installed in one of three ways:
606 standard: Install files in conformance with the Filesystem
607 Hierarchy Standard (FHS). This is the default mode
608 and should be used when installing a production
609 Koha system. On Unix systems, root access is
610 needed to complete a standard installation.
612 single: Install files under a single directory. This option
613 is useful for installing Koha without root access, e.g.,
614 on a web host that allows CGI scripts and MySQL databases
615 but requires the user to keep all files under the user's
618 dev: Create a set of symbolic links and configuration files to
619 allow Koha to run directly from the source distribution.
620 This mode is useful for developers who want to run
621 Koha from a git clone.
623 Please choose the installation mode);
624 $msg .= _add_valid_values_disp('INSTALL_MODE', $valid_values);
625 $config{'INSTALL_MODE'} = _get_value('INSTALL_MODE', $msg, $defaults->{'INSTALL_MODE'}, $valid_values);
627 # set message and default value for INSTALL_BASE
628 # depending on value of INSTALL_MODE
629 my $install_base_default = $defaults->{'INSTALL_BASE'};
630 if ($config{'INSTALL_MODE'} eq 'dev') {
632 Please specify the directory in which to install Koha's
633 active configuration files and (if applicable) the
634 Zebra database. Koha's CGI scripts and templates will
635 be run from the current directory.);
636 # FIXME - home directory portability consideration apply
637 $install_base_default = (exists $ENV{'HOME'}) ? "$ENV{'HOME'}/koha-dev" : "/usr/share/koha-dev";
638 } elsif ($config{'INSTALL_MODE'} eq 'single') {
639 $msg = "\nPlease specify the directory in which to install Koha";
640 # FIXME -- we're assuming under a 'single' mode install
641 # that user will likely want to install under the home
642 # directory. This is OK in and of itself, but we should
643 # use File::HomeDir to locate the home directory portably.
644 # This is deferred for now because File::HomeDir is not yet
646 $install_base_default = (exists $ENV{'HOME'}) ? "$ENV{'HOME'}/koha" : "/usr/share/koha";
650 Please specify the directory under which most Koha files
653 Note that if you are planning in installing more than
654 one instance of Koha, you may want to modify the last
655 component of the directory path, which will be used
656 as the package name in the FHS layout.);
658 $config{'INSTALL_BASE'} = _get_value('INSTALL_BASE', $msg, $install_base_default, $valid_values);
659 $config{'INSTALL_BASE'} = File::Spec->rel2abs($config{'INSTALL_BASE'});
662 Please specify which database engine you will use
663 to store data in Koha. The choices are MySQL and
664 PostgreSQL; please note that at the moment
665 PostgreSQL support is highly experimental.
668 $msg .= _add_valid_values_disp('DB_TYPE', $valid_values);
669 $config{'DB_TYPE'} = _get_value('DB_TYPE', $msg, $defaults->{'DB_TYPE'}, $valid_values);
672 Please specify the name or address of your
673 database server. Note that the database
674 does not have to exist at this point, it
675 can be created after running 'make install'
676 and before you try using Koha for the first time.
679 $config{'DB_HOST'} = _get_value('DB_HOST', $msg, $defaults->{'DB_HOST'}, $valid_values);
682 Please specify the port used to connect to the
684 my $db_port_default = $config{'DB_TYPE'} eq 'mysql' ? '3306' : '5432';
685 $config{'DB_PORT'} = _get_value('DB_PORT', $msg, $db_port_default, $valid_values);
688 Please specify the name of the database to be
690 $config{'DB_NAME'} = _get_value('DB_NAME', $msg, $defaults->{'DB_NAME'}, $valid_values);
693 Please specify the user that owns the database to be
695 $config{'DB_USER'} = _get_value('DB_USER', $msg, $defaults->{'DB_USER'}, $valid_values);
698 Please specify the password of the user that owns the
699 database to be used by Koha);
700 $config{'DB_PASS'} = _get_value('DB_PASS', $msg, $defaults->{'DB_PASS'}, $valid_values);
703 Koha can use the Zebra search engine for high-performance
704 searching of bibliographic and authority records. If you
705 have installed the Zebra software and would like to use it,
706 please answer 'yes' to the following question. Otherwise,
707 Koha will default to using its internal search engine.
709 Please specify whether to install the Zebra configuration files);
710 $msg .= _add_valid_values_disp('INSTALL_ZEBRA', $valid_values);
711 $config{'INSTALL_ZEBRA'} = _get_value('INSTALL_ZEBRA', $msg, $defaults->{'INSTALL_ZEBRA'}, $valid_values);
713 if ($config{'INSTALL_ZEBRA'} eq 'yes') {
715 Since you've chosen to use Zebra with Koha,
716 you must specify the primary MARC format of the
717 records to be indexed by Zebra.
719 Koha provides Zebra configuration files for MARC 21
722 Please specify the MARC format);
723 $msg .= _add_valid_values_disp('ZEBRA_MARC_FORMAT', $valid_values);
724 $config{'ZEBRA_MARC_FORMAT'} = _get_value('ZEBRA_MARC_FORMAT', $msg, $defaults->{'ZEBRA_MARC_FORMAT'}, $valid_values);
726 Koha supplies Zebra configuration files tuned for
727 searching either English (en) or French (fr) MARC
730 Please specify the primary language of the MARC records);
731 $msg .= _add_valid_values_disp('ZEBRA_LANGUAGE', $valid_values);
732 $config{'ZEBRA_LANGUAGE'} = _get_value('ZEBRA_LANGUAGE', $msg, $defaults->{'ZEBRA_LANGUAGE'}, $valid_values);
735 Please specify Zebra database user);
736 $config{'ZEBRA_USER'} = _get_value('ZEBRA_USER', $msg, $defaults->{'ZEBRA_USER'}, $valid_values);
739 Please specify the Zebra database password);
740 $config{'ZEBRA_PASS'} = _get_value('ZEBRA_PASS', $msg, $defaults->{'ZEBRA_PASS'}, $valid_values);
746 sub _add_valid_values_disp {
748 my $valid_values = shift;
751 if (exists $valid_values->{$key}) {
752 $disp = " (" . join(", ", sort keys %{ $valid_values->{$key} }) . ")";
761 my $valid_values = shift;
763 my $val = prompt($msg, $default);
764 while (exists $valid_values->{$key} and not exists $valid_values->{$key}->{$val}) {
765 my $retry_msg = "Value '$val' is not a valid option.\n";
766 $retry_msg .= "Please enter a value";
767 $retry_msg .= _add_valid_values_disp($key, $valid_values);
768 $val = prompt($retry_msg, $default);
773 =head2 get_target_directories
775 Creates a hash mapping from symbols for installation target
776 directories to actual directory paths.
780 sub get_target_directories {
783 my $base = $config->{'INSTALL_BASE'};
784 my $mode = $config->{'INSTALL_MODE'};
786 # get last component of install base directory
787 # to treat as package name
788 my ($volume, $directories, $file) = File::Spec->splitpath($base, 1);
789 my @basedir = File::Spec->splitdir($directories);
790 my $package = pop @basedir;
793 if ($mode eq 'single') {
794 $dirmap{'INTRANET_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'cgi-bin');
795 $dirmap{'INTRANET_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs', 'intranet-tmpl');
796 $dirmap{'INTRANET_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs');
797 $dirmap{'OPAC_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'cgi-bin');
798 $dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs', 'opac-tmpl');
799 $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs');
800 $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir(@basedir, $package, 'lib');
801 $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc');
802 $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'zebradb');
803 $dirmap{'EXAMPLE_DIR'} = File::Spec->catdir(@basedir, $package, 'example');
804 $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
805 $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
806 $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
807 $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
808 $dirmap{'LOG_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'log');
809 $dirmap{'ZEBRA_DATA_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lib', 'zebradb');
810 $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'run', 'zebradb');
811 } elsif ($mode eq 'dev') {
812 my $curdir = File::Spec->rel2abs(File::Spec->curdir());
813 $dirmap{'INTRANET_CGI_DIR'} = File::Spec->catdir($curdir);
814 $dirmap{'INTRANET_TMPL_DIR'} = File::Spec->catdir($curdir, 'koha-tmpl', 'intranet-tmpl');
815 $dirmap{'INTRANET_WWW_DIR'} = File::Spec->catdir($curdir, 'koha-tmpl', 'intranet-tmpl');
816 $dirmap{'OPAC_CGI_DIR'} = File::Spec->catdir($curdir, 'opac');
817 $dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir($curdir, 'koha-tmpl', 'opac-tmpl');
818 $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir($curdir, 'koha-tmpl', 'opac-tmpl');
819 $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir($curdir);
820 $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc');
821 $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'zebradb');
822 $dirmap{'EXAMPLE_DIR'} = File::Spec->catdir(@basedir, $package, 'example');
823 $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
824 $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
825 $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
826 $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
827 $dirmap{'LOG_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'log');
828 $dirmap{'ZEBRA_DATA_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lib', 'zebradb');
829 $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'run', 'zebradb');
831 # mode is standard, i.e., 'fhs'
832 $dirmap{'INTRANET_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'cgi-bin');
833 $dirmap{'INTRANET_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs', 'intranet-tmpl');
834 $dirmap{'INTRANET_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs');
835 $dirmap{'OPAC_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'cgi-bin');
836 $dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs', 'opac-tmpl');
837 $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs');
838 $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir(@basedir, $package, 'lib');
839 $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package);
840 $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package, 'zebradb');
841 $dirmap{'EXAMPLE_DIR'} = File::Spec->catdir(@basedir, $package, 'example');
842 $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
843 $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
844 $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
845 $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lock', $package, 'zebradb');
846 $dirmap{'LOG_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'log', $package);
847 $dirmap{'ZEBRA_DATA_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lib', $package, 'zebradb');
848 $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'run', $package, 'zebradb');
851 _get_argv_overrides(\%dirmap);
856 sub _get_argv_overrides {
860 for (my $i = 0; $i <= $#ARGV; $i++) {
861 if ($ARGV[$i] =~ /^([^=]+)=([^=]+)$/ and exists $dirmap->{$1}) {
864 push @new_argv, $ARGV[$i];
870 sub display_configuration {
873 print "\n\nKoha will be installed with the following configuration parameters:\n\n";
874 foreach my $key (sort keys %$config) {
875 print sprintf("%-25.25s%s\n", $key, $config->{$key});
878 print "\nand in the following directories:\n\n";
879 foreach my $key (sort keys %$dirmap) {
880 print sprintf("%-25.25s%s\n", $key, $dirmap->{$key});
882 print "\n\nTo change any configuration setting, please run\n";
883 print "perl Makefile.PL again. To override one of the target\n";
884 print "directories, you can do so on the command line like this:\n";
885 print "\nperl Makefile.PL PERL_MODULE_DIR=/usr/share/perl/5.8\n\n";
892 my $test = $self->SUPER::test(@_);
893 $test =~ s!\$\(INST_LIB\)!blib/PERL_MODULE_DIR!g;
900 # NOTE: we're *not* doing this: my $install = $self->SUPER::install(@_);
901 # This means that we're completely overriding EU::MM's default
902 # installation and uninstallation targets.
903 foreach my $key (sort keys %target_directories) {
905 KOHA_INST_$key = blib/$key
906 KOHA_DEST_$key = $target_directories{$key}
911 install :: all install_koha
912 \t\$(NOECHO) \$(NOOP)
914 $install .= "install_koha ::\n";
915 $install .= "\t\$(NOECHO) umask 022; \$(MOD_INSTALL) \\\n";
916 foreach my $key (sort keys %target_directories) {
917 $install .= "\t\t\$(KOHA_INST_$key) \$(KOHA_DEST_$key) \\\n";
919 $install .= "\t\t\$(INST_MAN1DIR) \$(DESTINSTALLMAN1DIR) \\\n";
920 $install .= "\t\t\$(INST_MAN3DIR) \$(DESTINSTALLMAN3DIR)\n";
925 # put directory mappings into Makefile
926 # so that Make will export as environment
927 # variables -- this is for the use of
929 my $env = join("\n", map { "export __${_}__ = $target_directories{$_}" } keys %target_directories);
931 $env .= join("\n", map { "export __${_}__ = $config{$_}" } keys %config);
940 ExtUtils::MakeMaker(3)
944 MJ Ray mjr at phonecoop.coop
947 FIXME: Zebra lang/MARC mapping
948 FIXME: deal with .htaccess