[32662] | 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 |
|
---|
[32788] | 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.
|
---|
[32662] | 48 |
|
---|
[32788] | 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
|
---|
[32662] | 56 | # and extract it into GSDLHOME as mysql-5.7.23
|
---|
| 57 | MYSQL_BIN=mysql-5.7.23
|
---|
| 58 | MYSQL_MIRROR=http://mysql.inspire.net.nz/Downloads/MySQL-5.7
|
---|
| 59 |
|
---|
[32788] | 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
|
---|
[32787] | 67 |
|
---|
[32788] | 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)
|
---|
[32786] | 75 | # see http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs
|
---|
| 76 | # and https://metacpan.org/pod/release/TIMB/DBI-1.634/lib/DBI/DBD.pm
|
---|
[32787] | 77 | DBI_DBD=DBI-1.634
|
---|
| 78 | DBI_DBD_DOWNLOAD=https://cpan.metacpan.org/authors/id/T/TI/TIMB/$DBI_DBD.tar.gz
|
---|
[32786] | 79 |
|
---|
[32662] | 80 |
|
---|
| 81 | ########################## DON'T CHANGE ####################
|
---|
| 82 | CPAN_DIR=$GSDLHOME/perllib/cpan
|
---|
| 83 |
|
---|
| 84 | # PERL_FOLDER is something like "perl-5.18" (even if the full version number is 5.18.2)
|
---|
[32786] | 85 | PERL_VERSION=`perl -e 'print "5.".substr($],3,2);'`
|
---|
| 86 | # full perl version number like 5.18.2 or 5.22.1 (actually "5 version 22 subversion 1)
|
---|
| 87 | PERL_FULL_VERSION=`perl -e 'print "5.".substr($],3,2).".".substr($],7,1);'`
|
---|
| 88 | PERL_FOLDER="perl-${PERL_VERSION}" #`perl -e 'print "perl-5.".substr($],3,2);'`
|
---|
[32662] | 89 |
|
---|
| 90 | # make the dirs cpan/$PERL_FOLDER and its subdir auto if they don't already exist
|
---|
| 91 | mkdir -p $CPAN_DIR/$PERL_FOLDER/auto
|
---|
| 92 |
|
---|
| 93 | WGET_FLAGS=--no-check-certificate
|
---|
| 94 | # folder where we'll put the downloaded files, the compile products and the temporary install products
|
---|
| 95 | # after everything is installed there, we copy just the relevant installed files to their final locations
|
---|
| 96 | # then the tmp file gets deleted
|
---|
[32786] | 97 | TEMP_DBI_DBD_DIR=$CPAN_DIR/tmp-mysql
|
---|
[32662] | 98 | TEMP_STATIC_LIBS_DIR=$GSDLHOME/$MYSQL_BIN/mysql-static
|
---|
| 99 | MYSQL_DIR=$GSDLHOME/$MYSQL_BIN
|
---|
| 100 |
|
---|
[32788] | 101 |
|
---|
[32662] | 102 | ##########################
|
---|
| 103 |
|
---|
[32786] | 104 | # if --clean was passed in
|
---|
[32662] | 105 | if [ "x$1" = "x--clean" ] ; then
|
---|
| 106 | pushd $CPAN_DIR
|
---|
[32788] | 107 | if [ -d "$PERL_FOLDER/DBD" ]; then
|
---|
[32662] | 108 | rm -rf $PERL_FOLDER/DBD
|
---|
| 109 | fi
|
---|
[32788] | 110 | if [ -d "$PERL_FOLDER/auto/DBD" ]; then
|
---|
[32662] | 111 | rm -rf $PERL_FOLDER/auto/DBD
|
---|
| 112 | fi
|
---|
| 113 | echo "** Done cleaning DBD::mysql related packages"
|
---|
[32786] | 114 |
|
---|
[32788] | 115 | if [ -e "$PERL_FOLDER/DBI.pm" ]; then
|
---|
| 116 | rm -f $PERL_FOLDER/DBI.pm
|
---|
| 117 | fi
|
---|
| 118 | if [ -d "$PERL_FOLDER/DBI" ]; then
|
---|
[32786] | 119 | rm -rf $PERL_FOLDER/DBI
|
---|
| 120 | fi
|
---|
[32788] | 121 | if [ -d "$PERL_FOLDER/auto/DBI" ]; then
|
---|
[32786] | 122 | rm -rf $PERL_FOLDER/auto/DBI
|
---|
| 123 | fi
|
---|
| 124 | echo "** Done cleaning DBI::DBD related packages"
|
---|
[32662] | 125 | popd
|
---|
| 126 | exit 0
|
---|
| 127 | fi
|
---|
| 128 |
|
---|
| 129 | # Go into $GSDLHOME
|
---|
| 130 | pushd $GSDLHOME
|
---|
| 131 |
|
---|
| 132 | # download and untar mysql into $GSDLHOME
|
---|
| 133 | if [ ! -d $GSDLHOME/$MYSQL_BIN ]; then
|
---|
| 134 | if [ ! -e $GSDLHOME/$MYSQL_TARBALL.tar.gz ]; then
|
---|
| 135 | echo "** Getting the mysql tarball"
|
---|
| 136 | wget $WGET_FLAGS $MYSQL_MIRROR/$MYSQL_TARBALL.tar.gz
|
---|
| 137 | fi
|
---|
| 138 | echo "** Extracting the mysql tarball into $GSDLHOME and renaming to $MYSQLBIN"
|
---|
| 139 | tar -xvzf $MYSQL_TARBALL.tar.gz
|
---|
| 140 | # there's 2 tarballs inside, untar the one with identical name to outer
|
---|
| 141 | # and rename to $GSDLHOME/mysql-5.7.23
|
---|
| 142 | # cd $MYSQL_TARBALL
|
---|
| 143 | # tar -xvzf $MYSQL_TARBALL.tar.gz
|
---|
| 144 | # cd $GSDLHOME
|
---|
| 145 | # mv $MYSQL_TARBALL/$MYSQL_TARBALL $GSDLHOME/$MYSQL_BIN
|
---|
| 146 | mv $MYSQL_TARBALL $GSDLHOME/$MYSQL_BIN
|
---|
| 147 | fi
|
---|
| 148 |
|
---|
| 149 | # copy just the static .a libraries into their own folder
|
---|
| 150 | if [ ! -d $TEMP_STATIC_LIBS_DIR ]; then
|
---|
[32786] | 151 | echo "** Creating $TEMP_STATIC_LIBS_DIR and copying $MYSQL_BIN/lib/*.a into it"
|
---|
| 152 | mkdir -p $TEMP_STATIC_LIBS_DIR
|
---|
[32662] | 153 | cp $GSDLHOME/$MYSQL_BIN/lib/*.a $TEMP_STATIC_LIBS_DIR/.
|
---|
| 154 | fi
|
---|
| 155 |
|
---|
[32788] | 156 | # Ensure a clean new temp folder to compile (DBI and) DBD into
|
---|
| 157 | echo "** Creating $TEMP_DBI_DBD_DIR (anew)"
|
---|
[32786] | 158 | if [ -d $TEMP_DBI_DBD_DIR ]; then
|
---|
| 159 | rm -rf $TEMP_DBI_DBD_DIR
|
---|
| 160 | fi
|
---|
| 161 | mkdir $TEMP_DBI_DBD_DIR
|
---|
| 162 |
|
---|
| 163 |
|
---|
[32788] | 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"
|
---|
[32786] | 177 |
|
---|
[32788] | 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
|
---|
[32786] | 199 | #echo "EXITING"
|
---|
| 200 | #exit
|
---|
| 201 |
|
---|
[32788] | 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"
|
---|
[32787] | 215 |
|
---|
[32788] | 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
|
---|
[32662] | 234 | fi
|
---|
| 235 |
|
---|
| 236 | # clean up
|
---|
| 237 | echo "*****************************"
|
---|
| 238 | echo "*** Done compiling DBD::mysql."
|
---|
| 239 | if [ "x$1" != "x--keep" ] ; then
|
---|
| 240 | echo "** Will now delete temporary DBD::mysql products, and the untarred DBD::mysql"
|
---|
[32786] | 241 | rm -rf $TEMP_DBI_DBD_DIR
|
---|
[32788] | 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
|
---|
[32662] | 248 | else
|
---|
[32786] | 249 | echo "** Not deleting the $TEMP_DBI_DBD_DIR"
|
---|
[32662] | 250 | fi
|
---|
[32788] | 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.
|
---|
[32662] | 253 | rm -rf $TEMP_STATIC_LIBS_DIR
|
---|
| 254 |
|
---|
| 255 |
|
---|
[32788] | 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
|
---|
| 263 |
|
---|
[32662] | 264 | # go back to where we started
|
---|
| 265 | popd
|
---|
| 266 |
|
---|
| 267 | echo "*****************************"
|
---|
| 268 | echo ""
|
---|
[32788] | 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
|
---|
[32662] | 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"
|
---|
| 277 | echo "** Once that's done, the same page has information on how to use the GreenstoneSQLPlugs in a collection"
|
---|
| 278 | echo ""
|
---|
| 279 | echo "*****************************"
|
---|
| 280 |
|
---|