1 | #!/bin/bash
|
---|
2 | # Used to merge in the code needed to add TDB support to Greenstone. The script
|
---|
3 | # is responsible for updating both Makefile.in and source code files. You can
|
---|
4 | # later run 'disable_tdb.sh' to undo these changes.
|
---|
5 | # @author John Thompson, University of Waikato, NZ
|
---|
6 |
|
---|
7 | echo
|
---|
8 | echo '===== Removing TDB support code from Greenstone ====='
|
---|
9 | echo
|
---|
10 |
|
---|
11 | # Test that GSDLHOME is set otherwise we won't be able to find the required files
|
---|
12 | if [ "${GSDLHOME}x" == "x" ]
|
---|
13 | then
|
---|
14 | echo 'Error! GSDLHOME not set. Please source setup.bash before running.'
|
---|
15 | echo
|
---|
16 | exit 0
|
---|
17 | fi
|
---|
18 | if [ "${GSDLOS}x" == "x" ]
|
---|
19 | then
|
---|
20 | echo 'Error! GSDLOS not set. Please source setup.bash before running.'
|
---|
21 | echo
|
---|
22 | exit 0
|
---|
23 | fi
|
---|
24 |
|
---|
25 | # Black magic to determine the actual name of the extension folder (in case I
|
---|
26 | # change from tdb-edit to tdb in the future (writing in hindsight))
|
---|
27 | EXTDIR=${PWD}
|
---|
28 | EXTNAME=${PWD##*/}
|
---|
29 |
|
---|
30 | printf ' * Removing TDB support from common function library... '
|
---|
31 | # - Makefile.in
|
---|
32 | MAKEFILE="${GSDLHOME}/common-src/src/lib/Makefile.in"
|
---|
33 | sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
|
---|
34 | sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I'${EXTDIR}'/'${GSDLOS}'/include\(.*\):\1\2:' "${MAKEFILE}"
|
---|
35 | sed -i 's:\(EXT_SOURCES\s*=.*\)\stdbclass.cpp\(.*\):\1\2:' "${MAKEFILE}"
|
---|
36 | sed -i 's:\(EXT_OBJECTS\s*=.*\)\stdbclass.o\(.*\):\1\2:' "${MAKEFILE}"
|
---|
37 | # (note - NOT Makefile.in ...)
|
---|
38 | rm -f "${GSDLHOME}/common-src/src/lib/Makefile"
|
---|
39 | # - Remove symlink
|
---|
40 | rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.h"
|
---|
41 | rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.cpp"
|
---|
42 | # - Remove compiled files
|
---|
43 | rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.o"
|
---|
44 | rm -f "${GSDLHOME}/common-src/src/lib/gsdllib.a"
|
---|
45 | echo 'Done!'
|
---|
46 |
|
---|
47 | if [ "${GSDL3HOME}x" == "x" ]
|
---|
48 | then
|
---|
49 | printf ' * Removing TDB support from collection server... '
|
---|
50 | # - Makefile.in
|
---|
51 | MAKEFILE="${GSDLHOME}/runtime-src/src/colservr/Makefile.in"
|
---|
52 | sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
|
---|
53 | sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
|
---|
54 | rm -f "${GSDLHOME}/runtime-src/src/colservr/Makefile"
|
---|
55 | # - collectset.cpp
|
---|
56 | # BUG: leaves behind the newlines...
|
---|
57 | SRCFILE="${GSDLHOME}/runtime-src/src/colservr/collectset.cpp"
|
---|
58 | sed -i '/^#include "tdbclass.h" \/\/TDB/ d' "${SRCFILE}"
|
---|
59 | sed -i '/^[ ]*if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} \/\/TDB/ d' "${SRCFILE}"
|
---|
60 | sed -i '/^[ ]*if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} \/\/TDBServer/ d' "${SRCFILE}"
|
---|
61 | # - collectserver.cpp
|
---|
62 | SRCFILE="${GSDLHOME}/runtime-src/src/colservr/collectserver.cpp"
|
---|
63 | sed -i '/^if (infodbtype == "tdb") { } \/\/ TDB Do nothing/ d' "${SRCFILE}"
|
---|
64 | sed -i '/^if (infodbtype == "tdbserver") { } \/\/ TDBServer Do nothing/ d' "${SRCFILE}"
|
---|
65 | # - Remove compiled files
|
---|
66 | rm -f "${GSDLHOME}/runtime-src/src/colservr/gsdlcolservr.a"
|
---|
67 | echo 'Done!'
|
---|
68 |
|
---|
69 | printf ' * Removing TDB support from Greenstone receptionist... '
|
---|
70 | # - Makefile.in
|
---|
71 | MAKEFILE="${GSDLHOME}/runtime-src/src/recpt/Makefile.in"
|
---|
72 | sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
|
---|
73 | sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
|
---|
74 | sed -i 's:\(EXT_LDFLAGS\s*=.*\)\s-L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib\(.*\):\1\2:' "${MAKEFILE}"
|
---|
75 | sed -i 's:\(EXT_LIBS\s*=.*\)\s-ltdb\(.*\):\1\2:' "${MAKEFILE}"
|
---|
76 | rm -f "${GSDLHOME}/runtime-src/src/recpt/Makefile"
|
---|
77 | # - Remove compiled files
|
---|
78 | rm -f "${GSDLHOME}/runtime-src/src/recpt/gsdlrecpt.a"
|
---|
79 | rm -f "${GSDLHOME}/runtime-src/src/recpt/library.cgi"
|
---|
80 | rm -f "${GSDLHOME}/cgi-bin/library.cgi"
|
---|
81 | echo 'Done!'
|
---|
82 |
|
---|
83 | printf ' * Removing TDB support from OAI Server receptionist... '
|
---|
84 | # - Makefile.in
|
---|
85 | MAKEFILE="${GSDLHOME}/runtime-src/src/oaiservr/Makefile.in"
|
---|
86 | sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
|
---|
87 | sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
|
---|
88 | sed -i 's:\(EXT_LDFLAGS\s*=.*\)\s-L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib\(.*\):\1\2:' "${MAKEFILE}"
|
---|
89 | sed -i 's:\(EXT_LIBS\s*=.*\)\s-ltdb\(.*\):\1\2:' "${MAKEFILE}"
|
---|
90 | rm -f "${GSDLHOME}/runtime-src/src/oaiservr/Makefile"
|
---|
91 | # - Remove compiled files
|
---|
92 | rm -f "${GSDLHOME}/runtime-src/src/oaiservr/oaiserver.cgi"
|
---|
93 | rm -f "${GSDLHOME}/cgi-bin/oaiserver.cgi"
|
---|
94 | echo 'Done!'
|
---|
95 | else
|
---|
96 | echo ' * TDB runtime support offered via Java/JNI/TDB bridge.'
|
---|
97 | fi
|
---|
98 |
|
---|
99 | echo
|
---|
100 | echo '====================================================='
|
---|
101 | echo
|
---|
102 | echo 'TDB support has now been removed from Greenstone.'
|
---|
103 | echo 'Please return to the main Greenstone directory and'
|
---|
104 | echo 'rerun:'
|
---|
105 | echo
|
---|
106 | if [ "${GSDL3HOME}x" == "x" ]
|
---|
107 | then
|
---|
108 | echo ' ./configure <any required arguments>'
|
---|
109 | echo ' make'
|
---|
110 | echo ' make install'
|
---|
111 | else
|
---|
112 | echo ' ant install'
|
---|
113 | fi
|
---|
114 | echo
|
---|
115 | echo 'to complete TDB removal.'
|
---|
116 | echo
|
---|
117 | echo 'Should you later wish to restore TDB support rerun:'
|
---|
118 | echo
|
---|
119 | echo ' ./enable_tdb.sh'
|
---|
120 | echo
|
---|
121 | echo '====================================================='
|
---|
122 | echo
|
---|
123 |
|
---|
124 | exit 0
|
---|