Changeset 30239

Show
Ignore:
Timestamp:
09.09.2015 13:44:47 (4 years ago)
Author:
jmt12
Message:

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)

Location:
gs2-extensions/tdb/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gs2-extensions/tdb/trunk/disable_tdb.sh

    r30182 r30239  
    1010 
    1111# Test that GSDLHOME is set otherwise we won't be able to find the required files 
    12 if [ "$GSDLHOME" == "" ] ; then echo 'Error! GSDLHOME not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi 
     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 
    1314 
     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##*/} 
    1418 
    1519echo ' - removing TDB support from common function library' 
    1620# - Makefile.in 
    17 sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' $GSDLHOME/common-src/src/lib/Makefile.in 
    18 sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/tdb-edit/linux/include\s*-I$(GSDL_DIR)/ext/tdb-edit/darwin/include\s*-I$(GSDL_DIR)/ext/tdb-edit/src/lib\(.*\):\1\2:' $GSDLHOME/common-src/src/lib/Makefile.in 
    19 sed -i 's:\(EXT_SOURCES\s*=.*\)\stdbclass.cpp\(.*\):\1\2:' $GSDLHOME/common-src/src/lib/Makefile.in 
    20 sed -i 's:\(EXT_OBJECTS\s*=.*\)\stdbclass.o\(.*\):\1\2:' $GSDLHOME/common-src/src/lib/Makefile.in 
    21 rm -f $GSDLHOME/common-src/src/lib/Makefile 
     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" 
    2228# - Remove symlink 
    23 rm -f $GSDLHOME/common-src/src/lib/tdbclass.h 
    24 rm -f $GSDLHOME/common-src/src/lib/tdbclass.cpp 
     29rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.h" 
     30rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.cpp" 
    2531# - Remove compiled files 
    26 rm -f $GSDLHOME/common-src/src/lib/tdbclass.o 
    27 rm -f $GSDLHOME/common-src/src/lib/gsdllib.a 
     32rm -f "${GSDLHOME}/common-src/src/lib/tdbclass.o" 
     33rm -f "${GSDLHOME}/common-src/src/lib/gsdllib.a" 
    2834 
    2935 
    3036echo ' - removing TDB support from collection server' 
    3137# - Makefile.in 
    32 sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' $GSDLHOME/runtime-src/src/colservr/Makefile.in 
    33 sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/tdb-edit/linux/include\s*-I$(GSDL_DIR)/ext/tdb-edit/darwin/include\s*-I$(GSDL_DIR)/ext/tdb-edit/src/lib\(.*\):\1\2:' $GSDLHOME/runtime-src/src/colservr/Makefile.in 
    34 rm -f $GSDLHOME/runtime-src/src/colservr/Makefile 
     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" 
    3542# - collectset.cpp 
    3643# BUG: leaves behind the newlines... 
    37 sed -i '/^#include "tdbclass.h" \/\/TDB/ d' $GSDLHOME/runtime-src/src/colservr/collectset.cpp 
    38 sed -i '/^[ ]*if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} \/\/TDB/ d' $GSDLHOME/runtime-src/src/colservr/collectset.cpp 
    39 sed -i '/^[ ]*if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} \/\/TDBServer/ d' $GSDLHOME/runtime-src/src/colservr/collectset.cpp 
     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}" 
    4048# - collectserver.cpp 
    41 sed -i '/^if (infodbtype == "tdb") { } \/\/ TDB Do nothing/ d' $GSDLHOME/runtime-src/src/colservr/collectset.cpp 
    42 sed -i '/^if (infodbtype == "tdbserver") { } \/\/ TDBServer Do nothing/ d' $GSDLHOME/runtime-src/src/colservr/collectset.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}" 
    4352# - Remove compiled files 
    44 rm -f $GSDLHOME/runtime-src/src/colservr/gsdlcolservr.a 
    45  
    46  
     53rm -f "${GSDLHOME}/runtime-src/src/colservr/gsdlcolservr.a" 
    4754 
    4855 
    4956echo ' - removing TDB support from Greenstone receptionist' 
    5057# - Makefile.in 
    51 sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' $GSDLHOME/runtime-src/src/recpt/Makefile.in 
    52 sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/tdb-edit/linux/include\s*-I$(GSDL_DIR)/ext/tdb-edit/darwin/include\s*-I$(GSDL_DIR)/ext/tdb-edit/src/lib\(.*\):\1\2:' $GSDLHOME/runtime-src/src/recpt/Makefile.in 
    53 sed -i 's:\(EXT_LDFLAGS\s*=.*\)\s-L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib\(.*\):\1\2:' $GSDLHOME/runtime-src/src/recpt/Makefile.in 
    54 sed -i 's:\(EXT_LIBS\s*=.*\)\s-ltdb\(.*\):\1\2:' $GSDLHOME/runtime-src/src/recpt/Makefile.in 
    55 rm -f $GSDLHOME/runtime-src/src/recpt/Makefile 
     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" 
    5664# - Remove compiled files 
    57 rm -f $GSDLHOME/runtime-src/src/recpt/gsdlrecpt.a 
    58 rm -f $GSDLHOME/runtime-src/src/recpt/library.cgi 
    59 rm -f $GSDLHOME/cgi-bin/library.cgi 
     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" 
    6068 
    6169 
    6270echo ' - removing TDB support from OAI Server receptionist' 
    6371# - Makefile.in 
    64 sed -i 's:\(EXT_DEFINES\s*=.*\)\s-DUSE_TDB\(.*\):\1\2:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
    65 sed -i 's:\(EXT_INCLUDES\s*=.*\)\s-I$(GSDL_DIR)/ext/tdb-edit/linux/include\s*-I$(GSDL_DIR)/ext/tdb-edit/darwin/include\s*-I$(GSDL_DIR)/ext/tdb-edit/src/lib\(.*\):\1\2:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
    66 sed -i 's:\(EXT_LDFLAGS\s*=.*\)\s-L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib\(.*\):\1\2:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
    67 sed -i 's:\(EXT_LIBS\s*=.*\)\s-ltdb\(.*\):\1\2:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
    68 rm -f $GSDLHOME/runtime-src/src/oaiservr/Makefile 
     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" 
    6978# - Remove compiled files 
    70 rm -f $GSDLHOME/runtime-src/src/oaiservr/oaiserver.cgi 
    71 rm -f $GSDLHOME/cgi-bin/oaiserver.cgi 
     79rm -f "${GSDLHOME}/runtime-src/src/oaiservr/oaiserver.cgi" 
     80rm -f "${GSDLHOME}/cgi-bin/oaiserver.cgi" 
    7281 
    7382echo 
     
    8493echo 'to complete TDB removal.' 
    8594echo 
     95echo 'Should you later wish to restore TDB support rerun:' 
     96echo 
     97echo ' ./enable_tdb.sh' 
     98echo 
    8699echo '=====================================================' 
    87100echo 
  • gs2-extensions/tdb/trunk/enable_tdb.sh

    r30183 r30239  
    1010 
    1111# Test that GSDLHOME is set otherwise we won't be able to find the required files 
    12 if [ "$GSDLHOME" == "" ] ; then echo 'Error! GSDLHOME not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi 
     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##*/} 
    1318 
    1419echo ' - enabling TDB support in common function library' 
    1520# - Symlink the source file into place 
    16 ln -f -s $GSDLHOME/ext/tdb-edit/src/lib/tdbclass.h $GSDLHOME/common-src/src/lib/tdbclass.h 
    17 ln -f -s $GSDLHOME/ext/tdb-edit/src/lib/tdbclass.cpp $GSDLHOME/common-src/src/lib/tdbclass.cpp 
    18 # - Makefile.in 
    19 MAKEFILE=$GSDLHOME/common-src/src/lib/Makefile.in 
     21ln -f -s "${GSDLHOME}/ext/${EXTNAME}/src/lib/tdbclass.h" "${GSDLHOME}/common-src/src/lib/tdbclass.h" 
     22ln -f -s "${GSDLHOME}/ext/${EXTNAME}/src/lib/tdbclass.cpp" "${GSDLHOME}/common-src/src/lib/tdbclass.cpp" 
     23# - Makefile.in 
     24MAKEFILE="${GSDLHOME}/common-src/src/lib/Makefile.in" 
    2025# - I have no idea why this is commented out in the Makefile 
    21 sed -i 's:#GSDL_DIR = ../../..:GSDL_DIR = ../../..:' ${MAKEFILE} 
    22 grep -q 'DUSE_TDB' ${MAKEFILE} 
     26sed -i 's:#GSDL_DIR = ../../..:GSDL_DIR = ../../..:' "${MAKEFILE}" 
     27grep -q 'DUSE_TDB' "${MAKEFILE}" 
    2328if [ $? -eq 1 ] 
    2429then 
    2530  # - Test for extension support in the makefile 
    26   grep -q 'EXT_DEFINES' ${MAKEFILE} 
     31  grep -q 'EXT_DEFINES' "${MAKEFILE}" 
    2732  if [ $? -eq 1 ] 
    2833  then 
    2934    # - No Extension variables yet - add them in with TDB parts 
    30     sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib\nEXT_SOURCES = tdbclass.cpp\nEXT_OBJECTS = tdbclass.o\n\n&:' ${MAKEFILE} 
    31     sed -i 's:DEFS = @DEFS@ .*:& $(EXT_DEFINES):' ${MAKEFILE} 
    32     sed -i 's:INCLUDES = -I. .*:& $(EXT_INCLUDES):' ${MAKEFILE} 
    33     sed -i 's:unitool.cpp:& \\\n        $(EXT_SOURCES):' ${MAKEFILE} 
    34     sed -i 's:unitool.o:& \\\n        $(EXT_OBJECTS):' ${MAKEFILE} 
     35    sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\nEXT_SOURCES = tdbclass.cpp\nEXT_OBJECTS = tdbclass.o\n\n&:' "${MAKEFILE}" 
     36    sed -i 's:DEFS = @DEFS@ .*:& $(EXT_DEFINES):' "${MAKEFILE}" 
     37    sed -i 's:INCLUDES = -I. .*:& $(EXT_INCLUDES):' "${MAKEFILE}" 
     38    sed -i 's:unitool.cpp:& \\\n        $(EXT_SOURCES):' "${MAKEFILE}" 
     39    sed -i 's:unitool.o:& \\\n        $(EXT_OBJECTS):' "${MAKEFILE}" 
    3540  else 
    3641    # - Extension support already present - add TDB parts 
    37     sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' ${MAKEFILE} 
    38     sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib:' ${MAKEFILE} 
    39     sed -i 's:EXT_SOURCES =.*:& tdbclass.cpp:' ${MAKEFILE} 
    40     sed -i 's:EXT_OBJECTS =.*:& tdbclass.o:' ${MAKEFILE} 
    41   fi 
    42 fi 
    43 grep -q 'DUSE_TDB' ${MAKEFILE} 
    44 if [ $? -eq 1 ] 
    45 then 
    46   echo Error! Update of ${MAKEFILE} failed. 
     42    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}" 
     43    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}" 
     44    sed -i 's:EXT_SOURCES =.*:& tdbclass.cpp:' "${MAKEFILE}" 
     45    sed -i 's:EXT_OBJECTS =.*:& tdbclass.o:' "${MAKEFILE}" 
     46  fi 
     47fi 
     48grep -q 'DUSE_TDB' "${MAKEFILE}" 
     49if [ $? -eq 1 ] 
     50then 
     51  echo "Error! Update of ${MAKEFILE} failed." 
    4752  exit 
    4853fi 
     
    5055echo ' - enabling TDB support in collection server' 
    5156# - Makefile.in 
    52 MAKEFILE=$GSDLHOME/runtime-src/src/colservr/Makefile.in 
    53 grep -q 'DUSE_TDB' ${MAKEFILE} 
     57MAKEFILE="${GSDLHOME}/runtime-src/src/colservr/Makefile.in" 
     58grep -q 'DUSE_TDB' "${MAKEFILE}" 
    5459if [ $? -eq 1 ] 
    5560then 
    5661  # - Test for extension support in the makefile 
    57   grep -q 'EXT_DEFINES' ${MAKEFILE} 
    58   if [ $? -eq 1 ] 
    59   then 
    60     sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib\n\n&:' ${MAKEFILE} 
    61     sed -i 's:DEFS = @DEFS@:& $(EXT_DEFINES):' ${MAKEFILE} 
    62     sed -i 's:INCLUDES = -I. -I$(GSDL_DIR):& $(EXT_INCLUDES):' ${MAKEFILE} 
    63   else 
    64     sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' ${MAKEFILE} 
    65     sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib:' ${MAKEFILE} 
    66   fi 
    67 fi 
    68 grep -q 'DUSE_TDB' ${MAKEFILE} 
    69 if [ $? -eq 1 ] 
    70 then 
    71   echo Error! Update of ${MAKEFILE} failed. 
     62  grep -q 'EXT_DEFINES' "${MAKEFILE}" 
     63  if [ $? -eq 1 ] 
     64  then 
     65    sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\n\n&:' "${MAKEFILE}" 
     66    sed -i 's:DEFS = @DEFS@:& $(EXT_DEFINES):' "${MAKEFILE}" 
     67    sed -i 's:INCLUDES = -I. -I$(GSDL_DIR):& $(EXT_INCLUDES):' "${MAKEFILE}" 
     68  else 
     69    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}" 
     70    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}" 
     71  fi 
     72fi 
     73grep -q 'DUSE_TDB' "${MAKEFILE}" 
     74if [ $? -eq 1 ] 
     75then 
     76  echo "Error! Update of ${MAKEFILE} failed." 
    7277  exit 
    7378fi 
    7479 
    7580# - collectset.cpp 
    76 SRCFILE=$GSDLHOME/runtime-src/src/colservr/collectset.cpp 
    77 grep -q 'tdbclass.h' ${SRCFILE} 
    78 if [ $? -eq 1 ] 
    79 then 
    80   grep -q '@EXTENSION HEADERS@' ${SRCFILE} 
    81   if [ $? -eq 1 ] 
    82   then 
    83     sed -i 's:collectset\:\:collectset (text_t& gsdlhome, text_t& collecthome):// @EXTENSION HEADERS@\n#include "tdbclass.h //TDB\n\n&:' ${SRCFILE} 
    84     sed -i 's:    // Use GDBM if the infodb type is empty or not one of the values above:    // @EXTENSION DATASOURCES@\n    if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} //TDB\n    if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} //TDBServer\n\n&:' ${SRCFILE} 
    85   else 
    86     sed -i 's:// @EXTENSION HEADERS@:&\n#include "tdbclass.h" //TDB:' ${SRCFILE} 
    87     sed -i 's:// @EXTENSION DATASOURCES@:&\n    if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} //TDB\n    if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} //TDBServer:' ${SRCFILE} 
    88   fi 
    89 fi 
    90 grep -q 'tdbclass.h' ${SRCFILE} 
    91 if [ $? -eq 1 ] 
    92 then 
    93   echo Error! Update of ${SRCFILE} failed. 
     81SRCFILE="${GSDLHOME}/runtime-src/src/colservr/collectset.cpp" 
     82grep -q 'tdbclass.h' "${SRCFILE}" 
     83if [ $? -eq 1 ] 
     84then 
     85  grep -q '@EXTENSION HEADERS@' "${SRCFILE}" 
     86  if [ $? -eq 1 ] 
     87  then 
     88    sed -i 's:collectset\:\:collectset (text_t& gsdlhome, text_t& collecthome):// @EXTENSION HEADERS@\n#include "tdbclass.h //TDB\n\n&:' "${SRCFILE}" 
     89    sed -i 's:    // Use GDBM if the infodb type is empty or not one of the values above:    // @EXTENSION DATASOURCES@\n    if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} //TDB\n    if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} //TDBServer\n\n&:' "${SRCFILE}" 
     90  else 
     91    sed -i 's:// @EXTENSION HEADERS@:&\n#include "tdbclass.h" //TDB:' "${SRCFILE}" 
     92    sed -i 's:// @EXTENSION DATASOURCES@:&\n    if (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} //TDB\n    if (infodbtype == "tdbserver") {db_ptr = new tdbclass(gsdlhome);} //TDBServer:' "${SRCFILE}" 
     93  fi 
     94fi 
     95grep -q 'tdbclass.h' "${SRCFILE}" 
     96if [ $? -eq 1 ] 
     97then 
     98  echo "Error! Update of ${SRCFILE} failed." 
    9499  exit 
    95100fi 
     
    99104# infodbtype are compiled into colservr. While not fatal to leave this as is, 
    100105# it does cause vast amounts of error messages in (Apache) logs 
    101 SRCFILE=$GSDLHOME/runtime-src/src/colservr/collectserver.cpp 
    102 grep -q 'TDB' ${SRCFILE} 
    103 if [ $? -eq 1 ] 
    104 then 
    105   grep -q '@EXTENSION DATASOURCES@' ${SRCFILE} 
    106   if [ $? -eq 1 ] 
    107   then 
    108     sed -i 's:  if (infodbtype=="gdbm") {:  // @EXTENSION DATASOURCES@\n  if (infodbtype == "tdb") { return; } // TDB Do nothing\n  if (infodbtype == "tdbserver") { return; } // TDBServer Do nothing\n\n&:' ${SRCFILE} 
    109   else 
    110     sed -i 's:  // @EXTENSION DATASOURCES@:&\n  if (infodbtype == "tdb") { return; } // TDB Do nothing\n  if (infodbtype == "tdbserver") { return; } // TDBServer Do nothing:' ${SRCFILE} 
    111   fi 
    112 fi 
    113 grep -q 'TDB' ${SRCFILE} 
    114 if [ $? -eq 1 ] 
    115 then 
    116   echo Error! Update of ${SRCFILE} failed. 
     106SRCFILE="${GSDLHOME}/runtime-src/src/colservr/collectserver.cpp" 
     107grep -q 'TDB' "${SRCFILE}" 
     108if [ $? -eq 1 ] 
     109then 
     110  grep -q '@EXTENSION DATASOURCES@' "${SRCFILE}" 
     111  if [ $? -eq 1 ] 
     112  then 
     113    sed -i 's:  if (infodbtype=="gdbm") {:  // @EXTENSION DATASOURCES@\n  if (infodbtype == "tdb") { return; } // TDB Do nothing\n  if (infodbtype == "tdbserver") { return; } // TDBServer Do nothing\n\n&:' "${SRCFILE}" 
     114  else 
     115    sed -i 's:  // @EXTENSION DATASOURCES@:&\n  if (infodbtype == "tdb") { return; } // TDB Do nothing\n  if (infodbtype == "tdbserver") { return; } // TDBServer Do nothing:' "${SRCFILE}" 
     116  fi 
     117fi 
     118grep -q 'TDB' "${SRCFILE}" 
     119if [ $? -eq 1 ] 
     120then 
     121  echo "Error! Update of ${SRCFILE} failed." 
    117122  exit 
    118123fi 
     
    120125echo ' - enabling TDB support in Greenstone receptionist' 
    121126# - Makefile.in 
    122 MAKEFILE=$GSDLHOME/runtime-src/src/recpt/Makefile.in 
    123 grep -q 'DUSE_TDB' ${MAKEFILE} 
    124 if [ $? -eq 1 ] 
    125 then 
    126   grep -q 'EXT_DEFINES' ${MAKEFILE} 
    127   if [ $? -eq 1 ] 
    128   then 
    129     sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib\nEXT_LDFLAGS = -L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib\nEXT_LIBS = -ltdb\n\n&:' ${MAKEFILE} 
    130     sed -i 's:DEFS = @DEFS@ -DNZDL -DQUIET -DSHORT_SUFFIX -DPARADOCNUM -DHAVE_CONFIG_H:& $(EXT_DEFINES):' ${MAKEFILE} 
    131     sed -i 's:INCLUDES = -I. -I$(GSDL_DIR):& $(EXT_INCLUDES):' ${MAKEFILE} 
    132     sed -i 's:LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@:& $(EXT_LDFLAGS):' ${MAKEFILE} 
    133     sed -i 's:LIBS = @LIBS@ $(GDBM_LIBS):& $(EXT_LIBS):' ${MAKEFILE} 
    134   else 
    135     sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' ${MAKEFILE} 
    136     sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib:' ${MAKEFILE} 
    137     sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib:' ${MAKEFILE} 
    138     sed -i 's:EXT_LIBS =.*:& -ltdb:' ${MAKEFILE} 
    139   fi 
    140 fi 
    141 grep -q 'DUSE_TDB' ${MAKEFILE} 
    142 if [ $? -eq 1 ] 
    143 then 
    144   echo Error! Update of ${MAKEFILE} failed. 
     127MAKEFILE="${GSDLHOME}/runtime-src/src/recpt/Makefile.in" 
     128grep -q 'DUSE_TDB' "${MAKEFILE}" 
     129if [ $? -eq 1 ] 
     130then 
     131  grep -q 'EXT_DEFINES' "${MAKEFILE}" 
     132  if [ $? -eq 1 ] 
     133  then 
     134    sed -i 's:AR = ar:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\nEXT_LDFLAGS = -L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib\nEXT_LIBS = -ltdb\n\n&:' "${MAKEFILE}" 
     135    sed -i 's:DEFS = @DEFS@ -DNZDL -DQUIET -DSHORT_SUFFIX -DPARADOCNUM -DHAVE_CONFIG_H:& $(EXT_DEFINES):' "${MAKEFILE}" 
     136    sed -i 's:INCLUDES = -I. -I$(GSDL_DIR):& $(EXT_INCLUDES):' "${MAKEFILE}" 
     137    sed -i 's:LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@:& $(EXT_LDFLAGS):' "${MAKEFILE}" 
     138    sed -i 's:LIBS = @LIBS@ $(GDBM_LIBS):& $(EXT_LIBS):' "${MAKEFILE}" 
     139  else 
     140    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}" 
     141    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}" 
     142    sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib:' "${MAKEFILE}" 
     143    sed -i 's:EXT_LIBS =.*:& -ltdb:' "${MAKEFILE}" 
     144  fi 
     145fi 
     146grep -q 'DUSE_TDB' "${MAKEFILE}" 
     147if [ $? -eq 1 ] 
     148then 
     149  echo "Error! Update of ${MAKEFILE} failed." 
    145150fi 
    146151 
     
    148153echo ' - enabling TDB support in OAI Server receptionist' 
    149154# - Makefile.in 
    150 MAKEFILE=$GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
    151 grep -q 'DUSE_TDB' ${MAKEFILE} 
    152 if [ $? -eq 1 ] 
    153 then 
    154   grep -q 'EXT_DEFINES' ${MAKEFILE} 
    155   if [ $? -eq 1 ] 
    156   then 
    157     sed -i 's:CC = @CC@:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib\nEXT_LDFLAGS = -L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib\nEXT_LIBS = -ltdb\n\n&:' ${MAKEFILE} 
    158     sed -i 's:DEFS = @DEFS@:& $(EXT_DEFINES):' ${MAKEFILE} 
    159     sed -i 's:INCLUDES = -I$(COMMON_DIR)/src/lib:& $(EXT_INCLUDES):' ${MAKEFILE} 
    160     sed -i 's:LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@:& $(EXT_LDFLAGS):' ${MAKEFILE} 
    161     sed -i 's:LIBS = @LIBS@ $(GDBM_LIBS):& $(EXT_LIBS):' ${MAKEFILE} 
    162   else 
    163     sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' ${MAKEFILE} 
    164     sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/tdb-edit/linux/include -I$(GSDL_DIR)/ext/tdb-edit/darwin/include -I$(GSDL_DIR)/ext/tdb-edit/src/lib:' ${MAKEFILE} 
    165     sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib:' ${MAKEFILE} 
    166     sed -i 's:EXT_LIBS =.*:& -ltdb:' ${MAKEFILE} 
    167   fi 
    168 fi 
    169 grep -q 'DUSE_TDB' ${MAKEFILE} 
    170 if [ $? -eq 1 ] 
    171 then 
    172   echo Error! Update of ${MAKEFILE} failed. 
     155MAKEFILE="${GSDLHOME}/runtime-src/src/oaiservr/Makefile.in" 
     156grep -q 'DUSE_TDB' "${MAKEFILE}" 
     157if [ $? -eq 1 ] 
     158then 
     159  grep -q 'EXT_DEFINES' "${MAKEFILE}" 
     160  if [ $? -eq 1 ] 
     161  then 
     162    sed -i 's:CC = @CC@:# Support for adding in extension classes\nEXT_DEFINES = -DUSE_TDB\nEXT_INCLUDES = -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib\nEXT_LDFLAGS = -L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib\nEXT_LIBS = -ltdb\n\n&:' "${MAKEFILE}" 
     163    sed -i 's:DEFS = @DEFS@:& $(EXT_DEFINES):' "${MAKEFILE}" 
     164    sed -i 's:INCLUDES = -I$(COMMON_DIR)/src/lib:& $(EXT_INCLUDES):' "${MAKEFILE}" 
     165    sed -i 's:LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@:& $(EXT_LDFLAGS):' "${MAKEFILE}" 
     166    sed -i 's:LIBS = @LIBS@ $(GDBM_LIBS):& $(EXT_LIBS):' "${MAKEFILE}" 
     167  else 
     168    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}" 
     169    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}" 
     170    sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib:' "${MAKEFILE}" 
     171    sed -i 's:EXT_LIBS =.*:& -ltdb:' "${MAKEFILE}" 
     172  fi 
     173fi 
     174grep -q 'DUSE_TDB' "${MAKEFILE}" 
     175if [ $? -eq 1 ] 
     176then 
     177  echo "Error! Update of ${MAKEFILE} failed." 
    173178fi 
    174179 
     
    186191echo 'to complete TDB installation.' 
    187192echo 
     193echo 'Should you later wish to remove TDB support run:' 
     194echo 
     195echo ' ./disable_tdb.sh' 
     196echo 
    188197echo '====================================================' 
    189198echo