Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 1073 lines (865 sloc) 38.61 kB
d0cc4b2 New installer and exclusions file
slef authored
1 # Copyright 2007 MJ Ray
2 #
3 # This file is part of Koha.
4 #
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
8 # version.
9 #
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.
13 #
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
17 #
18 # Current maintainer MJR http://mjr.towers.org.uk/
19 # See http://www.koha.org/wiki/?page=KohaInstaller
7d99474 Corrected CGI copy to include entire 'installer' subdir structure
Chris Nighswonger authored
20 #
faaf13a Cleaned up recursion routine a bit
Chris Nighswonger authored
21
5befdd2 installer (part 2): more work
Galen Charlton authored
22 use strict;
23 use warnings;
d0cc4b2 New installer and exclusions file
slef authored
24 use ExtUtils::MakeMaker;
25 use POSIX;
44efd0f installer (part 1): started major changes
Galen Charlton authored
26 use File::Spec;
d0cc4b2 New installer and exclusions file
slef authored
27
5befdd2 installer (part 2): more work
Galen Charlton authored
28 my $DEBUG = 0;
d0cc4b2 New installer and exclusions file
slef authored
29 die "perl 5.6.1 or later required" unless ($] >= 5.006001);
30
faaf13a Cleaned up recursion routine a bit
Chris Nighswonger authored
31 # Hash up directory structure & files beginning with the directory we were called from (should be the base of koha)...
32
33 my $dirtree = hashdir('.');
34 my %result = ();
35
d0cc4b2 New installer and exclusions file
slef authored
36 =head1 NAME
37
38 Makefile.PL - Koha packager and installer
39
40 =head1 SYNOPSIS
41
61190e9 @mjray New installation instructions and release notes.
mjray authored
42 =head2 BASIC INSTALLATION
43
faaf13a Cleaned up recursion routine a bit
Chris Nighswonger authored
44 perl Makefile.PL
d96ae00 ytpo fixes in description and variables
slef authored
45 make
46 sudo make install
61190e9 @mjray New installation instructions and release notes.
mjray authored
47
48 =head2 PACKAGING RELEASE TARBALLS
49
d96ae00 ytpo fixes in description and variables
slef authored
50 make manifest tardist
51 make manifest zipdist
d0cc4b2 New installer and exclusions file
slef authored
52
61190e9 @mjray New installation instructions and release notes.
mjray authored
53 =head2 CLEANING UP
54
55 make clean
56
d0cc4b2 New installer and exclusions file
slef authored
57 =head1 DESCRIPTION
58
44efd0f installer (part 1): started major changes
Galen Charlton authored
59 This is a packager and installer that uses
d0cc4b2 New installer and exclusions file
slef authored
60 ExtUtils::MakeMaker, which is fairly common
61 on perl systems.
62 As well as building tar or zip files
61190e9 @mjray New installation instructions and release notes.
mjray authored
63 and installing with the above commands,
d0cc4b2 New installer and exclusions file
slef authored
64 it allows us to check pre-requisites
65 and generate configuration files.
66
67 =head1 VARIABLES
68
e449c13 @mjray Add configuration file helper to the installer
mjray authored
69 =head2 NAME, VERSION_FROM, ABSTRACT, AUTHOR
d0cc4b2 New installer and exclusions file
slef authored
70
71 Basic metadata about this software.
72
73 =head2 NO_META
74
75 Suppress generation of META.yml file.
76
77 =head2 PREREQ_PM
78
79 Hash of perl modules and versions required.
80
81 =head2 PM
82
83 Hash of file mappings
84
85 =head2 PL_FILES
86
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
61190e9 @mjray New installation instructions and release notes.
mjray authored
90 to generate initial configuration files in future.
d0cc4b2 New installer and exclusions file
slef authored
91
92 =cut
93
44efd0f installer (part 1): started major changes
Galen Charlton authored
94 =head2 target_map
4b1d132 More work on the installer, just have to fix make now
Chris Cormack authored
95
44efd0f installer (part 1): started major changes
Galen Charlton authored
96 This is a hash mapping directories and files in the
97 source tree to installation target directories. The rules
98 for this mapping are:
4b1d132 More work on the installer, just have to fix make now
Chris Cormack authored
99
44efd0f installer (part 1): started major changes
Galen Charlton authored
100 =over 4
677f10b Working on the installer setting up the right zebra config
Chris Cormack authored
101
44efd0f installer (part 1): started major changes
Galen Charlton authored
102 =item If a directory or file is specified, it and its
103 contents will be copied to the installation target directory.
104
105 =item If a subdirectory of a mapped directory is specified,
106 its target overrides the parent's target for that subdirectory.
107
108 =item The value of each map entry may either be a scalar containing
c31b5c2 installer: moved web template dirs; got rid of multi-targets
Galen Charlton authored
109 one target or a reference to a hash containing 'target' and 'trimdir'
110 keys.
44efd0f installer (part 1): started major changes
Galen Charlton authored
111
112 =item Any files at the top level of the source tree that are
113 not included in the map will not be installed.
114
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
5befdd2 installer (part 2): more work
Galen Charlton authored
122 is to make the C<$target_map> hash as minimal as possible.
44efd0f installer (part 1): started major changes
Galen Charlton authored
123
124 =back
125
126 The permitted installation targets are:
127
128 =over 4
129
130 =item INTRANET_CGI_DIR
131
132 CGI scripts for intranet (staff) interface.
133
134 =item INTRANET_TMPL_DIR
135
136 HTML templates for the intranet interface.
137
138 =item INTRANET_WWW_DIR
139
140 HTML files, images, etc. for DocumentRoot for the intranet interface.
141
142 =item OPAC_CGI_DIR
143
144 CGI scripts for OPAC (public) interface.
145
146 =item OPAC_TMPL_DIR
147
148 HTML templates for the OPAC interface.
149
150 =item OPAC_WWW_DIR
151
152 HTML files, images, etc. for DocumentRoot for the OPAC interface.
153
154 =item PERL_MODULE_DIR
155
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.
160
161 =item KOHA_CONF_DIR
162
163 Directory for Koha configuration files.
164
165 =item ZEBRA_CONF_DIR
166
167 Directory for Zebra configuration files.
168
5befdd2 installer (part 2): more work
Galen Charlton authored
169 =item ZEBRA_LOCK_DIR
170
171 Directory for Zebra's lock files.
172
173 =item ZEBRA_DATA_DIR
174
175 Directory for Zebra's data files.
176
177 =item ZEBRA_RUN_DIR
178
179 Directory for Zebra's UNIX-domain sockets.
180
1b71360 installer: various changes
Galen Charlton authored
181 =item MISC_DIR
5befdd2 installer (part 2): more work
Galen Charlton authored
182
1b71360 installer: various changes
Galen Charlton authored
183 Directory for for miscellaenous scripts, among other
184 things the translation toolkit and RSS feed tools.
5befdd2 installer (part 2): more work
Galen Charlton authored
185
186 =item SCRIPT_DIR
187
188 Directory for command-line scripts and daemons.
189
190 =item MAN_DIR
191
192 Directory for man pages created from POD -- will mostly
193 contain information of interest to Koha developers.
194
195 =item DOC_DIR
196
197 Directory for Koha documentation accessed from the
198 command-line, e.g., READMEs.
199
200 =item LOG_DIR
201
202 Directory for Apache and Zebra logs produced by Koha.
203
44efd0f installer (part 1): started major changes
Galen Charlton authored
204 =item NONE
205
206 This is a dummy target used to explicitly state
207 that a given file or directory is not to be installed.
208 This is used either for parts of the installer itself
209 or for development tools that are not applicable to a
210 production installation.
211
212 =back
213
214 =cut
215
5befdd2 installer (part 2): more work
Galen Charlton authored
216 my $target_map = {
217 './about.pl' => 'INTRANET_CGI_DIR',
218 './acqui' => 'INTRANET_CGI_DIR',
219 './admin' => 'INTRANET_CGI_DIR',
220 './authorities' => 'INTRANET_CGI_DIR',
221 './C4' => 'PERL_MODULE_DIR',
222 './C4/SIP/t' => 'NONE',
223 './C4/SIP/koha_test' => 'NONE',
224 './C4/tests' => 'NONE',
225 './catalogue' => 'INTRANET_CGI_DIR',
226 './cataloguing' => 'INTRANET_CGI_DIR',
c31b5c2 installer: moved web template dirs; got rid of multi-targets
Galen Charlton authored
227 './changelanguage.pl' => 'INTRANET_CGI_DIR',
5befdd2 installer (part 2): more work
Galen Charlton authored
228 './check_sysprefs.pl' => 'NONE',
229 './circ' => 'INTRANET_CGI_DIR',
230 './edithelp.pl' => 'INTRANET_CGI_DIR',
231 './etc' => { target => 'KOHA_CONF_DIR', trimdir => -1 },
232 './etc/zebradb' => { target => 'ZEBRA_CONF_DIR', trimdir => -1 },
1b71360 installer: various changes
Galen Charlton authored
233 './help.pl' => 'INTRANET_CGI_DIR',
5befdd2 installer (part 2): more work
Galen Charlton authored
234 './installer-CPAN.pl' => 'NONE',
235 './installer' => 'INTRANET_CGI_DIR',
c31b5c2 installer: moved web template dirs; got rid of multi-targets
Galen Charlton authored
236 './koha-tmpl/errors' => {target => 'INTRANET_CGI_DIR', trimdir => 2},
5befdd2 installer (part 2): more work
Galen Charlton authored
237 './koha-tmpl/intranet-tmpl' => {target => 'INTRANET_TMPL_DIR', trimdir => -1},
c31b5c2 installer: moved web template dirs; got rid of multi-targets
Galen Charlton authored
238 './koha-tmpl/opac-tmpl' => {target => 'OPAC_TMPL_DIR', trimdir => -1},
1b71360 installer: various changes
Galen Charlton authored
239 './kohaversion.pl' => 'INTRANET_CGI_DIR',
5befdd2 installer (part 2): more work
Galen Charlton authored
240 './labels' => 'INTRANET_CGI_DIR',
241 './mainpage.pl' => 'INTRANET_CGI_DIR',
242 './Makefile.PL' => 'NONE',
243 './MANIFEST.SKIP' => 'NONE',
244 './members' => 'INTRANET_CGI_DIR',
245 './misc' => { target => 'SCRIPT_DIR', trimdir => -1 },
246 './misc/info' => { target => 'DOC_DIR', trimdir => 2 },
247 './misc/release notes' => { target => 'DOC_DIR', trimdir => 2 },
1b71360 installer: various changes
Galen Charlton authored
248 './misc/translator' => { target => 'MISC_DIR', trimdir => 2 },
5befdd2 installer (part 2): more work
Galen Charlton authored
249 './misc/installer_devel_notes' => 'NONE',
250 './opac' => 'OPAC_CGI_DIR',
251 './README.txt' => 'NONE',
252 './reports' => 'INTRANET_CGI_DIR',
253 './reserve' => 'INTRANET_CGI_DIR',
254 './reviews' => 'INTRANET_CGI_DIR',
255 './rewrite-config.PL' => 'NONE',
256 './reviews' => 'INTRANET_CGI_DIR',
1b71360 installer: various changes
Galen Charlton authored
257 './rss' => 'MISC_DIR',
5befdd2 installer (part 2): more work
Galen Charlton authored
258 './serials' => 'INTRANET_CGI_DIR',
190a7f4 installer: created skel directory
Galen Charlton authored
259 './skel' => 'NONE',
ca8f75e installer: KOHA_LOG_DIR => LOG_DIR
Galen Charlton authored
260 './skel/var/log/koha' => { target => 'LOG_DIR', trimdir => -1 },
190a7f4 installer: created skel directory
Galen Charlton authored
261 './skel/var/run/koha/zebradb' => { target => 'ZEBRA_RUN_DIR', trimdir => -1 },
262 './skel/var/lock/koha/zebradb/authorities' => { target => 'ZEBRA_LOCK_DIR', trimdir => 6 },
263 './skel/var/lib/koha/zebradb/authorities/key' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
264 './skel/var/lib/koha/zebradb/authorities/register' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
265 './skel/var/lib/koha/zebradb/authorities/shadow' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
266 './skel/var/lib/koha/zebradb/authorities/tmp' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
267 './skel/var/lock/koha/zebradb/biblios' => { target => 'ZEBRA_LOCK_DIR', trimdir => 6 },
268 './skel/var/lib/koha/zebradb/biblios/key' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
269 './skel/var/lib/koha/zebradb/biblios/register' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
270 './skel/var/lib/koha/zebradb/biblios/shadow' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
271 './skel/var/lib/koha/zebradb/biblios/tmp' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 },
5befdd2 installer (part 2): more work
Galen Charlton authored
272 './sms' => 'INTRANET_CGI_DIR',
273 './suggestion' => 'INTRANET_CGI_DIR',
274 './svc' => 'INTRANET_CGI_DIR',
275 './t' => 'NONE',
1b71360 installer: various changes
Galen Charlton authored
276 './tmp' => 'NONE', # FIXME need to determine whether
277 # Koha generates any persistent temp files
278 # that should go in /var/tmp/koha
5befdd2 installer (part 2): more work
Galen Charlton authored
279 './tools' => 'INTRANET_CGI_DIR',
280 './virtualshelves' => 'INTRANET_CGI_DIR',
281 # ignore files and directories created by the install itself
282 './pm_to_blib' => 'NONE',
283 './blib' => 'NONE',
284 };
44efd0f installer (part 1): started major changes
Galen Charlton authored
285
286 =head1 CONFIGURATION OPTIONS
287
288 The following configuration options are used by the installer.
289
290 =over 4
291
292 =item INSTALL_MODE
293
294 Specifies whether installation will be FHS-compliant (default,
295 assumes user has root), put everything under
296 a single directory (for users installing on a web host
297 that allows CGI scripts and a MySQL database but not root
298 access), or development (for a developer who wants to run
299 Koha from a git clone with no fuss).
300
301 =item INSTALL_BASE
d0cc4b2 New installer and exclusions file
slef authored
302
44efd0f installer (part 1): started major changes
Galen Charlton authored
303 Directory under which most components will go. Default
304 value will vary depending on INSTALL_MODE.
305
1b71360 installer: various changes
Galen Charlton authored
306 =item DB_TYPE
307
308 Type of DBMS (e.g., mysql or Pg).
309
310 =item DB_HOST
311
312 Name of DBMS server.
313
314 =item DB_PORT
315
316 Port that DBMS server is listening on.
317
318 =item DB_NAME
319
320 Name of the DBMS database for Koha.
321
322 =item DB_USER
323
324 Name of DBMS user account for Koha's database.
325
326 =item DB_PASS
327
328 Pasword of DMBS user account for Koha's database.
329
44efd0f installer (part 1): started major changes
Galen Charlton authored
330 =item INSTALL_ZEBRA
331
332 Whether to install Zebra configuration files and data
333 directories.
334
335 =item ZEBRA_MARC_FORMAT
336
337 Specifies format of MARC records to be indexed by Zebra.
338
339 =item ZEBRA_LANGUAGE
340
341 Specifies primary language of records that will be
342 indexed by Zebra.
343
1b71360 installer: various changes
Galen Charlton authored
344 =item ZEBRA_USER
345
346 Internal Zebra user account for the index.
347
348 =item ZEBRA_PASS
349
350 Internal Zebra user account's password.
351
352 =item KOHA_USER
353
354 System user account that will own Koha's files.
355
356 =item KOHA_GROUP
357
358 System group that will own Koha's files.
359
44efd0f installer (part 1): started major changes
Galen Charlton authored
360 =back
361
362 =cut
363
364 # default configuration options
365 my %config_defaults = (
366 'INSTALL_MODE' => 'standard',
367 'INSTALL_BASE' => '/usr/share/koha',
bd0877f installer: prompt for more configuration parameters
Galen Charlton authored
368 'DB_TYPE' => 'mysql',
369 'DB_HOST' => 'localhost',
370 'DB_NAME' => 'koha',
371 'DB_USER' => 'kohaadmin',
372 'DB_PASS' => 'katikoan',
44efd0f installer (part 1): started major changes
Galen Charlton authored
373 'INSTALL_ZEBRA' => 'yes',
374 'ZEBRA_MARC_FORMAT' => 'marc21',
375 'ZEBRA_LANGUAGE' => 'en',
bd0877f installer: prompt for more configuration parameters
Galen Charlton authored
376 'ZEBRA_USER' => 'kohauser',
377 'ZEBRA_PASS' => 'zebrastripes',
be79314 installer: start support for non-root file owner
Galen Charlton authored
378 'KOHA_USER' => 'koha',
379 'KOHA_GROUP' => 'koha',
44efd0f installer (part 1): started major changes
Galen Charlton authored
380 );
381
382 # valid values for certain configuration options
383 my %valid_config_values = (
384 'INSTALL_MODE' => { 'standard' => 1, 'single' => 1, 'dev' => 1 },
bd0877f installer: prompt for more configuration parameters
Galen Charlton authored
385 'DB_TYPE' => { 'mysql' => 1, 'Pg' => 1 },
44efd0f installer (part 1): started major changes
Galen Charlton authored
386 'INSTALL_ZEBRA' => { 'yes' => 1, 'no' => 1 },
387 'ZEBRA_MARC_FORMAT' => { 'marc21' => 1, 'unimarc' => 1 }, # FIXME should generate from contents of distributation
388 'ZEBRA_LANGUAGE' => { 'en' => 1, 'fr' => 1 }, # FIXME should generate from contents of distribution
389 );
390
391 my %config = get_configuration(\%config_defaults, \%valid_config_values);
1b71360 installer: various changes
Galen Charlton authored
392 my ($target_directories, $skip_directories) = get_target_directories(\%config);
393 display_configuration(\%config, $target_directories);
5befdd2 installer (part 2): more work
Galen Charlton authored
394 my $file_map = {};
3b58e09 installer: now respects INSTALL_ZEBRA = no
Galen Charlton authored
395 get_file_map($target_map, $dirtree, $file_map, $config{'INSTALL_ZEBRA'} eq "yes" ? 1: 0);
396
397 my $pl_files = {
398 'rewrite-config.PL' => [
399 'blib/KOHA_CONF_DIR/koha-conf.xml',
400 'blib/KOHA_CONF_DIR/koha-httpd.conf',
401 ]
402 };
403
404 if ($config{'INSTALL_ZEBRA'} eq "yes") {
405 push @{ $pl_files->{'rewrite-config.PL'} }, (
406 'blib/ZEBRA_CONF_DIR/etc/passwd',
407 'blib/ZEBRA_CONF_DIR/zebra-biblios.cfg',
408 'blib/ZEBRA_CONF_DIR/zebra-authorities.cfg'
409 );
410 }
44efd0f installer (part 1): started major changes
Galen Charlton authored
411
412 WriteMakefile(
d0cc4b2 New installer and exclusions file
slef authored
413 NAME => 'koha',
e449c13 @mjray Add configuration file helper to the installer
mjray authored
414 #VERSION => strftime('2.9.%Y%m%d%H',gmtime),
1b71360 installer: various changes
Galen Charlton authored
415 VERSION_FROM => 'kohaversion.pl',
d0cc4b2 New installer and exclusions file
slef authored
416 ABSTRACT => 'Award-winning integrated library system (ILS) and Web OPAC',
417 AUTHOR => 'Koha Developers <koha-devel@nongnu.org>',
418 NO_META => 1,
419 PREREQ_PM => {
420 'CGI' => 3.15,
421 'CGI::Carp' => 1.29,
6cdf083 new virtual shelves changes, keyed by biblionumber
Joshua Ferraro authored
422 'CGI::Session' => '4.10',
23325d3 Adding Class::Factory::Util dep
Paul POULAIN authored
423 'Class::Factory::Util' => 1.7,
df38770 Add more modules - listed in about.pl but not "use"d anywhere.
slef authored
424 'Class::Accessor' => 0.30,
425 'DBD::mysql' => 3.0008,
d0cc4b2 New installer and exclusions file
slef authored
426 'DBI' => 1.53,
427 'Data::Dumper' => 2.121_08,
428 'Date::Calc' => 5.4,
429 'Date::Manip' => 5.44,
430 'Digest::MD5' => 2.36,
431 'File::Temp' => 0.16,
432 'GD::Barcode::UPCE' => 1.1,
433 'Getopt::Long' => 2.35,
434 'Getopt::Std' => 1.05,
435 'HTML::Template::Pro' => 0.65,
436 'HTTP::Cookies' => 1.39,
437 'HTTP::Request::Common' => 1.26,
438 'LWP::Simple' => 1.41,
439 'LWP::UserAgent' => 2.033,
440 'Lingua::Stem' => 0.82,
441 'List::Util' => 1.18,
442 'Locale::Language' => 2.07,
45d570e bumped up MARC Perl module requirements
Galen Charlton authored
443 'MARC::Charset' => 0.98,
1bc2813 adding 2 deps to export biblios in dc format
Paul POULAIN authored
444 'MARC::Crosswalk::DublinCore' => 0.03,
45d570e bumped up MARC Perl module requirements
Galen Charlton authored
445 'MARC::File::XML' => 0.88,
446 'MARC::Record' => 2.00,
d0cc4b2 New installer and exclusions file
slef authored
447 'MIME::Base64' => 3.07,
448 'MIME::QuotedPrint' => 3.07,
449 'Mail::Sendmail' => 0.79,
1b71360 installer: various changes
Galen Charlton authored
450 'Net::Z3950::ZOOM' => 1.16,
d0cc4b2 New installer and exclusions file
slef authored
451 'PDF::API2' => 2.000,
452 'PDF::API2::Page' => 2.000,
453 'PDF::API2::Util' => 2.000,
454 'PDF::Reuse' => 0.33,
455 'PDF::Reuse::Barcode' => 0.05,
456 'POSIX' => 1.09,
8fcd2a6 fixing misplaced apostrophe
Joshua Ferraro authored
457 'Schedule::At' => 1.06,
d0cc4b2 New installer and exclusions file
slef authored
458 'Term::ANSIColor' => 1.10,
459 'Test' => 1.25,
460 'Test::Harness' => 2.56,
461 'Test::More' => 0.62,
a740bcd Fixing typo Test::CSV should be Text::CSV
Chris Cormack authored
462 'Text::CSV' => 0.01,
b6421ad Adding Text::CSV_XS dependancy
Paul POULAIN authored
463 'Text::CSV_XS' => 0.32,
d0cc4b2 New installer and exclusions file
slef authored
464 'Text::Wrap' => 2005.082401,
465 'Time::HiRes' => 1.86,
466 'Time::localtime' => 1.02,
467 'Unicode::Normalize' => 0.32,
310fdc3 adding missing dependancies (needed by scheduler & patron import)
Paul POULAIN authored
468 'XML::Dumper' => 0.81,
d0cc4b2 New installer and exclusions file
slef authored
469 'XML::LibXML' => 1.59,
470 'XML::SAX::ParserFactory' => 1.01,
471 'XML::Simple' => 2.14,
3ea77fd adding XML::RSS as mandatory package (to have RSS working)
tipaul authored
472 'XML::RSS' => 1.31,
d0cc4b2 New installer and exclusions file
slef authored
473 },
474
475 # File tree mapping
5befdd2 installer (part 2): more work
Galen Charlton authored
476 PM => $file_map,
477
478 # Man pages generated from POD
1b71360 installer: various changes
Galen Charlton authored
479 INSTALLMAN1DIR => File::Spec->catdir($target_directories->{'MAN_DIR'}, 'man1'),
480 INSTALLMAN3DIR => File::Spec->catdir($target_directories->{'MAN_DIR'}, 'man3'),
d0cc4b2 New installer and exclusions file
slef authored
481
3b58e09 installer: now respects INSTALL_ZEBRA = no
Galen Charlton authored
482 PL_FILES => $pl_files,
483
d0cc4b2 New installer and exclusions file
slef authored
484 );
485
486 =head1 FUNCTIONS
487
faaf13a Cleaned up recursion routine a bit
Chris Nighswonger authored
488 =head2 hashdir
d0cc4b2 New installer and exclusions file
slef authored
489
faaf13a Cleaned up recursion routine a bit
Chris Nighswonger authored
490 This function recurses through the directory structure and builds
491 a hash of hashes containing the structure with arrays holding filenames.
492 This directory hashing routine was taken from BrowserUK @ http://www.perlmonks.org/?node_id=219919
d0cc4b2 New installer and exclusions file
slef authored
493
494 =cut
495
faaf13a Cleaned up recursion routine a bit
Chris Nighswonger authored
496 sub hashdir{
497 my $dir = shift;
498 opendir my $dh, $dir or die $!;
499 my $tree = {}->{$dir} = {};
500 while( my $file = readdir($dh) ) {
61ca8a3 installer: use htdocs instead of www; handle .htaccess
Galen Charlton authored
501 next if $file =~ m/^\.{1,2}/ and $file !~ /^\.htaccess/; # .htaccess is a special case
faaf13a Cleaned up recursion routine a bit
Chris Nighswonger authored
502 my $path = $dir .'/' . $file;
503 $tree->{$file} = hashdir($path), next if -d $path;
504 push @{$tree->{'.'}}, $file;
505 }
506 return $tree;
507 }
d0cc4b2 New installer and exclusions file
slef authored
508
5befdd2 installer (part 2): more work
Galen Charlton authored
509 =head2 get_file_map
510
511 This function combines the target_map and file hash to
512 map each source file to its destination relative to
513 the set of installation targets.
514
515 Output will be a hash mapping from each source file
516 to its destination value, like this:
517
518 'mainpage.pl' => '$(INTRANET_CGI_DIR)/mainpage.pl'
519
520 =cut
521
522 sub get_file_map {
523 my $target_map = shift;
524 my $dirtree = shift;
525 my $file_map = shift;
3b58e09 installer: now respects INSTALL_ZEBRA = no
Galen Charlton authored
526 my $install_zebra = shift;
5befdd2 installer (part 2): more work
Galen Charlton authored
527 my $curr_path = @_ ? shift : ['.'];
528
529 # Traverse the directory tree.
530 # For each file or directory, identify the
531 # most specific match in the target_map
532 foreach my $dir (sort keys %{ $dirtree }) {
533 if ($dir eq '.') {
534 # deal with files in directory
535 foreach my $file (sort @{ $dirtree->{$dir} }) {
536 my $targetdir = undef;
537 my $matchlevel = undef;
538 # first, see if there is a match on this specific
539 # file in the target map
540 my $filepath = join("/", @$curr_path, $file);
541 if (exists $target_map->{$filepath}) {
542 $targetdir = $target_map->{$filepath};
543 $matchlevel = scalar(@$curr_path) + 1;
544 } else {
545 # no match on the specific file; look for
546 # a directory match
547 for (my $i = scalar(@$curr_path) - 1; $i >= 0; $i--) {
548 my $dirpath = join("/", @$curr_path[0..$i]);
549 if (exists $target_map->{$dirpath}) {
550 $targetdir = $target_map->{$dirpath};
551 $matchlevel = $i + 1;
552 last;
553 }
554 }
555 }
556 if (defined $targetdir) {
3b58e09 installer: now respects INSTALL_ZEBRA = no
Galen Charlton authored
557 _add_to_file_map($file_map, $targetdir, $curr_path, $file, $matchlevel, $install_zebra);
5befdd2 installer (part 2): more work
Galen Charlton authored
558 } else {
559 my $path = join("/", @$curr_path);
560 print "failed to map: $path/$file\n" if $DEBUG;
561 }
562 }
563 } else {
564 # dealing with subdirectory
565 push @$curr_path, $dir;
3b58e09 installer: now respects INSTALL_ZEBRA = no
Galen Charlton authored
566 get_file_map($target_map, $dirtree->{$dir}, $file_map, $install_zebra, $curr_path);
5befdd2 installer (part 2): more work
Galen Charlton authored
567 pop @$curr_path;
568 }
569 }
570 }
571
572 sub _add_to_file_map {
573 my $file_map = shift;
574 my $targetdir = shift;
575 my $curr_path = shift;
576 my $file = shift;
577 my $matchlevel = shift;
3b58e09 installer: now respects INSTALL_ZEBRA = no
Galen Charlton authored
578 my $install_zebra = shift;
5befdd2 installer (part 2): more work
Galen Charlton authored
579 my $dest_path = @_ ? shift : $curr_path;
580
581 # The target can be one of the following:
582 # 1. scalar representing target symbol
583 # 2. hash ref containing target and trimdir keys
584 #
585 # Consequently, this routine traverses this structure,
586 # calling itself recursively, until it deals with
587 # all of the scalar target symbols.
c31b5c2 installer: moved web template dirs; got rid of multi-targets
Galen Charlton authored
588 if (ref $targetdir eq 'HASH') {
5befdd2 installer (part 2): more work
Galen Charlton authored
589 my $subtarget = $targetdir->{target};
590 if (exists $targetdir->{trimdir}) {
591 # if we get here, we've specified that
592 # rather than installing the file to
593 # $(TARGET)/matching/dirs/subdirs/file,
594 # we want to install it to
595 # $(TARGET)/subdirs/file
596 #
597 # Note that this the only place where
598 # $matchlevel is used.
599 my @new_dest_path = @$dest_path;
600 if ($targetdir->{trimdir} == -1) {
601 splice @new_dest_path, 0, $matchlevel;
602 } else {
603 splice @new_dest_path, 0, $targetdir->{trimdir};
604 }
3b58e09 installer: now respects INSTALL_ZEBRA = no
Galen Charlton authored
605 _add_to_file_map($file_map, $subtarget, $curr_path, $file, $matchlevel, $install_zebra, \@new_dest_path);
5befdd2 installer (part 2): more work
Galen Charlton authored
606 } else {
607 # actually getting here means that the
608 # target was unnecessarily listed
609 # as a hash, but we'll forgive that
3b58e09 installer: now respects INSTALL_ZEBRA = no
Galen Charlton authored
610 _add_to_file_map($file_map, $subtarget, $curr_path, $file, $matchlevel, $install_zebra);
5befdd2 installer (part 2): more work
Galen Charlton authored
611 }
612 } elsif ($targetdir ne 'NONE' and $targetdir ne '') {
613 my $source = File::Spec->catfile(@$curr_path, $file);
614 my $destination = File::Spec->catfile('blib', $targetdir, @$dest_path, $file);
615 #print "$source => $destination\n"; # DEBUG
eebd56b install: handle spaces in file names
Galen Charlton authored
616 # quote spaces in file names
617 # FIXME: this is of questionable portability and
618 # probably depends on user's make recognizing this
619 # quoting syntax -- probably better to remove
620 # spaces and shell metacharacters from all file names
621 $source =~ s/ /\\ /g;
622 $destination =~ s/ /\\ /g;
3b58e09 installer: now respects INSTALL_ZEBRA = no
Galen Charlton authored
623
624 $file_map->{$source} = $destination unless (!$install_zebra and $targetdir =~ /ZEBRA/);
5befdd2 installer (part 2): more work
Galen Charlton authored
625 }
626 }
627
44efd0f installer (part 1): started major changes
Galen Charlton authored
628 =head2 get_configuration_options
629
630 This prompts the user for various configuration options.
631
632 =cut
633
634 sub get_configuration {
635 my $defaults = shift;
636 my $valid_values = shift;
637 my %config = ();
638
639 my $msg = q(
640 By default, Koha can be installed in one of three ways:
641
642 standard: Install files in conformance with the Filesystem
643 Hierarchy Standard (FHS). This is the default mode
644 and should be used when installing a production
645 Koha system. On Unix systems, root access is
646 needed to complete a standard installation.
647
648 single: Install files under a single directory. This option
649 is useful for installing Koha without root access, e.g.,
650 on a web host that allows CGI scripts and MySQL databases
651 but requires the user to keep all files under the user's
652 HOME directory.
653
654 dev: Create a set of symbolic links and configuration files to
655 allow Koha to run directly from the source distribution.
656 This mode is useful for developers who want to run
657 Koha from a git clone.
658
d7a09ca installer: modified wording of some questions
Galen Charlton authored
659 Installation mode);
44efd0f installer (part 1): started major changes
Galen Charlton authored
660 $msg .= _add_valid_values_disp('INSTALL_MODE', $valid_values);
661 $config{'INSTALL_MODE'} = _get_value('INSTALL_MODE', $msg, $defaults->{'INSTALL_MODE'}, $valid_values);
662
663 # set message and default value for INSTALL_BASE
664 # depending on value of INSTALL_MODE
665 my $install_base_default = $defaults->{'INSTALL_BASE'};
666 if ($config{'INSTALL_MODE'} eq 'dev') {
667 $msg = q(
668 Please specify the directory in which to install Koha's
669 active configuration files and (if applicable) the
670 Zebra database. Koha's CGI scripts and templates will
d7a09ca installer: modified wording of some questions
Galen Charlton authored
671 be run from the current directory.
672
673 Configuration directory:);
44efd0f installer (part 1): started major changes
Galen Charlton authored
674 # FIXME - home directory portability consideration apply
675 $install_base_default = (exists $ENV{'HOME'}) ? "$ENV{'HOME'}/koha-dev" : "/usr/share/koha-dev";
676 } elsif ($config{'INSTALL_MODE'} eq 'single') {
677 $msg = "\nPlease specify the directory in which to install Koha";
678 # FIXME -- we're assuming under a 'single' mode install
679 # that user will likely want to install under the home
680 # directory. This is OK in and of itself, but we should
681 # use File::HomeDir to locate the home directory portably.
682 # This is deferred for now because File::HomeDir is not yet
683 # core.
684 $install_base_default = (exists $ENV{'HOME'}) ? "$ENV{'HOME'}/koha" : "/usr/share/koha";
685 } else {
686 # must be standard
687 $msg = q(
688 Please specify the directory under which most Koha files
689 will be installed.
690
691 Note that if you are planning in installing more than
692 one instance of Koha, you may want to modify the last
693 component of the directory path, which will be used
d7a09ca installer: modified wording of some questions
Galen Charlton authored
694 as the package name in the FHS layout.
695
696 Base installation directory);
44efd0f installer (part 1): started major changes
Galen Charlton authored
697 }
698 $config{'INSTALL_BASE'} = _get_value('INSTALL_BASE', $msg, $install_base_default, $valid_values);
5befdd2 installer (part 2): more work
Galen Charlton authored
699 $config{'INSTALL_BASE'} = File::Spec->rel2abs($config{'INSTALL_BASE'});
44efd0f installer (part 1): started major changes
Galen Charlton authored
700
be79314 installer: start support for non-root file owner
Galen Charlton authored
701 if ($config{'INSTALL_MODE'} eq "standard") {
702 $msg = q(
703 Since you are using the 'standard' install
704 mode, you should run 'make install' as root.
705 However, it is recommended that a non-root
706 user (on Unix and Linux platforms) have
707 ownership of Koha's files, including the
708 Zebra indexes if applicable.
709
710 Please specify a user account. This
711 user account does not need to exist
712 right now, but it needs to exist
713 before you run 'make install'. Please
714 note that for security reasons, this
715 user should not be the same as the user
716 account Apache runs under.
717
718 User account);
719 $config{'KOHA_USER'} = _get_value('KOHA_USER', $msg, $defaults->{'KOHA_USER'}, $valid_values);
720
721 $msg = q(
722 Please specify the group that should own
723 Koha's files. As above, this group need
724 not exist right now, but should be created
725 before you run 'make install'.
726
727 Group);
728 $config{'KOHA_GROUP'} = _get_value('KOHA_GROUP', $msg, $defaults->{'KOHA_GROUP'}, $valid_values);
729 }
730
44efd0f installer (part 1): started major changes
Galen Charlton authored
731 $msg = q(
bd0877f installer: prompt for more configuration parameters
Galen Charlton authored
732 Please specify which database engine you will use
733 to store data in Koha. The choices are MySQL and
734 PostgreSQL; please note that at the moment
735 PostgreSQL support is highly experimental.
736
737 DBMS to use);
738 $msg .= _add_valid_values_disp('DB_TYPE', $valid_values);
739 $config{'DB_TYPE'} = _get_value('DB_TYPE', $msg, $defaults->{'DB_TYPE'}, $valid_values);
740
741 $msg = q(
742 Please specify the name or address of your
743 database server. Note that the database
744 does not have to exist at this point, it
745 can be created after running 'make install'
746 and before you try using Koha for the first time.
747
748 Database server);
749 $config{'DB_HOST'} = _get_value('DB_HOST', $msg, $defaults->{'DB_HOST'}, $valid_values);
750
751 $msg = q(
752 Please specify the port used to connect to the
753 DMBS);
754 my $db_port_default = $config{'DB_TYPE'} eq 'mysql' ? '3306' : '5432';
755 $config{'DB_PORT'} = _get_value('DB_PORT', $msg, $db_port_default, $valid_values);
756
757 $msg = q(
758 Please specify the name of the database to be
759 used by Koha);
760 $config{'DB_NAME'} = _get_value('DB_NAME', $msg, $defaults->{'DB_NAME'}, $valid_values);
761
762 $msg = q(
763 Please specify the user that owns the database to be
764 used by Koha);
765 $config{'DB_USER'} = _get_value('DB_USER', $msg, $defaults->{'DB_USER'}, $valid_values);
766
767 $msg = q(
768 Please specify the password of the user that owns the
769 database to be used by Koha);
770 $config{'DB_PASS'} = _get_value('DB_PASS', $msg, $defaults->{'DB_PASS'}, $valid_values);
771
772 $msg = q(
44efd0f installer (part 1): started major changes
Galen Charlton authored
773 Koha can use the Zebra search engine for high-performance
774 searching of bibliographic and authority records. If you
775 have installed the Zebra software and would like to use it,
776 please answer 'yes' to the following question. Otherwise,
777 Koha will default to using its internal search engine.
778
3b58e09 installer: now respects INSTALL_ZEBRA = no
Galen Charlton authored
779 Please note that if you choose *NOT* to install Zebra,
780 koha-conf.xml will still contain some references to Zebra
781 settings. Those references will be ignored by Koha.
782
d7a09ca installer: modified wording of some questions
Galen Charlton authored
783 Install the Zebra configuration files?);
44efd0f installer (part 1): started major changes
Galen Charlton authored
784 $msg .= _add_valid_values_disp('INSTALL_ZEBRA', $valid_values);
785 $config{'INSTALL_ZEBRA'} = _get_value('INSTALL_ZEBRA', $msg, $defaults->{'INSTALL_ZEBRA'}, $valid_values);
786
787 if ($config{'INSTALL_ZEBRA'} eq 'yes') {
788 $msg = q(
789 Since you've chosen to use Zebra with Koha,
790 you must specify the primary MARC format of the
791 records to be indexed by Zebra.
792
793 Koha provides Zebra configuration files for MARC 21
794 and UNIMARC.
795
d7a09ca installer: modified wording of some questions
Galen Charlton authored
796 MARC format for Zebra indexing);
44efd0f installer (part 1): started major changes
Galen Charlton authored
797 $msg .= _add_valid_values_disp('ZEBRA_MARC_FORMAT', $valid_values);
798 $config{'ZEBRA_MARC_FORMAT'} = _get_value('ZEBRA_MARC_FORMAT', $msg, $defaults->{'ZEBRA_MARC_FORMAT'}, $valid_values);
799 $msg = q(
800 Koha supplies Zebra configuration files tuned for
801 searching either English (en) or French (fr) MARC
802 records.
803
d7a09ca installer: modified wording of some questions
Galen Charlton authored
804 Primary language for Zebra indexing);
44efd0f installer (part 1): started major changes
Galen Charlton authored
805 $msg .= _add_valid_values_disp('ZEBRA_LANGUAGE', $valid_values);
806 $config{'ZEBRA_LANGUAGE'} = _get_value('ZEBRA_LANGUAGE', $msg, $defaults->{'ZEBRA_LANGUAGE'}, $valid_values);
bd0877f installer: prompt for more configuration parameters
Galen Charlton authored
807
808 $msg = q(
809 Please specify Zebra database user);
810 $config{'ZEBRA_USER'} = _get_value('ZEBRA_USER', $msg, $defaults->{'ZEBRA_USER'}, $valid_values);
811
812 $msg = q(
813 Please specify the Zebra database password);
814 $config{'ZEBRA_PASS'} = _get_value('ZEBRA_PASS', $msg, $defaults->{'ZEBRA_PASS'}, $valid_values);
815
44efd0f installer (part 1): started major changes
Galen Charlton authored
816 }
817 return %config;
818 }
819
820 sub _add_valid_values_disp {
821 my $key = shift;
822 my $valid_values = shift;
823
824 my $disp = "";
825 if (exists $valid_values->{$key}) {
826 $disp = " (" . join(", ", sort keys %{ $valid_values->{$key} }) . ")";
827 }
828 return $disp;
829 }
830
831 sub _get_value {
832 my $key = shift;
833 my $msg = shift;
834 my $default = shift;
835 my $valid_values = shift;
836
837 my $val = prompt($msg, $default);
838 while (exists $valid_values->{$key} and not exists $valid_values->{$key}->{$val}) {
839 my $retry_msg = "Value '$val' is not a valid option.\n";
840 $retry_msg .= "Please enter a value";
841 $retry_msg .= _add_valid_values_disp($key, $valid_values);
842 $val = prompt($retry_msg, $default);
843 }
844 return $val;
845 }
846
847 =head2 get_target_directories
848
849 Creates a hash mapping from symbols for installation target
850 directories to actual directory paths.
851
1b71360 installer: various changes
Galen Charlton authored
852 Also returns a hash indicating targets for which
853 files need not be copied -- this is used for the 'dev'
854 mode installation, where some files are installed in place.
855
44efd0f installer (part 1): started major changes
Galen Charlton authored
856 =cut
857
858 sub get_target_directories {
859 my $config = shift;
860
861 my $base = $config->{'INSTALL_BASE'};
862 my $mode = $config->{'INSTALL_MODE'};
863
864 # get last component of install base directory
865 # to treat as package name
866 my ($volume, $directories, $file) = File::Spec->splitpath($base, 1);
867 my @basedir = File::Spec->splitdir($directories);
868 my $package = pop @basedir;
869
870 my %dirmap = ();
1b71360 installer: various changes
Galen Charlton authored
871 my %skipdirs = ();
44efd0f installer (part 1): started major changes
Galen Charlton authored
872 if ($mode eq 'single') {
873 $dirmap{'INTRANET_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'cgi-bin');
c31b5c2 installer: moved web template dirs; got rid of multi-targets
Galen Charlton authored
874 $dirmap{'INTRANET_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs', 'intranet-tmpl');
61ca8a3 installer: use htdocs instead of www; handle .htaccess
Galen Charlton authored
875 $dirmap{'INTRANET_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs');
44efd0f installer (part 1): started major changes
Galen Charlton authored
876 $dirmap{'OPAC_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'cgi-bin');
c31b5c2 installer: moved web template dirs; got rid of multi-targets
Galen Charlton authored
877 $dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs', 'opac-tmpl');
61ca8a3 installer: use htdocs instead of www; handle .htaccess
Galen Charlton authored
878 $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs');
44efd0f installer (part 1): started major changes
Galen Charlton authored
879 $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir(@basedir, $package, 'lib');
880 $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc');
881 $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'zebradb');
1b71360 installer: various changes
Galen Charlton authored
882 $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc');
44efd0f installer (part 1): started major changes
Galen Charlton authored
883 $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
884 $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
885 $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
886 $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
887 $dirmap{'LOG_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'log');
888 $dirmap{'ZEBRA_DATA_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lib', 'zebradb');
5befdd2 installer (part 2): more work
Galen Charlton authored
889 $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'run', 'zebradb');
44efd0f installer (part 1): started major changes
Galen Charlton authored
890 } elsif ($mode eq 'dev') {
891 my $curdir = File::Spec->rel2abs(File::Spec->curdir());
892 $dirmap{'INTRANET_CGI_DIR'} = File::Spec->catdir($curdir);
1b71360 installer: various changes
Galen Charlton authored
893 $skipdirs{'INTRANET_CGI_DIR'} = 1;
44efd0f installer (part 1): started major changes
Galen Charlton authored
894 $dirmap{'INTRANET_TMPL_DIR'} = File::Spec->catdir($curdir, 'koha-tmpl', 'intranet-tmpl');
1b71360 installer: various changes
Galen Charlton authored
895 $skipdirs{'INTRANET_TMPL_DIR'} = 1;
44efd0f installer (part 1): started major changes
Galen Charlton authored
896 $dirmap{'INTRANET_WWW_DIR'} = File::Spec->catdir($curdir, 'koha-tmpl', 'intranet-tmpl');
1b71360 installer: various changes
Galen Charlton authored
897 $skipdirs{'INTRANET_WWW_DIR'} = 1;
44efd0f installer (part 1): started major changes
Galen Charlton authored
898 $dirmap{'OPAC_CGI_DIR'} = File::Spec->catdir($curdir, 'opac');
1b71360 installer: various changes
Galen Charlton authored
899 $skipdirs{'OPAC_CGI_DIR'} = 1;
44efd0f installer (part 1): started major changes
Galen Charlton authored
900 $dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir($curdir, 'koha-tmpl', 'opac-tmpl');
1b71360 installer: various changes
Galen Charlton authored
901 $skipdirs{'OPAC_TMPL_DIR'} = 1;
44efd0f installer (part 1): started major changes
Galen Charlton authored
902 $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir($curdir, 'koha-tmpl', 'opac-tmpl');
1b71360 installer: various changes
Galen Charlton authored
903 $skipdirs{'OPAC_WWW_DIR'} = 1;
44efd0f installer (part 1): started major changes
Galen Charlton authored
904 $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir($curdir);
1b71360 installer: various changes
Galen Charlton authored
905 $skipdirs{'PERL_MODULE_DIR'} = 1;
44efd0f installer (part 1): started major changes
Galen Charlton authored
906 $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc');
907 $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'zebradb');
1b71360 installer: various changes
Galen Charlton authored
908 $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc');
44efd0f installer (part 1): started major changes
Galen Charlton authored
909 $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
1b71360 installer: various changes
Galen Charlton authored
910 $skipdirs{'SCRIPT_DIR'} = 1;
44efd0f installer (part 1): started major changes
Galen Charlton authored
911 $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
912 $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
913 $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb');
914 $dirmap{'LOG_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'log');
915 $dirmap{'ZEBRA_DATA_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lib', 'zebradb');
5befdd2 installer (part 2): more work
Galen Charlton authored
916 $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'run', 'zebradb');
44efd0f installer (part 1): started major changes
Galen Charlton authored
917 } else {
918 # mode is standard, i.e., 'fhs'
919 $dirmap{'INTRANET_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'cgi-bin');
c31b5c2 installer: moved web template dirs; got rid of multi-targets
Galen Charlton authored
920 $dirmap{'INTRANET_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs', 'intranet-tmpl');
61ca8a3 installer: use htdocs instead of www; handle .htaccess
Galen Charlton authored
921 $dirmap{'INTRANET_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'htdocs');
44efd0f installer (part 1): started major changes
Galen Charlton authored
922 $dirmap{'OPAC_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'cgi-bin');
c31b5c2 installer: moved web template dirs; got rid of multi-targets
Galen Charlton authored
923 $dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs', 'opac-tmpl');
61ca8a3 installer: use htdocs instead of www; handle .htaccess
Galen Charlton authored
924 $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs');
44efd0f installer (part 1): started major changes
Galen Charlton authored
925 $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir(@basedir, $package, 'lib');
926 $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package);
927 $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package, 'zebradb');
1b71360 installer: various changes
Galen Charlton authored
928 $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc');
44efd0f installer (part 1): started major changes
Galen Charlton authored
929 $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin');
930 $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man');
931 $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc');
932 $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lock', $package, 'zebradb');
933 $dirmap{'LOG_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'log', $package);
934 $dirmap{'ZEBRA_DATA_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lib', $package, 'zebradb');
5befdd2 installer (part 2): more work
Galen Charlton authored
935 $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'run', $package, 'zebradb');
44efd0f installer (part 1): started major changes
Galen Charlton authored
936 }
937
bd0877f installer: prompt for more configuration parameters
Galen Charlton authored
938 _get_argv_overrides(\%dirmap);
939
1b71360 installer: various changes
Galen Charlton authored
940 return \%dirmap, \%skipdirs;
44efd0f installer (part 1): started major changes
Galen Charlton authored
941 }
942
bd0877f installer: prompt for more configuration parameters
Galen Charlton authored
943 sub _get_argv_overrides {
944 my $dirmap = shift;
945
946 my @new_argv = ();
947 for (my $i = 0; $i <= $#ARGV; $i++) {
948 if ($ARGV[$i] =~ /^([^=]+)=([^=]+)$/ and exists $dirmap->{$1}) {
949 $dirmap->{$1} = $2;
950 } else {
951 push @new_argv, $ARGV[$i];
952 }
953 }
954 @ARGV = @new_argv;
955 }
956
957 sub display_configuration {
958 my $config = shift;
959 my $dirmap = shift;
960 print "\n\nKoha will be installed with the following configuration parameters:\n\n";
961 foreach my $key (sort keys %$config) {
962 print sprintf("%-25.25s%s\n", $key, $config->{$key});
963 }
964
965 print "\nand in the following directories:\n\n";
966 foreach my $key (sort keys %$dirmap) {
967 print sprintf("%-25.25s%s\n", $key, $dirmap->{$key});
968 }
969 print "\n\nTo change any configuration setting, please run\n";
970 print "perl Makefile.PL again. To override one of the target\n";
971 print "directories, you can do so on the command line like this:\n";
972 print "\nperl Makefile.PL PERL_MODULE_DIR=/usr/share/perl/5.8\n\n";
973 }
974
5befdd2 installer (part 2): more work
Galen Charlton authored
975 package MY;
7f01995 installer (part 3): enabled 'make test'
Galen Charlton authored
976
977 sub test {
978 my $self = shift;
979 my $test = $self->SUPER::test(@_);
980 $test =~ s!\$\(INST_LIB\)!blib/PERL_MODULE_DIR!g;
981 return $test;
982 }
983
5befdd2 installer (part 2): more work
Galen Charlton authored
984 sub install {
985 my $self = shift;
986 my $install = "";
987 # NOTE: we're *not* doing this: my $install = $self->SUPER::install(@_);
988 # This means that we're completely overriding EU::MM's default
989 # installation and uninstallation targets.
1b71360 installer: various changes
Galen Charlton authored
990 foreach my $key (sort keys %$target_directories) {
5befdd2 installer (part 2): more work
Galen Charlton authored
991 $install .= qq(
992 KOHA_INST_$key = blib/$key
1b71360 installer: various changes
Galen Charlton authored
993 KOHA_DEST_$key = $target_directories->{$key}
994 ) unless ($config{'INSTALL_ZEBRA'} ne "yes" and $key =~ /ZEBRA/) or exists $skip_directories->{$key};
5befdd2 installer (part 2): more work
Galen Charlton authored
995 }
996
997 $install .= qq(
1b71360 installer: various changes
Galen Charlton authored
998 install :: all install_koha set_koha_ownership set_koha_permissions warn_koha_env_vars
5befdd2 installer (part 2): more work
Galen Charlton authored
999 \t\$(NOECHO) \$(NOOP)
1000 );
1001 $install .= "install_koha ::\n";
1002 $install .= "\t\$(NOECHO) umask 022; \$(MOD_INSTALL) \\\n";
1b71360 installer: various changes
Galen Charlton authored
1003 foreach my $key (sort keys %$target_directories) {
1004 $install .= "\t\t\$(KOHA_INST_$key) \$(KOHA_DEST_$key) \\\n"
1005 unless ($config{'INSTALL_ZEBRA'} ne "yes" and $key =~ /ZEBRA/) or exists $skip_directories->{$key};
5befdd2 installer (part 2): more work
Galen Charlton authored
1006 }
1007 $install .= "\t\t\$(INST_MAN1DIR) \$(DESTINSTALLMAN1DIR) \\\n";
1008 $install .= "\t\t\$(INST_MAN3DIR) \$(DESTINSTALLMAN3DIR)\n";
be79314 installer: start support for non-root file owner
Galen Charlton authored
1009
1010 $install .= "\n";
1011 $install .= "set_koha_ownership ::\n";
1012 if ($config{'INSTALL_MODE'} eq 'standard' and $config{'KOHA_USER'} ne "root") {
1b71360 installer: various changes
Galen Charlton authored
1013 foreach my $key (sort keys %$target_directories) {
1014 $install .= "\t\$(NOECHO) chown -R $config{'KOHA_USER'}:$config{'KOHA_GROUP'} \$(KOHA_DEST_$key)\n"
1015 unless ($config{'INSTALL_ZEBRA'} ne "yes" and $key =~ /ZEBRA/) or exists $skip_directories->{$key};
be79314 installer: start support for non-root file owner
Galen Charlton authored
1016 }
1017 } else {
1018 $install .= "\t\t\$(NOECHO) \$(NOOP)\n\n";
1019 }
1020
1b71360 installer: various changes
Galen Charlton authored
1021 $install .= "\n";
1022 $install .= "set_koha_permissions ::\n";
1023 # This is necessary because EU::MM installs files
1024 # as either 0444 or 0555, and we want the owner
1025 # of Koha's files to have write permission by default.
1026 foreach my $key (sort keys %$target_directories) {
1027 $install .= "\t\$(NOECHO) chmod -R u+w \$(KOHA_DEST_$key)\n"
1028 unless ($config{'INSTALL_ZEBRA'} ne "yes" and $key =~ /ZEBRA/) or exists $skip_directories->{$key};
1029 }
1030 $install .= "\n";
1031
1032 $install .= "warn_koha_env_vars ::\n";
1033 $install .= "\t\$(NOECHO) \$(ECHO)\n";
1034 $install .= "\t\$(NOECHO) \$(ECHO) Koha\\'s files have now been installed. \n";
1035 $install .= "\t\$(NOECHO) \$(ECHO)\n";
1036 $install .= "\t\$(NOECHO) \$(ECHO) In order to use Koha\\'s command-line batch jobs,\n";
1037 $install .= "\t\$(NOECHO) \$(ECHO) you should set the following environment variables:\n";
1038 $install .= "\t\$(NOECHO) \$(ECHO)\n";
1039 $install .= "\t\$(NOECHO) \$(ECHO) export KOHA_CONF=\$(KOHA_DEST_KOHA_CONF_DIR)/koha-conf.xml\n";
1040 $install .= "\t\$(NOECHO) \$(ECHO) export PERL5LIB=$target_directories->{'PERL_MODULE_DIR'}\n";
1041 $install .= "\t\$(NOECHO) \$(ECHO)\n";
1042 $install .= "\t\$(NOECHO) \$(ECHO) For other post-installation tasks, please consult the README.\n";
1043 $install .= "\t\$(NOECHO) \$(ECHO)\n";
1044
5befdd2 installer (part 2): more work
Galen Charlton authored
1045 return $install;
1046 }
1047
1048 sub postamble {
1049 # put directory mappings into Makefile
1050 # so that Make will export as environment
1051 # variables -- this is for the use of
1052 # rewrite-confg.PL
1b71360 installer: various changes
Galen Charlton authored
1053 my $env = join("\n", map { "export __${_}__ = $target_directories->{$_}" } keys %$target_directories);
f3a868f installer: started on Zebra paths
Galen Charlton authored
1054 $env .= "\n\n";
bd0877f installer: prompt for more configuration parameters
Galen Charlton authored
1055 $env .= join("\n", map { "export __${_}__ = $config{$_}" } keys %config);
5befdd2 installer (part 2): more work
Galen Charlton authored
1056 return "$env\n";
1057 }
44efd0f installer (part 1): started major changes
Galen Charlton authored
1058
d0cc4b2 New installer and exclusions file
slef authored
1059 __END__
1060
1061
1062 =head1 SEE ALSO
1063
1064 ExtUtils::MakeMaker(3)
1065
faaf13a Cleaned up recursion routine a bit
Chris Nighswonger authored
1066 =head1 AUTHORS
e449c13 @mjray Add configuration file helper to the installer
mjray authored
1067
1068 MJ Ray mjr at phonecoop.coop
1b71360 installer: various changes
Galen Charlton authored
1069 Galen Charlton galen.charlton at liblime.com
e449c13 @mjray Add configuration file helper to the installer
mjray authored
1070
d0cc4b2 New installer and exclusions file
slef authored
1071 =cut
5befdd2 installer (part 2): more work
Galen Charlton authored
1072 FIXME: deal with .htaccess
Something went wrong with that request. Please try again.