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 |
|
---|
15 | if [ "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
|
---|
22 | fi
|
---|
23 |
|
---|
24 | if [ "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
|
---|
30 | fi
|
---|
31 |
|
---|
32 | echo ""
|
---|
33 | echo "**************************"
|
---|
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
|
---|
40 | MYSQL_BIN=mysql-5.7.23
|
---|
41 | MYSQL_MIRROR=http://mysql.inspire.net.nz/Downloads/MySQL-5.7
|
---|
42 | #MYSQL_TARBALL="${MYSQL_BIN}-linux-glibc2.12-x86_64"
|
---|
43 | MYSQL_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
|
---|
48 | DBI_MYSQL=DBI-1.634
|
---|
49 | DBI_MYSQL_DOWNLOAD=https://cpan.metacpan.org/authors/id/T/TI/TIMB/$DBI_MYSQL.tar.gz
|
---|
50 |
|
---|
51 | # We want DBD::mysql version 4.033
|
---|
52 | DBD_MYSQL=DBD-mysql-4.033
|
---|
53 | DBD_MYSQL_DOWNLOAD=https://cpan.metacpan.org/authors/id/C/CA/CAPTTOFU/$DBD_MYSQL.tar.gz
|
---|
54 |
|
---|
55 |
|
---|
56 | ########################## DON'T CHANGE ####################
|
---|
57 | CPAN_DIR=$GSDLHOME/perllib/cpan
|
---|
58 |
|
---|
59 | # PERL_FOLDER is something like "perl-5.18" (even if the full version number is 5.18.2)
|
---|
60 | PERL_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)
|
---|
62 | PERL_FULL_VERSION=`perl -e 'print "5.".substr($],3,2).".".substr($],7,1);'`
|
---|
63 | PERL_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
|
---|
66 | mkdir -p $CPAN_DIR/$PERL_FOLDER/auto
|
---|
67 |
|
---|
68 | WGET_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
|
---|
72 | TEMP_DBI_DBD_DIR=$CPAN_DIR/tmp-mysql
|
---|
73 | TEMP_STATIC_LIBS_DIR=$GSDLHOME/$MYSQL_BIN/mysql-static
|
---|
74 | MYSQL_DIR=$GSDLHOME/$MYSQL_BIN
|
---|
75 |
|
---|
76 |
|
---|
77 | ##########################
|
---|
78 |
|
---|
79 | # if --clean was passed in
|
---|
80 | if [ "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
|
---|
99 | fi
|
---|
100 |
|
---|
101 | # Go into $GSDLHOME
|
---|
102 | pushd $GSDLHOME
|
---|
103 |
|
---|
104 | # download and untar mysql into $GSDLHOME
|
---|
105 | if [ ! -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
|
---|
119 | fi
|
---|
120 |
|
---|
121 | # copy just the static .a libraries into their own folder
|
---|
122 | if [ ! -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/.
|
---|
126 | fi
|
---|
127 |
|
---|
128 | # download and untar DBI::DBD v 1.634
|
---|
129 | if [ ! -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
|
---|
137 | fi
|
---|
138 | # start compiling DBI::DBD into $TEMP_DBI_DBD_DIR
|
---|
139 | echo "** Creating $TEMP_DBI_DBD_DIR (anew) and compiling this perl package"
|
---|
140 |
|
---|
141 | if [ -d $TEMP_DBI_DBD_DIR ]; then
|
---|
142 | rm -rf $TEMP_DBI_DBD_DIR
|
---|
143 | fi
|
---|
144 | mkdir $TEMP_DBI_DBD_DIR
|
---|
145 |
|
---|
146 | cd $GSDLHOME/$DBI_MYSQL
|
---|
147 | perl Makefile.PL \
|
---|
148 | PREFIX=$TEMP_DBI_DBD_DIR
|
---|
149 | --cflags=-I$GSDLHOME/$MYSQL_BIN/include \
|
---|
150 | --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient"
|
---|
151 | make
|
---|
152 | make install
|
---|
153 |
|
---|
154 | # move built DBI::DBD products into correct CPAN location
|
---|
155 | echo "** Moving relevant DBI::DBD products into $CPAN_DIR/$PERL_FOLDER"
|
---|
156 | cd $CPAN_DIR
|
---|
157 | mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBI $PERL_FOLDER/.
|
---|
158 | mv $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
|
---|
164 | if [ ! -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
|
---|
172 | fi
|
---|
173 | # start compiling DBD::mysql into $TEMP_DBI_DBD_DIR
|
---|
174 | echo "** Compiling this perl package"
|
---|
175 |
|
---|
176 | cd $GSDLHOME/$DBD_MYSQL
|
---|
177 | perl Makefile.PL \
|
---|
178 | PREFIX=$TEMP_DBI_DBD_DIR \
|
---|
179 | --cflags=-I$GSDLHOME/$MYSQL_BIN/include \
|
---|
180 | --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient"
|
---|
181 | make
|
---|
182 | make install
|
---|
183 |
|
---|
184 |
|
---|
185 | # move built DBD::mysql products into correct CPAN location
|
---|
186 | echo "** Moving relevant DBD::mysql products into $CPAN_DIR/$PERL_FOLDER"
|
---|
187 | cd $CPAN_DIR
|
---|
188 | mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBD $PERL_FOLDER/.
|
---|
189 | mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_SUBVERSION/darwin-thread-multi-2level/auto/DBD $PERL_FOLDER/auto/.
|
---|
190 |
|
---|
191 | # clean up
|
---|
192 | echo "*****************************"
|
---|
193 | echo "*** Done compiling DBD::mysql."
|
---|
194 | if [ "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
|
---|
199 | else
|
---|
200 | echo "** Not deleting the $TEMP_DBI_DBD_DIR"
|
---|
201 | fi
|
---|
202 | rm -rf $TEMP_STATIC_LIBS_DIR
|
---|
203 |
|
---|
204 |
|
---|
205 | # go back to where we started
|
---|
206 | popd
|
---|
207 |
|
---|
208 | echo "*****************************"
|
---|
209 | echo ""
|
---|
210 | echo "** You now need to initialize the MySQL installation at $GSDLHOME/$MYSQL_BIN"
|
---|
211 | echo "** Follow the instructions from STEP 2 ONWARDS at at http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs#installing_one_time_setup"
|
---|
212 | echo "** Once that's done, the same page has information on how to use the GreenstoneSQLPlugs in a collection"
|
---|
213 | echo ""
|
---|
214 | echo "*****************************"
|
---|
215 |
|
---|