root/gs2-extensions/tdb/trunk/disable_tdb.sh @ 30239

Revision 30239, 4.7 KB (checked in by jmt12, 5 years ago)

Correcting paths for project name change and making script a little safer by enclosing variable names in braces and paths in quotes (in case they contain spaces)

  • Property svn:executable set to *
Line 
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
7echo
8echo '===== Removing TDB support code from Greenstone ====='
9echo
10
11# Test that GSDLHOME is set otherwise we won't be able to find the required files
12if [ "${GSDLHOME}x" == "x" ] ; then echo 'Error! GSDLHOME not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi
13if [ "${GSDLOS}x" == "x" ] ; then echo 'Error! GSDLOS not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi
14
15# Black magic to determine the actual name of the extension folder (in case I
16# change from tdb-edit to tdb in the future (writing in hindsight))
17EXTNAME=${PWD##*/}
18
19echo ' - removing TDB support from common function library'
20# - Makefile.in
21MAKEFILE="${GSDLHOME}/common-src/src/lib/Makefile.in"
22sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
23sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
24sed -i 's:\(EXT_SOURCES\s*=.*\)\stdbclass.cpp\(.*\):\1\2:' "${MAKEFILE}"
25sed -i 's:\(EXT_OBJECTS\s*=.*\)\stdbclass.o\(.*\):\1\2:' "${MAKEFILE}"
26# (note - NOT Makefile.in ...)
27rm -f "${GSDLHOME}/common-src/src/lib/Makefile"
28# - Remove symlink
29rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.h"
30rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.cpp"
31# - Remove compiled files
32rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.o"
33rm -f "${GSDLHOME}/common-src/src/lib/gsdllib.a"
34
35
36echo ' - removing TDB support from collection server'
37# - Makefile.in
38MAKEFILE="${GSDLHOME}/runtime-src/src/colservr/Makefile.in"
39sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
40sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
41rm -f "${GSDLHOME}/runtime-src/src/colservr/Makefile"
42# - collectset.cpp
43# BUG: leaves behind the newlines...
44SRCFILE="${GSDLHOME}/runtime-src/src/colservr/collectset.cpp"
45sed -i '/^#include "tdbclass.h" \/\/TDB/ d' "${SRCFILE}"
46sed -i '/^[ ]*if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} \/\/TDB/ d' "${SRCFILE}"
47sed -i '/^[ ]*if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} \/\/TDBServer/ d' "${SRCFILE}"
48# - collectserver.cpp
49SRCFILE="${GSDLHOME}/runtime-src/src/colservr/collectserver.cpp"
50sed -i '/^if (infodbtype == "tdb") { } \/\/ TDB Do nothing/ d' "${SRCFILE}"
51sed -i '/^if (infodbtype == "tdbserver") { } \/\/ TDBServer Do nothing/ d' "${SRCFILE}"
52# - Remove compiled files
53rm -f "${GSDLHOME}/runtime-src/src/colservr/gsdlcolservr.a"
54
55
56echo ' - removing TDB support from Greenstone receptionist'
57# - Makefile.in
58MAKEFILE="${GSDLHOME}/runtime-src/src/recpt/Makefile.in"
59sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
60sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
61sed -i 's:\(EXT_LDFLAGS\s*=.*\)\s-L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib\(.*\):\1\2:' "${MAKEFILE}"
62sed -i 's:\(EXT_LIBS\s*=.*\)\s-ltdb\(.*\):\1\2:' "${MAKEFILE}"
63rm -f "${GSDLHOME}/runtime-src/src/recpt/Makefile"
64# - Remove compiled files
65rm -f "${GSDLHOME}/runtime-src/src/recpt/gsdlrecpt.a"
66rm -f "${GSDLHOME}/runtime-src/src/recpt/library.cgi"
67rm -f "${GSDLHOME}/cgi-bin/library.cgi"
68
69
70echo ' - removing TDB support from OAI Server receptionist'
71# - Makefile.in
72MAKEFILE="${GSDLHOME}/runtime-src/src/oaiservr/Makefile.in"
73sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' "${MAKEFILE}"
74sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include\s*-I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\(.*\):\1\2:' "${MAKEFILE}"
75sed -i 's:\(EXT_LDFLAGS\s*=.*\)\s-L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib\(.*\):\1\2:' "${MAKEFILE}"
76sed -i 's:\(EXT_LIBS\s*=.*\)\s-ltdb\(.*\):\1\2:' "${MAKEFILE}"
77rm -f "${GSDLHOME}/runtime-src/src/oaiservr/Makefile"
78# - Remove compiled files
79rm -f "${GSDLHOME}/runtime-src/src/oaiservr/oaiserver.cgi"
80rm -f "${GSDLHOME}/cgi-bin/oaiserver.cgi"
81
82echo
83echo '====================================================='
84echo
85echo 'TDB support has now been removed from Greenstone.'
86echo 'Please return to the main Greenstone directory and'
87echo 'rerun:'
88echo
89echo ' ./configure <any required arguments>'
90echo ' make'
91echo ' make install'
92echo
93echo 'to complete TDB removal.'
94echo
95echo 'Should you later wish to restore TDB support rerun:'
96echo
97echo ' ./enable_tdb.sh'
98echo
99echo '====================================================='
100echo
101
102exit 0
Note: See TracBrowser for help on using the browser.