Index: /main/trunk/greenstone2/perllib/cpan/compile-dbd-mysql.sh
===================================================================
--- /main/trunk/greenstone2/perllib/cpan/compile-dbd-mysql.sh	(revision 32785)
+++ /main/trunk/greenstone2/perllib/cpan/compile-dbd-mysql.sh	(revision 32786)
@@ -40,5 +40,12 @@
 MYSQL_BIN=mysql-5.7.23
 MYSQL_MIRROR=http://mysql.inspire.net.nz/Downloads/MySQL-5.7
+#MYSQL_TARBALL="${MYSQL_BIN}-linux-glibc2.12-x86_64"
 MYSQL_TARBALL="${MYSQL_BIN}-macos10.13-x86_64"
+
+# We want DBI::mysql version 1.634
+# see http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs
+# and https://metacpan.org/pod/release/TIMB/DBI-1.634/lib/DBI/DBD.pm
+DBI_MYSQL=DBI-1.634
+DBI_MYSQL_DOWNLOAD=https://cpan.metacpan.org/authors/id/T/TI/TIMB/$DBI_MYSQL.tar.gz
 
 # We want DBD::mysql version 4.033
@@ -51,5 +58,8 @@
 
 # PERL_FOLDER is something like "perl-5.18" (even if the full version number is 5.18.2)
-PERL_FOLDER=`perl -e 'print "perl-5.".substr($],3,2);'`
+PERL_VERSION=`perl -e 'print "5.".substr($],3,2);'`
+# full perl version number like 5.18.2 or 5.22.1 (actually "5 version 22 subversion 1)
+PERL_FULL_VERSION=`perl -e 'print "5.".substr($],3,2).".".substr($],7,1);'`
+PERL_FOLDER="perl-${PERL_VERSION}" #`perl -e 'print "perl-5.".substr($],3,2);'`
 
 # make the dirs cpan/$PERL_FOLDER and its subdir auto if they don't already exist
@@ -60,5 +70,5 @@
 # after everything is installed there, we copy just the relevant installed files to their final locations
 # then the tmp file gets deleted
-TEMP_DBD_MYSQL_DIR=$CPAN_DIR/tmp-mysql
+TEMP_DBI_DBD_DIR=$CPAN_DIR/tmp-mysql
 TEMP_STATIC_LIBS_DIR=$GSDLHOME/$MYSQL_BIN/mysql-static
 MYSQL_DIR=$GSDLHOME/$MYSQL_BIN
@@ -67,5 +77,5 @@
 ##########################
 
-# if clean was passed in
+# if --clean was passed in
 if [ "x$1" = "x--clean" ] ; then
     pushd $CPAN_DIR
@@ -77,4 +87,12 @@
     fi
     echo "** Done cleaning DBD::mysql related packages"
+
+    if [ -e "$PERL_FOLDER/DBI" ]; then
+	rm -rf $PERL_FOLDER/DBI
+    fi
+    if [ -e "$PERL_FOLDER/auto/DBI" ]; then
+	rm -rf $PERL_FOLDER/auto/DBI
+    fi
+    echo "** Done cleaning DBI::DBD related packages"
     popd
     exit 0
@@ -103,8 +121,43 @@
 # copy just the static .a libraries into their own folder
 if [ ! -d $TEMP_STATIC_LIBS_DIR ]; then
-    echo "** Creating $TEMP_STATIC_LIBS_DIR and copying $MYSQL_BIN/lib/* into it"
-    mkdir $TEMP_STATIC_LIBS_DIR
+    echo "** Creating $TEMP_STATIC_LIBS_DIR and copying $MYSQL_BIN/lib/*.a into it"
+    mkdir -p $TEMP_STATIC_LIBS_DIR
     cp $GSDLHOME/$MYSQL_BIN/lib/*.a $TEMP_STATIC_LIBS_DIR/.
 fi
+
+# download and untar DBI::DBD v 1.634
+if [ ! -d $GSDLHOME/$DBI_MYSQL ]; then
+    cd $GSDLHOME
+    if [ ! -e $GSDLHOME/$DBI_MYSQL.tar.gz ]; then
+	echo "** Getting the DBI::DBD tarball"
+	wget $WGET_FLAGS $DBI_MYSQL_DOWNLOAD
+    fi
+    echo "** Extracting the DBI::DBD tarball into $GSDLHOME"
+    tar -xvzf $DBI_MYSQL.tar.gz
+fi
+# start compiling DBI::DBD into $TEMP_DBI_DBD_DIR
+echo "** Creating $TEMP_DBI_DBD_DIR (anew) and compiling this perl package"
+
+if [ -d $TEMP_DBI_DBD_DIR ]; then
+    rm -rf $TEMP_DBI_DBD_DIR
+fi
+mkdir $TEMP_DBI_DBD_DIR
+
+cd $GSDLHOME/$DBI_MYSQL
+perl Makefile.PL \
+    PREFIX=$TEMP_DBI_DBD_DIR
+    --cflags=-I$GSDLHOME/$MYSQL_BIN/include \
+    --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient"
+make
+make install
+
+# move built DBI::DBD products into correct CPAN location
+echo "** Moving relevant DBI::DBD products into $CPAN_DIR/$PERL_FOLDER"
+cd $CPAN_DIR
+mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBI $PERL_FOLDER/.
+mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/auto/DBI $PERL_FOLDER/auto/.
+
+#echo "EXITING"
+#exit
 
 # download and untar DBD::mysql v 4.033
@@ -118,16 +171,10 @@
     tar -xvzf $DBD_MYSQL.tar.gz
 fi
-
-# start compiling DBD::mysql into $TEMP_DBD_MYSQL_DIR
-echo "** Creating $TEMP_DBD_MYSQL_DIR (anew) and compiling this perl package"
-
-if [ -d $TEMP_DBD_MYSQL_DIR ]; then
-    rm -rf $TEMP_DBD_MYSQL_DIR
-fi
-mkdir $TEMP_DBD_MYSQL_DIR
+# start compiling DBD::mysql into $TEMP_DBI_DBD_DIR
+echo "** Compiling this perl package"
 
 cd $GSDLHOME/$DBD_MYSQL
 perl Makefile.PL \
-    PREFIX=$TEMP_DBD_MYSQL_DIR \
+    PREFIX=$TEMP_DBI_DBD_DIR \
     --cflags=-I$GSDLHOME/$MYSQL_BIN/include \
     --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient"
@@ -139,6 +186,6 @@
 echo "** Moving relevant DBD::mysql products into $CPAN_DIR/$PERL_FOLDER"
 cd $CPAN_DIR
-mv $TEMP_DBD_MYSQL_DIR/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/DBD $PERL_FOLDER/.
-mv $TEMP_DBD_MYSQL_DIR/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/auto/DBD $PERL_FOLDER/auto/.
+mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_VERSION/darwin-thread-multi-2level/DBD $PERL_FOLDER/.
+mv $TEMP_DBI_DBD_DIR/lib/perl5/site_perl/$PERL_FULL_SUBVERSION/darwin-thread-multi-2level/auto/DBD $PERL_FOLDER/auto/.
 
 # clean up
@@ -147,8 +194,9 @@
 if [ "x$1" != "x--keep" ] ; then
     echo "** Will now delete temporary DBD::mysql products, and the untarred DBD::mysql"
-    rm -rf $TEMP_DBD_MYSQL_DIR
+    rm -rf $TEMP_DBI_DBD_DIR
+    rm -rf $GSDLHOME/$DBI_MYSQL
     rm -rf $GSDLHOME/$DBD_MYSQL
 else
-    echo "**   Not deleting the $TEMP_DBD_MYSQL_DIR"
+    echo "**   Not deleting the $TEMP_DBI_DBD_DIR"
 fi
 rm -rf $TEMP_STATIC_LIBS_DIR
