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

Last change on this file since 32787 was 32787, checked in by ak19, 5 years ago

Some more corrections and better var names before committing linux changes.

  • 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
46# We want DBI::mysql version 1.634
47# see http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs
48# and https://metacpan.org/pod/release/TIMB/DBI-1.634/lib/DBI/DBD.pm
49DBI_DBD=DBI-1.634
50DBI_DBD_DOWNLOAD=https://cpan.metacpan.org/authors/id/T/TI/TIMB/$DBI_DBD.tar.gz
51
52# We want DBD::mysql version 4.033
53DBD_MYSQL=DBD-mysql-4.033
54DBD_MYSQL_DOWNLOAD=https://cpan.metacpan.org/authors/id/C/CA/CAPTTOFU/$DBD_MYSQL.tar.gz
55
56
57########################## DON'T CHANGE ####################
58CPAN_DIR=$GSDLHOME/perllib/cpan
59
60# PERL_FOLDER is something like "perl-5.18" (even if the full version number is 5.18.2)
61PERL_VERSION=`perl -e 'print "5.".substr($],3,2);'`
62# full perl version number like 5.18.2 or 5.22.1 (actually "5 version 22 subversion 1)
63PERL_FULL_VERSION=`perl -e 'print "5.".substr($],3,2).".".substr($],7,1);'`
64PERL_FOLDER="perl-${PERL_VERSION}" #`perl -e 'print "perl-5.".substr($],3,2);'`
65
66# make the dirs cpan/$PERL_FOLDER and its subdir auto if they don't already exist
67mkdir -p $CPAN_DIR/$PERL_FOLDER/auto
68
69WGET_FLAGS=--no-check-certificate
70# folder where we'll put the downloaded files, the compile products and the temporary install products
71# after everything is installed there, we copy just the relevant installed files to their final locations
72# then the tmp file gets deleted
73TEMP_DBI_DBD_DIR=$CPAN_DIR/tmp-mysql
74TEMP_STATIC_LIBS_DIR=$GSDLHOME/$MYSQL_BIN/mysql-static
75MYSQL_DIR=$GSDLHOME/$MYSQL_BIN
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_DBD ]; then
130 cd $GSDLHOME
131 if [ ! -e $GSDLHOME/$DBI_DBD.tar.gz ]; then
132 echo "** Getting the DBI::DBD tarball"
133 wget $WGET_FLAGS $DBI_DBD_DOWNLOAD
134 fi
135 echo "** Extracting the DBI::DBD tarball into $GSDLHOME"
136 tar -xvzf $DBI_DBD.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_DBD
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
164# download and untar DBD::mysql v 4.033
165if [ ! -d $GSDLHOME/$DBD_MYSQL ]; then
166 cd $GSDLHOME
167 if [ ! -e $GSDLHOME/$DBD_MYSQL.tar.gz ]; then
168 echo "** Getting the DBD::mysql tarball"
169 wget $WGET_FLAGS $DBD_MYSQL_DOWNLOAD
170 fi
171 echo "** Extracting the DBD mysql tarball into $GSDLHOME"
172 tar -xvzf $DBD_MYSQL.tar.gz
173fi
174# start compiling DBD::mysql into $TEMP_DBI_DBD_DIR
175echo "** Compiling this perl package"
176
177cd $GSDLHOME/$DBD_MYSQL
178perl Makefile.PL \
179 PREFIX=$TEMP_DBI_DBD_DIR \
180 --cflags=-I$GSDLHOME/$MYSQL_BIN/include \
181 --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient"
182make
183make install
184
185
186# move built DBD::mysql products into correct CPAN location
187echo "** Moving relevant DBD::mysql products into $CPAN_DIR/$PERL_FOLDER"
188cd $CPAN_DIR
189mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBD $PERL_FOLDER/.
190mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/auto/DBD $PERL_FOLDER/auto/.
191
192# clean up
193echo "*****************************"
194echo "*** Done compiling DBD::mysql."
195if [ "x$1" != "x--keep" ] ; then
196 echo "** Will now delete temporary DBD::mysql products, and the untarred DBD::mysql"
197 rm -rf $TEMP_DBI_DBD_DIR
198 rm -rf $GSDLHOME/$DBI_DBD
199 rm -rf $GSDLHOME/$DBD_MYSQL
200else
201 echo "** Not deleting the $TEMP_DBI_DBD_DIR"
202fi
203rm -rf $TEMP_STATIC_LIBS_DIR
204
205
206# go back to where we started
207popd
208
209echo "*****************************"
210echo ""
211echo "** You now need to initialize the MySQL installation at $GSDLHOME/$MYSQL_BIN"
212echo "** Follow the instructions from STEP 2 ONWARDS at at http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs#installing_one_time_setup"
213echo "** Once that's done, the same page has information on how to use the GreenstoneSQLPlugs in a collection"
214echo ""
215echo "*****************************"
216
Note: See TracBrowser for help on using the repository browser.