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}-macos10.13-x86_64"
|
---|
43 |
|
---|
44 | # We want DBD::mysql version 4.033
|
---|
45 | DBD_MYSQL=DBD-mysql-4.033
|
---|
46 | DBD_MYSQL_DOWNLOAD=https://cpan.metacpan.org/authors/id/C/CA/CAPTTOFU/$DBD_MYSQL.tar.gz
|
---|
47 |
|
---|
48 |
|
---|
49 | ########################## DON'T CHANGE ####################
|
---|
50 | CPAN_DIR=$GSDLHOME/perllib/cpan
|
---|
51 |
|
---|
52 | # PERL_FOLDER is something like "perl-5.18" (even if the full version number is 5.18.2)
|
---|
53 | PERL_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
|
---|
56 | mkdir -p $CPAN_DIR/$PERL_FOLDER/auto
|
---|
57 |
|
---|
58 | WGET_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
|
---|
62 | TEMP_DBD_MYSQL_DIR=$CPAN_DIR/tmp-mysql
|
---|
63 | TEMP_STATIC_LIBS_DIR=$GSDLHOME/$MYSQL_BIN/mysql-static
|
---|
64 | MYSQL_DIR=$GSDLHOME/$MYSQL_BIN
|
---|
65 |
|
---|
66 |
|
---|
67 | ##########################
|
---|
68 |
|
---|
69 | # if clean was passed in
|
---|
70 | if [ "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
|
---|
81 | fi
|
---|
82 |
|
---|
83 | # Go into $GSDLHOME
|
---|
84 | pushd $GSDLHOME
|
---|
85 |
|
---|
86 | # download and untar mysql into $GSDLHOME
|
---|
87 | if [ ! -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
|
---|
101 | fi
|
---|
102 |
|
---|
103 | # copy just the static .a libraries into their own folder
|
---|
104 | if [ ! -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/.
|
---|
108 | fi
|
---|
109 |
|
---|
110 | # download and untar DBD::mysql v 4.033
|
---|
111 | if [ ! -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
|
---|
119 | fi
|
---|
120 |
|
---|
121 | # start compiling DBD::mysql into $TEMP_DBD_MYSQL_DIR
|
---|
122 | echo "** Creating $TEMP_DBD_MYSQL_DIR (anew) and compiling this perl package"
|
---|
123 |
|
---|
124 | if [ -d $TEMP_DBD_MYSQL_DIR ]; then
|
---|
125 | rm -rf $TEMP_DBD_MYSQL_DIR
|
---|
126 | fi
|
---|
127 | mkdir $TEMP_DBD_MYSQL_DIR
|
---|
128 |
|
---|
129 | cd $GSDLHOME/$DBD_MYSQL
|
---|
130 | perl Makefile.PL \
|
---|
131 | PREFIX=$TEMP_DBD_MYSQL_DIR \
|
---|
132 | --cflags=-I$GSDLHOME/$MYSQL_BIN/include \
|
---|
133 | --libs="-L$TEMP_STATIC_LIBS_DIR -lmysqlclient"
|
---|
134 | make
|
---|
135 | make install
|
---|
136 |
|
---|
137 |
|
---|
138 | # move built DBD::mysql products into correct CPAN location
|
---|
139 | echo "** Moving relevant DBD::mysql products into $CPAN_DIR/$PERL_FOLDER"
|
---|
140 | cd $CPAN_DIR
|
---|
141 | mv $TEMP_DBD_MYSQL_DIR/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/DBD $PERL_FOLDER/.
|
---|
142 | mv $TEMP_DBD_MYSQL_DIR/lib/perl5/site_perl/5.18.2/darwin-thread-multi-2level/auto/DBD $PERL_FOLDER/auto/.
|
---|
143 |
|
---|
144 | # clean up
|
---|
145 | echo "*****************************"
|
---|
146 | echo "*** Done compiling DBD::mysql."
|
---|
147 | if [ "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
|
---|
151 | else
|
---|
152 | echo "** Not deleting the $TEMP_DBD_MYSQL_DIR"
|
---|
153 | fi
|
---|
154 | rm -rf $TEMP_STATIC_LIBS_DIR
|
---|
155 |
|
---|
156 |
|
---|
157 | # go back to where we started
|
---|
158 | popd
|
---|
159 |
|
---|
160 | echo "*****************************"
|
---|
161 | echo ""
|
---|
162 | echo "** You now need to initialize the MySQL installation at $GSDLHOME/$MYSQL_BIN"
|
---|
163 | 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"
|
---|
164 | echo "** Once that's done, the same page has information on how to use the GreenstoneSQLPlugs in a collection"
|
---|
165 | echo ""
|
---|
166 | echo "*****************************"
|
---|
167 |
|
---|