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
22 use ExtUtils::MakeMaker;
25 die "perl 5.6.1 or later required" unless ($] >= 5.006001);
27 # Hash up directory structure & files beginning with the directory we were called from (should be the base of koha)...
29 my $dirtree = hashdir('.');
34 Makefile.PL - Koha packager and installer
38 =head2 BASIC INSTALLATION
44 =head2 PACKAGING RELEASE TARBALLS
55 This is a Packager and installer that uses
56 ExtUtils::MakeMaker, which is fairly common
58 As well as building tar or zip files
59 and installing with the above commands,
60 it allows us to check pre-requisites
61 and generate configuration files.
65 =head2 NAME, VERSION_FROM, ABSTRACT, AUTHOR
67 Basic metadata about this software.
71 Suppress generation of META.yml file.
75 Hash of perl modules and versions required.
83 Maybe use prompt() here in future to get configuration values
84 interactively at installation time.
88 This is a hash of PL scripts to run after installation and
89 the files to ask them to generate.
90 Maybe use the values from CONFIGURE
91 to generate initial configuration files in future.
99 while ($marc_value ne 'marc21' && $marc_value ne 'unimarc'){
100 my $message= "Chose your flavour of MARC, unimarc or marc21 [marc21]";
101 $marc_value=prompt($message) || 'marc21';
103 while ($lang_value ne 'en' && $lang_value ne 'fr'){
104 my $message= "Choose your language, en or fr [en]";
105 $lang_value=prompt($message) || 'en';
111 #VERSION => strftime('2.9.%Y%m%d%H',gmtime),
112 VERSION_FROM => 'C4/Context.pm',
113 ABSTRACT => 'Award-winning integrated library system (ILS) and Web OPAC',
114 AUTHOR => 'Koha Developers <koha-devel@nongnu.org>',
119 'CGI::Session' => '4.10',
120 'Class::Factory::Util' => 1.7,
121 'Class::Accessor' => 0.30,
122 'DBD::mysql' => 3.0008,
124 'Data::Dumper' => 2.121_08,
126 'Date::Manip' => 5.44,
127 'Digest::MD5' => 2.36,
128 'File::Temp' => 0.16,
129 'GD::Barcode::UPCE' => 1.1,
130 'Getopt::Long' => 2.35,
131 'Getopt::Std' => 1.05,
132 'HTML::Template::Pro' => 0.65,
133 'HTTP::Cookies' => 1.39,
134 'HTTP::Request::Common' => 1.26,
135 'LWP::Simple' => 1.41,
136 'LWP::UserAgent' => 2.033,
137 'Lingua::Stem' => 0.82,
138 'List::Util' => 1.18,
139 'Locale::Language' => 2.07,
140 'MARC::Charset' => 0.98,
141 'MARC::Crosswalk::DublinCore' => 0.03,
142 'MARC::File::XML' => 0.88,
143 'MARC::Record' => 2.00,
144 'MIME::Base64' => 3.07,
145 'MIME::QuotedPrint' => 3.07,
146 'Mail::Sendmail' => 0.79,
147 'PDF::API2' => 2.000,
148 'PDF::API2::Page' => 2.000,
149 'PDF::API2::Util' => 2.000,
150 'PDF::Reuse' => 0.33,
151 'PDF::Reuse::Barcode' => 0.05,
153 'Schedule::At' => 1.06,
154 'Term::ANSIColor' => 1.10,
156 'Test::Harness' => 2.56,
157 'Test::More' => 0.62,
159 'Text::CSV_XS' => 0.32,
160 'Text::Wrap' => 2005.082401,
161 'Time::HiRes' => 1.86,
162 'Time::localtime' => 1.02,
163 'Unicode::Normalize' => 0.32,
164 'XML::Dumper' => 0.81,
165 'XML::LibXML' => 1.59,
166 'XML::SAX::ParserFactory' => 1.01,
167 'XML::Simple' => 2.14,
174 PM => unhashdir($dirtree),
177 'test' => {TESTS => 't/dummy.t'},
180 # # Ask for options with prompt($question,$default) calls here?
181 # return { macro => { 'export TEST' => '755' } }
184 PL_FILES => { # generator => target(s)
185 'rewrite-config.PL' => [
186 '$(PREFIX)/share/koha/etc/koha-conf.xml',
187 '$(PREFIX)/share/koha/etc/koha-httpd.conf',
188 '$(PREFIX)/share/koha/etc/zebradb/etc/passwd',
189 '$(PREFIX)/share/koha/etc/zebradb/zebra-biblios.cfg',
190 '$(PREFIX)/share/koha/etc/zebradb/zebra-authorities.cfg'
193 # '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'],
194 # 'misc/koha.conf.PL' => '$(INST_LIBDIR)/../etc/koha.conf',
195 # 'misc/apache-koha.conf.PL' => '$(INST_LIBDIR)/../etc/apache-koha.conf',
196 # 'misc/koha.sql.PL' => '$(INST_LIBDIR)/intranet/scripts/koha.sql',
197 # 'z3950/z3950-daemon-options.PL' => '$(INST_LIBDIR)/intranet/scripts/z3950daemon/z3950-daemon-options',
198 # # fake target to check permissions
199 # 'misc/chmod.PL' => '$(INST_LIBDIR)/fake-target'
201 # need to set ownerships
202 # need to load koha.sql
203 # need to link koha-httpd.conf
204 # need to start z3950-daemon
211 This function recurses through the directory structure and builds
212 a hash of hashes containing the structure with arrays holding filenames.
213 This directory hashing routine was taken from BrowserUK @ http://www.perlmonks.org/?node_id=219919
219 opendir my $dh, $dir or die $!;
220 my $tree = {}->{$dir} = {};
221 while( my $file = readdir($dh) ) {
222 next if $file =~ m/^\.{1,2}/;
223 my $path = $dir .'/' . $file;
224 $tree->{$file} = hashdir($path), next if -d $path;
225 push @{$tree->{'.'}}, $file;
232 This function unhashes the hash of hashes generated by hashdir().
233 This directory unhashing routine is the personal work of Chris Nighswonger (fbcit).
234 Modified here to build koha makefile. It lists all files and where to install each one.
235 It then returns a hash reference suitable for the PM variable above.
241 my $dirlevel = shift;
242 my $toplevel = $dirlevel;
243 for my $k1 ( sort keys %$dirhash ) {
244 if ($k1 ne '.' && $k1 ne '') {
245 $dirlevel = ( $dirlevel ? $dirlevel . '/' . $k1 : $k1 );
246 &unhashdir($dirhash->{ $k1 }, $dirlevel);
247 $dirlevel = $toplevel;
249 elsif ( $k1 eq '.' ) {
250 foreach $file ( @{$dirhash->{ $k1 }} ) {
251 # TODO: There are some hacks here that may be able to be improved... -fbcit
252 if ( $file =~ /^./ ) { next; } # skip hidden files and directories.
254 elsif ( $file =~ /\.pm/ && $dirlevel =~ /C4/ ) { $result{ ($dirlevel ? $dirlevel . '/' . $file : $file) } = '$(INST_LIBDIR)/' . ($dirlevel ? $dirlevel . '/' . $file : $file); } # C4/*.pm is copied to perl's lib namespace.
256 elsif ( $dirlevel !~ /koha-tmpl/ && $dirlevel =~ /(installer|errors)/ ) { $result{ ($dirlevel ? $dirlevel . '/' . $file : $file) } = '$(PREFIX)/lib/cgi-bin/koha/' . ($dirlevel ? $dirlevel . '/' . $file : $file); } # error templates are copied to $(PREFIX)/lib/cgi-bin/koha/
258 elsif ( $dirlevel =~ /koha-tmpl/ && $dirlevel !~ /errors/ ) { $result{ ($dirlevel ? $dirlevel . '/' . $file : $file) } = '$(INST_LIBDIR)/koha/templates/' . ($dirlevel ? $dirlevel . '/' . $file : $file); } # error templates are copied to $(INST_LIBDIR)/koha/templates/
260 elsif ( $dirlevel =~ /(misc|rss)/ ) { $result{ ($dirlevel ? $dirlevel . '/' . $file : $file) } = '$(INST_LIBDIR)/koha/' . ($dirlevel ? $dirlevel . '/' . $file : $file); } # misc & rss are copied to koha,
262 # elsif ( $dirlevel =~ /(intranet-tmpl|opac-tmpl)/ ) { $result{ ($dirlevel ? $dirlevel . '/' . $file : $file) } = '$(INST_LIBDIR)/koha/templates/' . ($dirlevel ? $dirlevel . '/' . $file : $file); } # Templates are copied to koha/templates,
264 elsif ( $file !~ /\.pl/ && $dirlevel =~ /etc/ ) { $result{ ($dirlevel ? $dirlevel . '/' . $file : $file) } = '$(PREFIX)/share/koha/' . ($dirlevel ? $dirlevel . '/' . $file : $file); } # Misc etc to koha/etc
266 elsif ( $file =~ /\.pl/ ) { $result{ ($dirlevel ? $dirlevel . '/' . $file : $file) } = '$(PREFIX)/lib/cgi-bin/koha/' . ($dirlevel ? $dirlevel . '/' . $file : $file); } # CGIs are copied to $(PREFIX)/lib/cgi-bin/koha/ print $result{ ($dirlevel ? $dirlevel . '/' . $file : $file)},"\n\n";
280 ExtUtils::MakeMaker(3)
284 MJ Ray mjr at phonecoop.coop