source: main/trunk/greenstone2/perllib/cpan/compile-dbd-mysql.sh@ 32786

Last change on this file since 32786 was 32786, checked in by ak19, 2 years ago

Preliminary changes before this script can work on Linux too. The Linux testing machine VM doesn't have DBI or DBD (DBI::DBD and DBD::mysql). This prevents the GreenstonePlugs from parsing during pluginfo. Should make the plugins inactive, but since the mac script to compile up DBD and install the mysql server can also work for linux have started adjusting it for that. Committing the linux changes separately. These are improvements for compiling on the Mac and now including getting and compiling DBI, not just DBD (which should in theory be be working with that DBI).

  • Property svn:executable set to *
File size: 7.4 KB
Line 
1###################################################
2# A basic cascade-make to install the DBD::mysql v 4.033 perl package to work with the GreenstoneSQLPlugin/Plugout
3#
4# Requires an internet connection to download required packages etc
5#
6# No dependencies
7#
8#
9# Compiling AND INSTALLING of all packages takes place in the temporary cpan/tmp folder. A select subset of the compiled/installed
10# products are then copied into their final destinations: lib/../<pkg> is copied into cpan, and lib/../auto/<pkg> is copied into cpan/auto
11#
12#
13###################################################
14
15if [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
16 echo "Usage: $0 [--clean|--keep|--help|-h]"
17 echo " Run without flags to compile and remove unnecessary stuff at the end."
18 echo " Run with --keep to retain the cpan/tmp subdir at compilation's end."
19 echo " Run with --clean to remove all traces of compilation completely so you can recompile from scratch"
20 echo " Run with --help/-h to see this Usage statement again"
21 exit 0
22fi
23
24if [ "x$GSDL3SRCHOME" = "x" ] ; then
25 echo "** GSDL3SRCHOME not set, sourcing gs3-setup.sh"
26 echo ""
27 cd ../../..
28 source ./gs3-setup.sh
29 cd $GSDLHOME/perllib/cpan
30fi
31
32echo ""
33echo "**************************"
34
35########################## VARIABLES ######################
36
37
38# the version of mysql we want is 5.7.23, we get the MacOS 10.13 (High Sierra) binary
39# and extract it into GSDLHOME as mysql-5.7.23
40MYSQL_BIN=mysql-5.7.23
41MYSQL_MIRROR=http://mysql.inspire.net.nz/Downloads/MySQL-5.7
42#MYSQL_TARBALL="${MYSQL_BIN}-linux-glibc2.12-x86_64"
43MYSQL_TARBALL="${MYSQL_BIN}-macos10.13-x86_64"
44
45# We want DBI::mysql version 1.634
46# see http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs
47# and https://metacpan.org/pod/release/TIMB/DBI-1.634/lib/DBI/DBD.pm
48DBI_MYSQL=DBI-1.634
49DBI_MYSQL_DOWNLOAD=https://cpan.metacpan.org/authors/id/T/TI/TIMB/$DBI_MYSQL.tar.gz
50
51# We want DBD::mysql version 4.033
52DBD_MYSQL=DBD-mysql-4.033
53DBD_MYSQL_DOWNLOAD=https://cpan.metacpan.org/authors/id/C/CA/CAPTTOFU/$DBD_MYSQL.tar.gz
54
55
56########################## DON'T CHANGE ####################
57CPAN_DIR=$GSDLHOME/perllib/cpan
58
59# PERL_FOLDER is something like "perl-5.18" (even if the full version number is 5.18.2)
60PERL_VERSION=`perl -e 'print "5.".substr($],3,2);'`
61# full perl version number like 5.18.2 or 5.22.1 (actually "5 version 22 subversion 1)
62PERL_FULL_VERSION=`perl -e 'print "5.".substr($],3,2).".".substr($],7,1);'`
63PERL_FOLDER="perl-${PERL_VERSION}" #`perl -e 'print "perl-5.".substr($],3,2);'`
64
65# make the dirs cpan/$PERL_FOLDER and its subdir auto if they don't already exist
66mkdir -p $CPAN_DIR/$PERL_FOLDER/auto
67
68WGET_FLAGS=--no-check-certificate
69# folder where we'll put the downloaded files, the compile products and the temporary install products
70# after everything is installed there, we copy just the relevant installed files to their final locations
71# then the tmp file gets deleted
72TEMP_DBI_DBD_DIR=$CPAN_DIR/tmp-mysql
73TEMP_STATIC_LIBS_DIR=$GSDLHOME/$MYSQL_BIN/mysql-static
74MYSQL_DIR=$GSDLHOME/$MYSQL_BIN
75
76
77##########################
78
79# if --clean was passed in
80if [ "x$1" = "x--clean" ] ; then
81 pushd $CPAN_DIR
82 if [ -e "$PERL_FOLDER/DBD" ]; then
83 rm -rf $PERL_FOLDER/DBD
84 fi
85 if [ -e "$PERL_FOLDER/auto/DBD" ]; then
86 rm -rf $PERL_FOLDER/auto/DBD
87 fi
88 echo "** Done cleaning DBD::mysql related packages"
89
90 if [ -e "$PERL_FOLDER/DBI" ]; then
91 rm -rf $PERL_FOLDER/DBI
92 fi
93 if [ -e "$PERL_FOLDER/auto/DBI" ]; then
94 rm -rf $PERL_FOLDER/auto/DBI
95 fi
96 echo "** Done cleaning DBI::DBD related packages"
97 popd
98 exit 0
99fi
100
101# Go into $GSDLHOME
102pushd $GSDLHOME
103
104# download and untar mysql into $GSDLHOME
105if [ ! -d $GSDLHOME/$MYSQL_BIN ]; then
106 if [ ! -e $GSDLHOME/$MYSQL_TARBALL.tar.gz ]; then
107 echo "** Getting the mysql tarball"
108 wget $WGET_FLAGS $MYSQL_MIRROR/$MYSQL_TARBALL.tar.gz
109 fi
110 echo "** Extracting the mysql tarball into $GSDLHOME and renaming to $MYSQLBIN"
111 tar -xvzf $MYSQL_TARBALL.tar.gz
112 # there's 2 tarballs inside, untar the one with identical name to outer
113 # and rename to $GSDLHOME/mysql-5.7.23
114# cd $MYSQL_TARBALL
115# tar -xvzf $MYSQL_TARBALL.tar.gz
116# cd $GSDLHOME
117# mv $MYSQL_TARBALL/$MYSQL_TARBALL $GSDLHOME/$MYSQL_BIN
118 mv $MYSQL_TARBALL $GSDLHOME/$MYSQL_BIN
119fi
120
121# copy just the static .a libraries into their own folder
122if [ ! -d $TEMP_STATIC_LIBS_DIR ]; then
123 echo "** Creating $TEMP_STATIC_LIBS_DIR and copying $MYSQL_BIN/lib/*.a into it"
124 mkdir -p $TEMP_STATIC_LIBS_DIR
125 cp $GSDLHOME/$MYSQL_BIN/lib/*.a $TEMP_STATIC_LIBS_DIR/.
126fi
127
128# download and untar DBI::DBD v 1.634
129if [ ! -d $GSDLHOME/$DBI_MYSQL ]; then
130 cd $GSDLHOME
131 if [ ! -e $GSDLHOME/$DBI_MYSQL.tar.gz ]; then
132 echo "** Getting the DBI::DBD tarball"
133 wget $WGET_FLAGS $DBI_MYSQL_DOWNLOAD
134 fi
135 echo "** Extracting the DBI::DBD tarball into $GSDLHOME"
136 tar -xvzf $DBI_MYSQL.tar.gz
137fi
138# start compiling DBI::DBD into $TEMP_DBI_DBD_DIR
139echo "** Creating $TEMP_DBI_DBD_DIR (anew) and compiling this perl package"
140
141if [ -d $TEMP_DBI_DBD_DIR ]; then
142 rm -rf $TEMP_DBI_DBD_DIR
143fi
144mkdir $TEMP_DBI_DBD_DIR
145
146cd $GSDLHOME/$DBI_MYSQL
147perl Makefile.PL \
148 PREFIX=$TEMP_DBI_DBD_DIR
149 --cflags=-I$GSDLHOME/$MYSQL_BIN/include \
150 --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient"
151make
152make install
153
154# move built DBI::DBD products into correct CPAN location
155echo "** Moving relevant DBI::DBD products into $CPAN_DIR/$PERL_FOLDER"
156cd $CPAN_DIR
157mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBI $PERL_FOLDER/.
158mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/auto/DBI $PERL_FOLDER/auto/.
159
160#echo "EXITING"
161#exit
162
163# download and untar DBD::mysql v 4.033
164if [ ! -d $GSDLHOME/$DBD_MYSQL ]; then
165 cd $GSDLHOME
166 if [ ! -e $GSDLHOME/$DBD_MYSQL.tar.gz ]; then
167 echo "** Getting the DBD::mysql tarball"
168 wget $WGET_FLAGS $DBD_MYSQL_DOWNLOAD
169 fi
170 echo "** Extracting the DBD mysql tarball into $GSDLHOME"
171 tar -xvzf $DBD_MYSQL.tar.gz
172fi
173# start compiling DBD::mysql into $TEMP_DBI_DBD_DIR
174echo "** Compiling this perl package"
175
176cd $GSDLHOME/$DBD_MYSQL
177perl Makefile.PL \
178 PREFIX=$TEMP_DBI_DBD_DIR \
179 --cflags=-I$GSDLHOME/$MYSQL_BIN/include \
180 --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient"
181make
182make install
183
184
185# move built DBD::mysql products into correct CPAN location
186echo "** Moving relevant DBD::mysql products into $CPAN_DIR/$PERL_FOLDER"
187cd $CPAN_DIR
188mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBD $PERL_FOLDER/.
189mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_SUBVERSION/darwin-thread-multi-2level/auto/DBD $PERL_FOLDER/auto/.
190
191# clean up
192echo "*****************************"
193echo "*** Done compiling DBD::mysql."
194if [ "x$1" != "x--keep" ] ; then
195 echo "** Will now delete temporary DBD::mysql products, and the untarred DBD::mysql"
196 rm -rf $TEMP_DBI_DBD_DIR
197 rm -rf $GSDLHOME/$DBI_MYSQL
198 rm -rf $GSDLHOME/$DBD_MYSQL
199else
200 echo "** Not deleting the $TEMP_DBI_DBD_DIR"
201fi
202rm -rf $TEMP_STATIC_LIBS_DIR
203
204
205# go back to where we started
206popd
207
208echo "*****************************"
209echo ""
210echo "** You now need to initialize the MySQL installation at $GSDLHOME/$MYSQL_BIN"
211echo "** Follow the instructions from STEP 2 ONWARDS at at http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs#installing_one_time_setup"
212echo "** Once that's done, the same page has information on how to use the GreenstoneSQLPlugs in a collection"
213echo ""
214echo "*****************************"
215
Note: See TracBrowser for help on using the repository browser.