- Timestamp:
- 2019-02-20T20:21:39+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cpan/compile-dbd-mysql.sh
r32787 r32788 35 35 ########################## VARIABLES ###################### 36 36 37 38 # the version of mysql we want is 5.7.23, we get the MacOS 10.13 (High Sierra) binary 37 # Expected defaults: 38 # - This script was originally created for Mac High Sierra where the DBI perl package was installed # but the DBD perl package is missing (which needs to be compiled against MySQL 5.7.23 that we 39 # will download and adjust for the purpose) 40 # - The DBI perl package tends to be installed on Mac and Linux Ubuntu. If not, set NEED_PERL_DBI 41 # to true to compile it up against the MySQL that this script will download. 42 # - Regardless of whether you have a MySQL installed, this script needs to download MySQL v 5.7.23 43 # in specific to compile (DBI and) DBD against it. 44 # MySQL tends to be installed on Linux. If the version installed is 5.7.23, you may not want to 45 # keep the MySQL that this script downloads. In that case set KEEP_MYSQL_DOWNLOAD to false. 46 # - The Ubunutu 16.04 assigned to me had both DBI and DBD installed so I didn't need to run this 47 # script at all. 48 49 NEED_PERL_DBI=false # set to true if your machine doesn't have DBI 50 KEEP_MYSQL_DOWNLOAD=true # needed for compiling DBD (and DBI). Set to false if custom MySQL to be removed after compiling 51 NEED_PERL_DBD=true # only set to false, if you want this script to ONLY get and extract MySQL for you 52 53 # Need mysql 5.7.23 to compile DBD (and DBI) against. Regardless of whether user wants to use this mysql, 54 # we need to download, unpack and adjust it for compiling up DBD (and optionally DBI). 55 # The version of mysql we want is 5.7.23, we get the MacOS 10.13 (High Sierra) binary 39 56 # and extract it into GSDLHOME as mysql-5.7.23 40 57 MYSQL_BIN=mysql-5.7.23 41 58 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 46 # We want DBI::mysql version 1.634 59 60 # $GSDLOS can be "darwin" on Mac, else "linux". 61 # Alternatively, can test `uname`: echoed value can be "Darwin" (on Mac) or "Linux" 62 if [ "x$GSDLOS" = "xdarwin" ] ; then 63 MYSQL_TARBALL="${MYSQL_BIN}-macos10.13-x86_64" 64 else 65 MYSQL_TARBALL="${MYSQL_BIN}-linux-glibc2.12-x86_64" 66 fi 67 68 # We want DBD::mysql version 4.033 69 # This package is necessary on Mac High Sierra (v10.13) 70 # Assigned Ubuntu had DBD (and DBI) but VM testing Ubuntu had neither 71 DBD_MYSQL=DBD-mysql-4.033 72 DBD_MYSQL_DOWNLOAD=https://cpan.metacpan.org/authors/id/C/CA/CAPTTOFU/$DBD_MYSQL.tar.gz 73 74 # We may need DBI::DBD version 1.634, if DBI not installed (on machines with no DBD and DBI) 47 75 # see http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs 48 76 # and https://metacpan.org/pod/release/TIMB/DBI-1.634/lib/DBI/DBD.pm 49 77 DBI_DBD=DBI-1.634 50 78 DBI_DBD_DOWNLOAD=https://cpan.metacpan.org/authors/id/T/TI/TIMB/$DBI_DBD.tar.gz 51 52 # We want DBD::mysql version 4.03353 DBD_MYSQL=DBD-mysql-4.03354 DBD_MYSQL_DOWNLOAD=https://cpan.metacpan.org/authors/id/C/CA/CAPTTOFU/$DBD_MYSQL.tar.gz55 79 56 80 … … 75 99 MYSQL_DIR=$GSDLHOME/$MYSQL_BIN 76 100 101 77 102 ########################## 78 103 … … 80 105 if [ "x$1" = "x--clean" ] ; then 81 106 pushd $CPAN_DIR 82 if [ - e"$PERL_FOLDER/DBD" ]; then107 if [ -d "$PERL_FOLDER/DBD" ]; then 83 108 rm -rf $PERL_FOLDER/DBD 84 109 fi 85 if [ - e"$PERL_FOLDER/auto/DBD" ]; then110 if [ -d "$PERL_FOLDER/auto/DBD" ]; then 86 111 rm -rf $PERL_FOLDER/auto/DBD 87 112 fi 88 113 echo "** Done cleaning DBD::mysql related packages" 89 114 90 if [ -e "$PERL_FOLDER/DBI" ]; then 115 if [ -e "$PERL_FOLDER/DBI.pm" ]; then 116 rm -f $PERL_FOLDER/DBI.pm 117 fi 118 if [ -d "$PERL_FOLDER/DBI" ]; then 91 119 rm -rf $PERL_FOLDER/DBI 92 120 fi 93 if [ - e"$PERL_FOLDER/auto/DBI" ]; then121 if [ -d "$PERL_FOLDER/auto/DBI" ]; then 94 122 rm -rf $PERL_FOLDER/auto/DBI 95 123 fi … … 126 154 fi 127 155 128 # download and untar DBI::DBD v 1.634 129 if [ ! -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 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 156 # Ensure a clean new temp folder to compile (DBI and) DBD into 157 echo "** Creating $TEMP_DBI_DBD_DIR (anew)" 141 158 if [ -d $TEMP_DBI_DBD_DIR ]; then 142 159 rm -rf $TEMP_DBI_DBD_DIR … … 144 161 mkdir $TEMP_DBI_DBD_DIR 145 162 146 cd $GSDLHOME/$DBI_DBD 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 163 164 if [ "x$NEED_PERL_DBI" = "xtrue" ] ; then 165 # download and untar DBI::DBD v 1.634 166 if [ ! -d $GSDLHOME/$DBI_DBD ]; then 167 cd $GSDLHOME 168 if [ ! -e $GSDLHOME/$DBI_DBD.tar.gz ]; then 169 echo "** Getting the DBI::DBD tarball" 170 wget $WGET_FLAGS $DBI_DBD_DOWNLOAD 171 fi 172 echo "** Extracting the DBI::DBD tarball into $GSDLHOME" 173 tar -xvzf $DBI_DBD.tar.gz 174 fi 175 # start compiling DBI::DBD into $TEMP_DBI_DBD_DIR 176 echo "** Compiling the DBI perl package" 177 178 cd $GSDLHOME/$DBI_DBD 179 perl Makefile.PL \ 180 PREFIX=$TEMP_DBI_DBD_DIR 181 --cflags=-I$GSDLHOME/$MYSQL_BIN/include \ 182 --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient" 183 make 184 make install 185 186 # move built DBI::DBD products into correct CPAN location 187 echo "** Moving relevant DBI::DBD products into $CPAN_DIR/$PERL_FOLDER" 188 cd $CPAN_DIR 189 if [ "x$GSDLOS" = "xdarwin" ] ; then 190 mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBI.pm $PERL_FOLDER/. 191 mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBI $PERL_FOLDER/. 192 mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/auto/DBI $PERL_FOLDER/auto/. 193 else 194 mv $TEMP_DBI_DBD_DIR/lib/x86_64-linux-gnu/perl/$PERL_FULL_VERSION/DBI.pm $PERL_FOLDER/. 195 mv $TEMP_DBI_DBD_DIR/lib/x86_64-linux-gnu/perl/$PERL_FULL_VERSION/DBI $PERL_FOLDER/. 196 mv $TEMP_DBI_DBD_DIR/lib/x86_64-linux-gnu/perl/$PERL_FULL_VERSION/auto/DBI $PERL_FOLDER/auto/. 197 fi 198 fi 160 199 #echo "EXITING" 161 200 #exit 162 201 163 164 # download and untar DBD::mysql v 4.033 165 if [ ! -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 173 fi 174 # start compiling DBD::mysql into $TEMP_DBI_DBD_DIR 175 echo "** Compiling this perl package" 176 177 cd $GSDLHOME/$DBD_MYSQL 178 perl Makefile.PL \ 179 PREFIX=$TEMP_DBI_DBD_DIR \ 180 --cflags=-I$GSDLHOME/$MYSQL_BIN/include \ 181 --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient" 182 make 183 make install 184 185 186 # move built DBD::mysql products into correct CPAN location 187 echo "** Moving relevant DBD::mysql products into $CPAN_DIR/$PERL_FOLDER" 188 cd $CPAN_DIR 189 mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBD $PERL_FOLDER/. 190 mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/auto/DBD $PERL_FOLDER/auto/. 202 if [ "x$NEED_PERL_DBD" = "xtrue" ] ; then 203 # download and untar DBD::mysql v 4.033 204 if [ ! -d $GSDLHOME/$DBD_MYSQL ]; then 205 cd $GSDLHOME 206 if [ ! -e $GSDLHOME/$DBD_MYSQL.tar.gz ]; then 207 echo "** Getting the DBD::mysql tarball" 208 wget $WGET_FLAGS $DBD_MYSQL_DOWNLOAD 209 fi 210 echo "** Extracting the DBD mysql tarball into $GSDLHOME" 211 tar -xvzf $DBD_MYSQL.tar.gz 212 fi 213 # start compiling DBD::mysql into $TEMP_DBI_DBD_DIR 214 echo "** Compiling this perl package" 215 216 cd $GSDLHOME/$DBD_MYSQL 217 perl Makefile.PL \ 218 PREFIX=$TEMP_DBI_DBD_DIR \ 219 --cflags=-I$GSDLHOME/$MYSQL_BIN/include \ 220 --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient" 221 make 222 make install 223 224 # move built DBD::mysql products into correct CPAN location 225 echo "** Moving relevant DBD::mysql products into $CPAN_DIR/$PERL_FOLDER" 226 cd $CPAN_DIR 227 if [ "x$GSDLOS" = "xdarwin" ] ; then 228 mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBD $PERL_FOLDER/. 229 mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/auto/DBD $PERL_FOLDER/auto/. 230 else 231 mv $TEMP_DBI_DBD_DIR/lib/x86_64-linux-gnu/perl/$PERL_FULL_VERSION/DBD $PERL_FOLDER/. 232 mv $TEMP_DBI_DBD_DIR/lib/x86_64-linux-gnu/perl/$PERL_FULL_VERSION/auto/DBD $PERL_FOLDER/auto/. 233 fi 234 fi 191 235 192 236 # clean up … … 196 240 echo "** Will now delete temporary DBD::mysql products, and the untarred DBD::mysql" 197 241 rm -rf $TEMP_DBI_DBD_DIR 198 rm -rf $GSDLHOME/$DBI_DBD 199 rm -rf $GSDLHOME/$DBD_MYSQL 242 if [ -d "$GSDLHOME/$DBI_DBD" ]; then 243 rm -rf $GSDLHOME/$DBI_DBD 244 fi 245 if [ -d "$GSDLHOME/$DBD_MYSQL" ]; then 246 rm -rf $GSDLHOME/$DBD_MYSQL 247 fi 200 248 else 201 249 echo "** Not deleting the $TEMP_DBI_DBD_DIR" 202 250 fi 251 # The static libs folder added to the downloaded MySQL installation was only necessary for compiling. 252 # It can be removed now, since MySQL usage doesn't require it. 203 253 rm -rf $TEMP_STATIC_LIBS_DIR 204 254 255 256 if [ "x$KEEP_MYSQL_DOWNLOAD" = "xfalse" ] ; then 257 if [ -d $GSDLHOME/$MYSQL_BIN ]; then 258 echo "**** KEEP_MYSQL_DOWNLOAD set to false, so removing $GSDLHOME/$MYSQL_BIN folder" 259 echo " now that compilation is done" 260 rm -rf $GSDLHOME/$MYSQL_BIN 261 fi 262 fi 205 263 206 264 # go back to where we started … … 209 267 echo "*****************************" 210 268 echo "" 211 echo "** You now need to initialize the MySQL installation at $GSDLHOME/$MYSQL_BIN" 269 if [ "x$KEEP_MYSQL_DOWNLOAD" = "xfalse" ] ; then 270 echo "** KEEP_MYSQL_DOWNLOAD was set to false," 271 echo " so it's assumed you have your own MySQL 5.7.23 installation" 272 echo " You now need to initialise your MySQL installation." 273 else 274 echo "** You now need to initialise the MySQL installation at $GSDLHOME/$MYSQL_BIN" 275 fi 212 276 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" 213 277 echo "** Once that's done, the same page has information on how to use the GreenstoneSQLPlugs in a collection"
Note:
See TracChangeset
for help on using the changeset viewer.