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

Last change on this file since 32662 was 32662, checked in by ak19, 2 years ago

MacOS 10.13/High Sierra script for compiling DBD::mysql v 4.033, which first installs a mysql 5.7.23 binary installation into GSDLHOME as this includes headers and static libraries that the DBD::mysql perl package needs to build against.

  • Property svn:executable set to *
File size: 5.6 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
42MYSQL_TARBALL="${MYSQL_BIN}-macos10.13-x86_64"
43
44# We want DBD::mysql version 4.033
45DBD_MYSQL=DBD-mysql-4.033
46DBD_MYSQL_DOWNLOAD=https://cpan.metacpan.org/authors/id/C/CA/CAPTTOFU/$DBD_MYSQL.tar.gz
47
48
49########################## DON'T CHANGE ####################
50CPAN_DIR=$GSDLHOME/perllib/cpan
51
52# PERL_FOLDER is something like "perl-5.18" (even if the full version number is 5.18.2)
53PERL_FOLDER=`perl -e 'print "perl-5.".substr($],3,2);'`
54
55# make the dirs cpan/$PERL_FOLDER and its subdir auto if they don't already exist
56mkdir -p $CPAN_DIR/$PERL_FOLDER/auto
57
58WGET_FLAGS=--no-check-certificate
59# folder where we'll put the downloaded files, the compile products and the temporary install products
60# after everything is installed there, we copy just the relevant installed files to their final locations
61# then the tmp file gets deleted
62TEMP_DBD_MYSQL_DIR=$CPAN_DIR/tmp-mysql
63TEMP_STATIC_LIBS_DIR=$GSDLHOME/$MYSQL_BIN/mysql-static
64MYSQL_DIR=$GSDLHOME/$MYSQL_BIN
65
66
67##########################
68
69# if clean was passed in
70if [ "x$1" = "x--clean" ] ; then
71 pushd $CPAN_DIR
72 if [ -e "$PERL_FOLDER/DBD" ]; then
73 rm -rf $PERL_FOLDER/DBD
74 fi
75 if [ -e "$PERL_FOLDER/auto/DBD" ]; then
76 rm -rf $PERL_FOLDER/auto/DBD
77 fi
78 echo "** Done cleaning DBD::mysql related packages"
79 popd
80 exit 0
81fi
82
83# Go into $GSDLHOME
84pushd $GSDLHOME
85
86# download and untar mysql into $GSDLHOME
87if [ ! -d $GSDLHOME/$MYSQL_BIN ]; then
88 if [ ! -e $GSDLHOME/$MYSQL_TARBALL.tar.gz ]; then
89 echo "** Getting the mysql tarball"
90 wget $WGET_FLAGS $MYSQL_MIRROR/$MYSQL_TARBALL.tar.gz
91 fi
92 echo "** Extracting the mysql tarball into $GSDLHOME and renaming to $MYSQLBIN"
93 tar -xvzf $MYSQL_TARBALL.tar.gz
94 # there's 2 tarballs inside, untar the one with identical name to outer
95 # and rename to $GSDLHOME/mysql-5.7.23
96# cd $MYSQL_TARBALL
97# tar -xvzf $MYSQL_TARBALL.tar.gz
98# cd $GSDLHOME
99# mv $MYSQL_TARBALL/$MYSQL_TARBALL $GSDLHOME/$MYSQL_BIN
100 mv $MYSQL_TARBALL $GSDLHOME/$MYSQL_BIN
101fi
102
103# copy just the static .a libraries into their own folder
104if [ ! -d $TEMP_STATIC_LIBS_DIR ]; then
105 echo "** Creating $TEMP_STATIC_LIBS_DIR and copying $MYSQL_BIN/lib/* into it"
106 mkdir $TEMP_STATIC_LIBS_DIR
107 cp $GSDLHOME/$MYSQL_BIN/lib/*.a $TEMP_STATIC_LIBS_DIR/.
108fi
109
110# download and untar DBD::mysql v 4.033
111if [ ! -d $GSDLHOME/$DBD_MYSQL ]; then
112 cd $GSDLHOME
113 if [ ! -e $GSDLHOME/$DBD_MYSQL.tar.gz ]; then
114 echo "** Getting the DBD::mysql tarball"
115 wget $WGET_FLAGS $DBD_MYSQL_DOWNLOAD
116 fi
117 echo "** Extracting the DBD mysql tarball into $GSDLHOME"
118 tar -xvzf $DBD_MYSQL.tar.gz
119fi
120
121# start compiling DBD::mysql into $TEMP_DBD_MYSQL_DIR
122echo "** Creating $TEMP_DBD_MYSQL_DIR (anew) and compiling this perl package"
123
124if [ -d $TEMP_DBD_MYSQL_DIR ]; then
125 rm -rf $TEMP_DBD_MYSQL_DIR
126fi
127mkdir $TEMP_DBD_MYSQL_DIR
128
129cd $GSDLHOME/$DBD_MYSQL
130perl Makefile.PL \
131 PREFIX=$TEMP_DBD_MYSQL_DIR \
132 --cflags=-I$GSDLHOME/$MYSQL_BIN/include \
133 --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient"
134make
135make install
136
137
138# move built DBD::mysql products into correct CPAN location
139echo "** Moving relevant DBD::mysql products into $CPAN_DIR/$PERL_FOLDER"
140cd $CPAN_DIR
141mv $TEMP_DBD_MYSQL_DIR/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/DBD $PERL_FOLDER/.
142mv $TEMP_DBD_MYSQL_DIR/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/auto/DBD $PERL_FOLDER/auto/.
143
144# clean up
145echo "*****************************"
146echo "*** Done compiling DBD::mysql."
147if [ "x$1" != "x--keep" ] ; then
148 echo "** Will now delete temporary DBD::mysql products, and the untarred DBD::mysql"
149 rm -rf $TEMP_DBD_MYSQL_DIR
150 rm -rf $GSDLHOME/$DBD_MYSQL
151else
152 echo "** Not deleting the $TEMP_DBD_MYSQL_DIR"
153fi
154rm -rf $TEMP_STATIC_LIBS_DIR
155
156
157# go back to where we started
158popd
159
160echo "*****************************"
161echo ""
162echo "** You now need to initialize the MySQL installation at $GSDLHOME/$MYSQL_BIN"
163echo "** Follow the instructions from STEP 2 ONWARDS at at http://wiki.greenstone.org/doku.php?id=en:user_advanced:greenstonesqlplugs#installing_one_time_setup"
164echo "** Once that's done, the same page has information on how to use the GreenstoneSQLPlugs in a collection"
165echo ""
166echo "*****************************"
167
Note: See TracBrowser for help on using the repository browser.