Working on the installer setting up the right zebra config
[koha.git] / Makefile.PL
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
20 #
21 # 2007-11-05 Corrected CGI copy to include entire 'installer' subdir structure. -fbcit
22 use ExtUtils::MakeMaker;
23 use POSIX;
24
25 die "perl 5.6.1 or later required" unless ($] >= 5.006001);
26
27 =head1 NAME
28
29 Makefile.PL - Koha packager and installer
30
31 =head1 SYNOPSIS
32
33 =head2 BASIC INSTALLATION
34
35         perl Makefile.PL
36         make
37         sudo make install
38
39 =head2 PACKAGING RELEASE TARBALLS
40
41         make manifest tardist
42         make manifest zipdist
43
44 =head2 CLEANING UP
45
46         make clean
47
48 =head1 DESCRIPTION
49
50 This is a packager and installer that uses
51 ExtUtils::MakeMaker, which is fairly common
52 on perl systems.
53 As well as building tar or zip files
54 and installing with the above commands,
55 it allows us to check pre-requisites
56 and generate configuration files.
57
58 =head1 VARIABLES
59
60 =head2 NAME, VERSION_FROM, ABSTRACT, AUTHOR
61
62 Basic metadata about this software.
63
64 =head2 NO_META
65
66 Suppress generation of META.yml file.
67
68 =head2 PREREQ_PM
69
70 Hash of perl modules and versions required.
71
72 =head2 PM
73
74 Hash of file mappings
75
76 =head2 CONFIGURE
77
78 Maybe use prompt() here in future to get configuration values 
79 interactively at installation time.
80
81 =head2 PL_FILES
82
83 This is a hash of PL scripts to run after installation and
84 the files to ask them to generate.
85 Maybe use the values from CONFIGURE
86 to generate initial configuration files in future.
87
88 =cut
89
90 my $message = "What version of MARC marc21 or unimarc?";
91 my $marc_value = prompt($message);
92 $message = "Which language fr or en?";
93 my $lang_value = prompt($message);
94
95 WriteMakefile(
96
97     NAME => 'koha',
98     #VERSION => strftime('2.9.%Y%m%d%H',gmtime),
99     VERSION_FROM => 'C4/Context.pm',
100     ABSTRACT => 'Award-winning integrated library system (ILS) and Web OPAC',
101     AUTHOR => 'Koha Developers <koha-devel@nongnu.org>',
102     NO_META => 1,
103     PREREQ_PM => {
104 'Biblio::EndnoteStyle' => 0.05,
105 'CGI' => 3.15,
106 'CGI::Carp' => 1.29,
107 'CGI::Session' => '4.10',
108 'Class::Factory::Util' => 1.7,
109 'Class::Accessor' => 0.30,
110 'DBD::mysql' => 3.0008,
111 'DBI' => 1.53,
112 'Data::Dumper' => 2.121_08,
113 'Date::Calc' => 5.4,
114 'Date::Manip' => 5.44,
115 'Digest::MD5' => 2.36,
116 'File::Temp' => 0.16,
117 'GD::Barcode::UPCE' => 1.1,
118 'Getopt::Long' => 2.35,
119 'Getopt::Std' => 1.05,
120 'HTML::Template::Pro' => 0.65,
121 'HTTP::Cookies' => 1.39,
122 'HTTP::Request::Common' => 1.26,
123 'LWP::Simple' => 1.41,
124 'LWP::UserAgent' => 2.033,
125 'Lingua::Stem' => 0.82,
126 'List::Util' => 1.18,
127 'Locale::Language' => 2.07,
128 'MARC::Charset' => 0.98,
129 'MARC::Crosswalk::DublinCore' => 0.03,
130 'MARC::File::XML' => 0.88,
131 'MARC::Record' => 2.00,
132 'MARC::Crosswalk::DublinCore' => 0.02,
133 'MIME::Base64' => 3.07,
134 'MIME::QuotedPrint' => 3.07,
135 'Mail::Sendmail' => 0.79,
136 'Net::Z3950::ZOOM' => 1.16,
137 'PDF::API2' => 2.000,
138 'PDF::API2::Page' => 2.000,
139 'PDF::API2::Util' => 2.000,
140 'PDF::Reuse' => 0.33,
141 'PDF::Reuse::Barcode' => 0.05,
142 'POSIX' => 1.09,
143 'Schedule::At' => 1.06,
144 'Term::ANSIColor' => 1.10,
145 'Test' => 1.25,
146 'Test::Harness' => 2.56,
147 'Test::More' => 0.62,
148 'Text::CSV' => 0.01,
149 'Text::CSV_XS' => 0.32,
150 'Text::Wrap' => 2005.082401,
151 'Time::HiRes' => 1.86,
152 'Time::localtime' => 1.02,
153 'Unicode::Normalize' => 0.32,
154 'XML::Dumper' => 0.81,
155 'XML::LibXML' => 1.59,
156 'XML::LibXSLT' => 1.63,
157 'XML::SAX::ParserFactory' => 1.01,
158 'XML::Simple' => 2.14,
159 'XML::RSS' => 1.31,
160         },
161
162         # File tree mapping
163         PM => map_tree(),
164
165         # disable tests
166         'test' => {TESTS => 't/dummy.t'},
167
168 #   CONFIGURE => sub {
169 #     # Ask for options with prompt($question,$default) calls here?
170 #     return { macro => { 'export TEST' => '755' } }
171 #     },
172
173    PL_FILES => { # generator => target(s)
174       'rewrite-config.PL' => [
175          '$(PREFIX)/share/koha/etc/koha-conf.xml',
176          '$(PREFIX)/share/koha/etc/koha-httpd.conf',
177          '$(PREFIX)/share/koha/etc/zebradb/etc/passwd',
178          '$(PREFIX)/share/koha/etc/zebradb/zebra-biblios.cfg',
179          '$(PREFIX)/share/koha/etc/zebradb/zebra-authorities.cfg'
180          ]
181    }
182 #     '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'],
183 #     'misc/koha.conf.PL' => '$(INST_LIBDIR)/../etc/koha.conf',
184 #     'misc/apache-koha.conf.PL' => '$(INST_LIBDIR)/../etc/apache-koha.conf',
185 #     'misc/koha.sql.PL' => '$(INST_LIBDIR)/intranet/scripts/koha.sql',
186 #     'z3950/z3950-daemon-options.PL' => '$(INST_LIBDIR)/intranet/scripts/z3950daemon/z3950-daemon-options',
187 #     # fake target to check permissions
188 #     'misc/chmod.PL' => '$(INST_LIBDIR)/fake-target'
189 #     }
190    # need to set ownerships
191    # need to load koha.sql
192    # need to link koha-httpd.conf
193    # need to start z3950-daemon
194 );
195
196 =head1 FUNCTIONS
197
198 =head2 map_tree
199
200 This function lists all files and where to install each one.
201 It returns a hash reference suitable for the PM variable above.
202
203 =cut
204
205 sub map_tree {
206         my %result => ();
207
208 =pod
209
210 C4/*.pm is copied to perl's lib namespace.
211
212 =cut
213         foreach my $src (glob("C4/*.pm")) {
214                 $result{$src} = '$(INST_LIBDIR)/'.$src;
215         }
216
217 =pod
218
219 CGIs are copied to $(PREFIX)/lib/cgi-bin/koha/
220 and other scripts to koha/
221
222 =cut
223         foreach my $src ("mainpage.pl","help.pl","kohaversion.pl",glob("*/*.pl"),glob("installer/*"),glob("installer/*/*/*/*"),glob("*/*/*.pl"),glob("*/*/*/*.pl")) {
224                 if ($src =~ /(misc|updater|rss)\//) {
225                         $result{$src} = '$(INST_LIBDIR)/koha/'.$src;
226                 } else {
227                         $result{$src} = '$(PREFIX)/lib/cgi-bin/koha/'.$src;
228                 }
229         }
230
231 =pod
232
233 Templates are copied to koha/templates,
234
235 =cut
236         foreach my $src (glob("koha-tmpl/*"),glob("koha-tmpl/intranet-tmpl/*/*/*"),glob("koha-tmpl/intranet-tmpl/*/*/*/*"),glob("koha-tmpl/intranet-tmpl/*/*/*/*/*"),glob("koha-tmpl/opac-tmpl/*/*/*"),glob("koha-tmpl/opac-tmpl/*/*/*/*"),glob("koha-tmpl/opac-tmpl/*/*/*/*/*")) {
237
238 =pod
239
240 excluding non-files and whitespace in filenames.
241
242 =cut
243                 if ((-f $src) && ($src !~ /(\s)/)) {
244                         $result{$src} = '$(INST_LIBDIR)/koha/templates/'.$src;
245                 }
246         }
247         
248 =pod
249
250 etc files are copied to /usr/share/koha/etc/
251
252 =cut
253         # Misc etc to koha/etc
254         foreach my $src (glob("etc/zebradb/*/*/*"),glob("etc/zebradb/*/*"),glob("etc/zebradb/*"),glob("etc/*")) {
255                 if (-f $src) {
256                         $result{$src} = '$(PREFIX)/share/koha/'.$src;
257                 }
258         }
259         
260         # set up zebra with the appropriate language and marc config
261     $result{"etc/zebradb/lang_defs/sort-string-$lang_value.chr"} = '$(PREFIX)/share/koha/etc/zebradb/etc/sort-string-utf.chr';
262     $result{"etc/zebradb/marc_defs/biblios-$marc_value.abs"} = '$(PREFIX)/share/koha/etc/zebradb/biblios/etc/record.abs';
263         $result{"etc/zebradb/marc_defs/authorities-$marc_value.abs"} = '$(PREFIX)/share/koha/etc/zebradb/authorities/etc/record.abs';
264         return \%result;
265 }
266
267 __END__
268
269
270 =head1 SEE ALSO
271
272 ExtUtils::MakeMaker(3)
273
274 =head1 AUTHOR
275
276 MJ Ray mjr at phonecoop.coop
277
278 =cut
279