]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/extras/Makefile.install
Display warning message and prompt before PostgreSQL removal
[Evergreen.git] / Open-ILS / src / extras / Makefile.install
1 # ---------------------------------------------------------------------
2 # Author: Bill Erickson <erickson@esilibrary.com>
3 # Author: Dan Scott <dscott@laurentian.ca>
4 #
5 # Makefile to install prerequisites for OpenSRF and Evergreen
6 #
7 # Currently supports Debian (squeeze), Ubuntu (lucid), and Fedora (14).
8 # Working towards support of CentOS 5 / RHEL 5.
9 # Installs Perl prereqs, libjs with Perl wrapper, libdbi, libdbi-drivers, and libyaz
10 #
11 # usage:
12 #       make -f Makefile.install debian-squeeze
13 #       - or -
14 #       make -f Makefile.install ubuntu-lucid
15 #       - or -
16 #       make -f Makefile.install fedora14
17 #       - or -
18 #       make -f Makefile.install centos
19 #       - or -
20 #       make -f Makefile.install rhel
21 #
22 # Notes:
23 #
24 #       This makefile has been tested much more with Debian, Ubuntu, and
25 #       Fedora than CentOS, or RHEL.
26 #
27 # ---------------------------------------------------------------------
28  
29 # Make any assumptions about the shell being used explicit
30 SHELL=/bin/bash 
31
32 LIBJS=js-1.7.0
33 LIBJS_PERL=JavaScript-SpiderMonkey-0.20
34 LIBJS_URL=http://ftp.mozilla.org/pub/mozilla.org/js/$(LIBJS).tar.gz
35 LIBJS_PERL_URL=http://mirror.datapipe.net/pub/CPAN/authors/id/T/TB/TBUSCH/$(LIBJS_PERL).tar.gz
36 # used for installing libjs lib and header files
37 JS_INSTALL_PREFIX=/usr/
38
39 # The libdbi sources can be fetched from sourceforge.net.  They are stored on
40 # the open-ils.org site now for ease of direct linking
41 LIBDBI=libdbi-0.8.3
42 LIBDBI_DRIVERS=libdbi-drivers-0.8.3
43 LIBDBI_HOST=http://open-ils.org/~denials/evergreen
44
45 # We need a recent version of Yaz
46 # Debian Lenny and Ubuntu 8.10 come with 3.0.34
47 YAZ=yaz-3.0.47
48 YAZ_HOST=http://ftp.indexdata.dk/pub/yaz
49
50 # Business::OnlinePayment is not packaged on CentOS/RHEL
51 PAY_ONLINE=Business-OnlinePayment-3.00_08.tar.gz
52 PAY_ONLINE_HOST=http://ftp.perl.org/pub/CPAN/authors/id/I/IV/IVAN/
53
54 APT_TOOL=aptitude -yq
55 APT_SAFE_TOOL=aptitude -P
56 APT_BACKPORT_TOOL=aptitude -t squeeze-backports -yq
57
58 # 64 or 32 bit os?
59 LBITS=$(shell getconf LONG_BIT)
60
61 # Fedora?
62 FEDORA=$(shell uname -r | grep "\.fc[0-9][0-9]\.")
63
64 # Fedora 64-bit?
65 FEDORA_64=$(shell uname -r | grep "\.fc[0-9][0-9]\.x86_64")
66
67 #RHEL/Centos PGSQL 
68 PGSQL_HOST=http://yum.pgsqlrpms.org/reporpms/8.4
69 PGSQL_CENTOS=pgdg-centos-8.4-2.noarch.rpm
70 PGSQL_REDHAT=pgdg-redhat-8.4-2.noarch.rpm       
71
72 # Debian dependencies
73 DEBS =  \
74         apache2-prefork-dev\
75         aspell\
76         aspell-en\
77         libbusiness-creditcard-perl\
78         libbusiness-onlinepayment-authorizenet-perl\
79         libbusiness-onlinepayment-perl\
80         libdatetime-format-builder-perl\
81         libdatetime-format-iso8601-perl\
82         libdatetime-format-mail-perl\
83         libdatetime-perl\
84         libdatetime-timezone-perl\
85         libdatetime-set-perl\
86         libdbd-pg-perl\
87         libemail-send-perl\
88         libemail-simple-perl\
89         libgd-graph3d-perl\
90         liblog-log4perl-perl\
91         libmarc-record-perl\
92         libncurses5-dev\
93         libnet-server-perl\
94         libnet-ssh2-perl\
95         libnspr4-dev\
96         libole-storage-lite-perl\
97         libparent-perl \
98         libpq-dev\
99         libreadline5-dev\
100         libspreadsheet-writeexcel-perl\
101         libssh2-1-dev\
102         libtext-aspell-perl\
103         libtext-csv-perl\
104         libuniversal-require-perl\
105         libnet-ip-perl\
106         libunix-syslog-perl
107
108 # Debian Lenny and Ubuntu Intrepid bundle recent versions of yaz
109 EXTRA_DEBS = \
110         libbusiness-isbn-perl\
111         libbusiness-isbn-data-perl\
112         libmarc-charset-perl \
113         libmarc-xml-perl \
114         libnet-z3950-zoom-perl \
115         libyaz-dev \
116         yaz
117
118 EXTRA_DEBS_SQUEEZE = \
119     libuuid-tiny-perl
120
121 # Ubuntu Hardy requires libencode-perl # to get a version of Encode
122 # > 2.12 - see bug 525069.
123 EXTRA_ENCODE = \
124         libencode-perl
125
126 CENTOS = \
127         aspell \
128         aspell-devel \
129         aspell-en \
130         gd-devel \
131         libssh2-devel \
132         openssl-devel \
133         perl-Business-CreditCard \
134         perl-Business-ISBN \
135         perl-Business-ISBN-Data \
136         perl-Business-OnlinePayment \
137         perl-Class-Data-Inheritable \
138         perl-DateTime-Format-Builder \
139         perl-DateTime-Format-Strptime \
140         perl-Ima-DBI \
141         perl-DBD-Pg \
142         perl-GD-Graph3d \
143         perl-IO-stringy \
144         perl-Spreadsheet-WriteExcel \
145         perl-Text-Aspell \
146         perl-Text-CSV
147
148 CENTOS_PERL = \
149         Encode \
150         DBIx::ContextualFetch \
151         Getopt::Long \
152         Net::SSH2 \
153         Net::XMPP \
154         Net::Z3950::ZOOM
155
156 FEDORA_RPMS = \
157         aspell \
158         aspell-en \
159         libdbi \
160         libdbi-dbd-pgsql \
161         libdbi-devel \
162         libssh2-devel \
163         libyaz \
164         libyaz-devel \
165         mod_ssl \
166         ncurses-devel \
167         ncurses-libs \
168         perl-parent \
169         perl-Business-CreditCard \
170         perl-Business-ISBN \
171         perl-Business-ISBN-Data \
172         perl-DBD-Pg \
173         perl-Email-Send \
174         perl-Email-Simple \
175         perl-GDGraph3d \
176         perl-Net-IP \
177         perl-Net-SSH2 \
178         perl-OLE-Storage_Lite \
179         perl-Spreadsheet-WriteExcel \
180         perl-Text-Aspell \
181         perl-Text-CSV \
182         perl-Text-CSV_XS \
183         perl-XML-Writer \
184         postgresql90-devel \
185         readline-devel \
186         tcp_wrappers-devel \
187         wget \
188         yaz
189
190 # Note: B:O:AuthorizeNet 3.21 fails with https://rt.cpan.org/Public/Bug/Display.html?id=55172
191 # Should be fixed in 3.22
192 # MARC::Record 2.0.1 is required but only 2.0.0 is packaged
193 FEDORA_CPAN = \
194         Business::OnlinePayment \
195         Business::OnlinePayment::AuthorizeNet \
196         MARC::Record \
197         UUID::Tiny
198
199 PGSQL_90_RPMS = \
200         postgresql90 \
201         postgresql90-contrib \
202         postgresql90-devel \
203         postgresql90-libs \
204         postgresql90-plperl \
205         postgresql90-server
206
207 PGSQL_CLIENT_DEBS_90 = \
208         libpq5 \
209         libpq-dev \
210         postgresql-client-9.0
211
212 PGSQL_SERVER_DEBS_90 = \
213         postgresql-9.0 \
214         postgresql-contrib-9.0 \
215         postgresql-plperl-9.0 \
216         postgresql-server-dev-9.0
217
218 DEB_APACHE_MODS = \
219     expires\
220     include\
221     proxy\
222     proxy_http\
223     rewrite
224
225 DEB_APACHE_DISMODS = \
226     deflate
227
228 # Chronically unpackaged CPAN modules
229 CPAN_MODULES = \
230     Business::EDI \
231     Library::CallNumber::LC \
232     Net::Z3950::Simple2ZOOM \
233     SRU
234
235 # More chronically unpackaged CPAN modules (available in Squeeze though)
236 CPAN_MODULES_MORE = \
237     Business::CreditCard::Object \
238     MARC::Record \
239     Net::SSH2 \
240     UUID::Tiny
241
242 # Are we sure most distros don't come with an acceptable version of Safe.pm?
243 CPAN_MODULES_SAFE = \
244         Safe
245
246 # Recent Debian/Ubuntus have libmarc-charset-perl, libmarc-xml-perl, libnet-z3950-zoom-perl
247 CPAN_MODULES_MARC = \
248         Business::ISBN \
249         Business::ISBN::Data \
250         MARC::Charset \
251         MARC::File::XML \
252         Net::Z3950::ZOOM
253
254 CPAN_MODULES_MARC_RECORD = \
255         MARC::Record
256
257 CPAN_MODULES_FORCE = \
258         Class::DBI::Frozen::301
259
260 # Lucid needs this because the XML::RPC that comes by default is broken with Evergreen
261 LUCID_CPAN = \
262         XML::RPC
263
264 # ----------------------------------------------------------------------------
265
266 all: 
267         @echo "please specify an OS" && exit 0
268
269 # these should be the same for any distro
270 install: install_cpan install_js_sm install_libdbi install_cpan_force
271
272 centos: install_centos_pgsql centos_like
273 rhel: install_redhat_pgsql centos_like
274 centos_like: install_centos_rpms install_yaz install_cpan_marc install install_centos_perl create_ld_local install_cpan_safe install_cpan_force
275
276 fedora14: install_fedora_rpms install_cpan install_cpan_fedora install_cpan_marc install_js_sm install_cpan_force
277 fedora15: fedora14
278
279 debian-squeeze: squeeze generic_debian
280 squeeze: install_pgsql_client_debs_90  install_extra_debs_squeeze
281 generic_debian:  install_debs test_for_libdbi_pkg install debian_sys_config install_cpan_force
282
283 ubuntu-lucid: lucid generic_ubuntu
284 lucid: install_pgsql_client_debs_90 install_extra_debs install_cpan_marc_record install_yaz install_cpan_lucid
285 generic_ubuntu: install_debs test_for_libdbi_pkg install debian_sys_config install_cpan_more install_cpan_safe install_cpan_force
286
287 # - COMMON TARGETS ---------------------------------------------------------
288
289 # Install the CPAN modules
290 install_cpan: 
291         for m in $(CPAN_MODULES); do perl -MCPAN -e "install \"$$m\";"; done
292
293 install_cpan_more: 
294         for m in $(CPAN_MODULES_MORE); do perl -MCPAN -e "install \"$$m\";"; done
295
296 # Install the CPAN modules for MARC functionality
297 install_cpan_marc: install_cpan_marc_record
298         for m in $(CPAN_MODULES_MARC); do perl -MCPAN -e "install \"$$m\";"; done
299
300 install_cpan_marc_record:
301         for m in $(CPAN_MODULES_MARC_RECORD); do perl -MCPAN -e "install \"$$m\";"; done
302
303 install_cpan_force:
304         for m in $(CPAN_MODULES_FORCE); do \
305                 echo "force install $$m" | perl -MCPAN -e shell ;\
306         done
307
308 # Install the Safe Perl module
309 # Is this really unpackaged everywhere except for Fedora?
310 install_cpan_safe: 
311         for m in $(CPAN_MODULES_SAFE); do perl -MCPAN -e "install \"$$m\";"; done
312
313 # Install the CPAN modules for Fedora 13
314 install_cpan_fedora: 
315         for m in $(FEDORA_CPAN); do \
316                 echo "force install $$m" | perl -MCPAN -e shell;\
317         done
318
319 # Install the CPAN modules needed for Lucid
320 install_cpan_lucid:
321         for m in $(LUCID_CPAN); do perl -MCPAN -e "install \"$$m\";"; done
322
323 # Install a known working version of YAZ
324 install_yaz:    
325         if [ ! -d $(YAZ) ]; then wget $(YAZ_HOST)/$(YAZ).tar.gz; fi;
326         tar xzf $(YAZ).tar.gz
327         cd $(YAZ) && ./configure && make && make install && ldconfig
328
329 # Install the custom spidermonkey libs and JavaScript-SpiderMonkey Perl modules
330 install_js_sm: install_libjs install_spidermonkey
331
332 install_libjs: 
333         if [ ! -f $(LIBJS).tar.gz ]; then wget $(LIBJS_URL); fi;
334         tar -zxf $(LIBJS).tar.gz
335         cd js/src/ && JS_DIST=/usr make -f Makefile.ref
336         mkdir -p $(JS_INSTALL_PREFIX)/include/js/
337         cp js/src/*.h $(JS_INSTALL_PREFIX)/include/js/
338         cp js/src/*.tbl $(JS_INSTALL_PREFIX)/include/js/
339         cp js/src/Linux_All_DBG.OBJ/*.so $(JS_INSTALL_PREFIX)/lib/
340         cp js/src/Linux_All_DBG.OBJ/*.a $(JS_INSTALL_PREFIX)/lib/
341
342 install_spidermonkey:
343         if [ ! -f $(LIBJS_PERL).tar.gz ]; then wget $(LIBJS_PERL_URL); fi;
344         tar -zxf $(LIBJS_PERL).tar.gz
345         if [ ! -z $(FEDORA_64) ]; then \
346                 sed -i -e 's/"\/usr\/lib"/"\/usr\/lib64"/' $(LIBJS_PERL)/Makefile.PL ; \
347         fi;
348         if [ ! -z $(FEDORA) ]; then \
349                 sed -i -e 's/js32.dll/libjs.so/' $(LIBJS_PERL)/Makefile.PL ; \
350         fi;
351         cd $(LIBJS_PERL) && perl Makefile.PL -E4X && make && make test && make install
352
353 # On Ubuntu and possibly Debian, the libdbi0 package prevents the 
354 # compiled-from-source version from being used and breaks the install.
355 # This package might get installed depending on the install-time choices
356 # for the distro. Test for its existence; if it's there, throw an error
357 # message and exit.
358 test_for_libdbi_pkg:
359                 @if [ "$$(apt-cache policy libdbi0 | grep Installed | grep none | wc -l)" -eq 0 ]; then \
360                                 echo "*** Detected locally installed libdbi0 package; you must remove this"; \
361                                 echo "*** with a command like 'aptitude remove libdbi0' before proceeding"; \
362                                 echo "*** to successfully install Evergreen."; \
363                                 echo; \
364                                 echo "*** Note: this may break other applications on your system."; \
365                                 exit 0; \
366                 fi;
367
368 # Install libdbi and the postgres drivers
369 install_libdbi:
370         if [ ! -d $(LIBDBI) ]; then wget $(LIBDBI_HOST)/$(LIBDBI).tar.gz; fi;
371         if [ ! -d $(LIBDBI_DRIVERS) ]; then wget $(LIBDBI_HOST)/$(LIBDBI_DRIVERS).tar.gz; fi;
372         tar -zxf $(LIBDBI).tar.gz
373         tar -zxf $(LIBDBI_DRIVERS).tar.gz
374         cd $(LIBDBI) && ./configure --disable-docs && make all install
375         cd $(LIBDBI_DRIVERS) && ./configure  \
376                 --disable-docs --with-pgsql --enable-libdbi && make all install  
377
378 clean:
379         make -C $(LIBDBI) clean
380         make -C $(LIBDBI_DRIVERS) clean
381         make -C $(LIBJS_PERL) clean
382         make -f Makefile.ref -C js/src/ clean
383
384
385 # ------------------------------------------------------------------
386 # - DEBIAN ---------------------------------------------------------
387
388 debian_sys_config: 
389         # link the apache modules in
390         for m in $(DEB_APACHE_MODS); do a2enmod $$m; done;
391         # keep the bad apache modules away
392         for m in $(DEB_APACHE_DISMODS); do a2dismod $$m; done;
393         # refresh the dynamic library cache
394         ldconfig
395
396 # Install the debian-specific dependencies
397 install_debs:
398         $(APT_TOOL) install $(DEBS)
399
400 install_pgsql_client_debs_90:
401         @if [ `$(APT_TOOL) versions libpq-dev | grep ^i|sed 's/^i[ \t]*//'|cut -d. -f1` -eq 8 ]; \
402                 then \
403                 echo -e "libpq5 / libpq-dev are installed as part of OpenSRF (a dependency" \
404                 "of apache2-prefork-dev), but these are the 8.4 versions and they" \
405                 "conflict with the 9.0 versions - so remove them, install the pinned" \
406                 "backports of 9.0, then reinstall the apache2-prefork-dev package.\n\n" \
407                 "**WARNING**: Saying 'Yes' to this step will _remove_ any PostgreSQL" \
408                 "databases that might currently exist on this machine." && \
409                 $(APT_SAFE_TOOL) remove libpq5 libpq-dev ; \
410         fi
411         $(APT_BACKPORT_TOOL) install $(PGSQL_CLIENT_DEBS_90)
412         $(APT_TOOL) install apache2-prefork-dev
413
414 install_pgsql_server_debs_90:
415         $(APT_BACKPORT_TOOL) install $(PGSQL_SERVER_DEBS_90)
416
417 # Install the debian-specific dependencies for more modern distros
418 install_extra_debs_squeeze: install_extra_debs
419         $(APT_TOOL) install $(EXTRA_DEBS_SQUEEZE)
420
421 install_extra_debs:
422         $(APT_TOOL) install $(EXTRA_DEBS)
423
424 # Install specific modules required by Ubuntu Hardy - see bug 525069
425 install_extra_encode:
426         $(APT_TOOL) install $(EXTRA_ENCODE)
427
428 # ------------------------------------------------------------------
429
430 # FEDORA 13
431 install_fedora_rpms:
432         yum -y update
433         yum -y install $(FEDORA_RPMS)
434
435 install_fedora_pgsql_server:
436         yum -y install $(PGSQL_84_RPMS)
437
438 # CENTOS
439 install_centos_rpms:
440         yum -y install $(CENTOS)
441         yum -y update
442         if [ $(LBITS) -eq 64 ]; then \
443                 ln -sf /usr/lib64/libpq.* /usr/lib/ && \
444                 ln -sf /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so /usr/lib/ && \
445                 ldconfig ; \
446         fi;
447         if [ $(LBITS) -eq 32 ]; then \
448                 ln -sf /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/libperl.so /usr/lib && \
449                 ldconfig ; \
450         fi;
451
452 install_centos_pgsql:
453         if [ $(LBITS) -eq 64 ]; then yum remove -y postgresql-libs-8.1*i386 apr-util-devel-*i386 ; fi;
454         wget $(PGSQL_HOST)/$(PGSQL_CENTOS)
455         rpm -Uvh --force ./$(PGSQL_CENTOS)
456         yum update -y
457         yum -y install $(PGSQL_84_RPMS)
458
459 install_redhat_pgsql:
460         if [ $(LBITS) -eq 64 ]; then yum remove -y postgresql-libs-8.1*i386 apr-util-devel-*i386 ; fi;
461         wget $(PGSQL_HOST)/$(PGSQL_REDHAT)
462         rpm -Uvh --force ./$(PGSQL_REDHAT)
463         yum update -y
464         yum -y install $(PGSQL_84_RPMS)
465
466 install_centos_perl:
467         for m in $(CENTOS_PERL); do perl -MCPAN -e "install \"$$m\";"; done
468         echo "force install Business::OnlinePayment::AuthorizeNet" | perl -MCPAN -e shell
469         echo "force install Scalar::Util" | perl -MCPAN -e shell        
470
471 # We need to add /usr/local/lib to the ldconfig list of directories on CentOS,
472 # if it is not already there
473 create_ld_local:
474         if [ "$$(ldconfig -v 2> /dev/null | grep '^/usr/local/lib' | wc -l)" -eq 0 ]; then \
475                 echo '/usr/local/lib' >> /etc/ld.so.conf.d/local.conf; \
476                 ldconfig; \
477         fi;
478
479 # vim:noet:sw=4:ts=4: