Changeset 30253 for gs2-extensions


Ignore:
Timestamp:
09/21/15 10:49:32 (5 years ago)
Author:
jmt12
Message:

It is now safe to run this script multiple times... only the first time will change anything. Subsequent runs will notice the changes are already made.

File:
1 edited

Legend:

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

    r30239 r30253  
    1010
    1111# Test that GSDLHOME is set otherwise we won't be able to find the required files
    12 if [ "${GSDLHOME}x" == "x" ] ; then echo 'Error! GSDLHOME not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi
    13 if [ "${GSDLOS}x" == "x" ] ; then echo 'Error! GSDLOS not set. Please source setup.bash before running.' ; echo ; exit 0 ; fi
     12if [ "${GSDLHOME}x" == "x" ]
     13then
     14    echo 'Error! GSDLHOME not set. Please source setup.bash before running.'
     15    echo
     16    exit 0
     17fi
     18if [ "${GSDLOS}x" == "x" ]
     19then
     20    echo 'Error! GSDLOS not set. Please source setup.bash before running.'
     21    echo
     22    exit 0
     23fi
    1424
    1525# Black magic to determine the actual name of the extension folder (in case I
     
    1727EXTNAME=${PWD##*/}
    1828
    19 echo ' - enabling TDB support in common function library'
    2029# - Symlink the source file into place
    21 ln -f -s "${GSDLHOME}/ext/${EXTNAME}/src/lib/tdbclass.h" "${GSDLHOME}/common-src/src/lib/tdbclass.h"
    22 ln -f -s "${GSDLHOME}/ext/${EXTNAME}/src/lib/tdbclass.cpp" "${GSDLHOME}/common-src/src/lib/tdbclass.cpp"
    23 # - Makefile.in
     30printf ' * Symlinking TDB source files into place... '
     31if [ -f "${GSDLHOME}/common-src/src/lib/tdbclass.h" ]
     32then
     33    echo 'already present'
     34else
     35    ln -f -s "${GSDLHOME}/ext/${EXTNAME}/src/lib/tdbclass.h" "${GSDLHOME}/common-src/src/lib/tdbclass.h"
     36    ln -f -s "${GSDLHOME}/ext/${EXTNAME}/src/lib/tdbclass.cpp" "${GSDLHOME}/common-src/src/lib/tdbclass.cpp"
     37    echo 'Done!'
     38fi
     39
     40# - Makefile.in
     41printf ' * Enabling TDB support in common function library... '
    2442MAKEFILE="${GSDLHOME}/common-src/src/lib/Makefile.in"
    2543# - I have no idea why this is commented out in the Makefile
     
    2846if [ $? -eq 1 ]
    2947then
    30   # - Test for extension support in the makefile
    31   grep -q 'EXT_DEFINES' "${MAKEFILE}"
    32   if [ $? -eq 1 ]
    33   then
    34     # - No Extension variables yet - add them in with TDB parts
    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}"
    40   else
    41     # - Extension support already present - add TDB parts
    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
     48    # - Test for extension support in the makefile
     49    grep -q 'EXT_DEFINES' "${MAKEFILE}"
     50    if [ $? -eq 1 ]
     51    then
     52    # - No Extension variables yet - add them in with TDB parts
     53    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}"
     54    sed -i 's:DEFS = @DEFS@ .*:& $(EXT_DEFINES):' "${MAKEFILE}"
     55    sed -i 's:INCLUDES = -I. .*:& $(EXT_INCLUDES):' "${MAKEFILE}"
     56    sed -i 's:unitool.cpp:& \\\n        $(EXT_SOURCES):' "${MAKEFILE}"
     57    sed -i 's:unitool.o:& \\\n        $(EXT_OBJECTS):' "${MAKEFILE}"
     58    else
     59    # - Extension support already present - add TDB parts
     60    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}"
     61    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}"
     62    sed -i 's:EXT_SOURCES =.*:& tdbclass.cpp:' "${MAKEFILE}"
     63    sed -i 's:EXT_OBJECTS =.*:& tdbclass.o:' "${MAKEFILE}"
     64    fi
     65    echo 'Done!'
     66else
     67    echo 'already enabled'
    4768fi
    4869grep -q 'DUSE_TDB' "${MAKEFILE}"
     
    5374fi
    5475
    55 echo ' - enabling TDB support in collection server'
     76printf ' * Enabling TDB support in collection server... '
    5677# - Makefile.in
    5778MAKEFILE="${GSDLHOME}/runtime-src/src/colservr/Makefile.in"
     
    5980if [ $? -eq 1 ]
    6081then
    61   # - Test for extension support in the makefile
    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
    72 fi
    73 grep -q 'DUSE_TDB' "${MAKEFILE}"
    74 if [ $? -eq 1 ]
    75 then
    76   echo "Error! Update of ${MAKEFILE} failed."
    77   exit
     82    # - Test for extension support in the makefile
     83    grep -q 'EXT_DEFINES' "${MAKEFILE}"
     84    if [ $? -eq 1 ]
     85    then
     86    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}"
     87    sed -i 's:DEFS = @DEFS@:& $(EXT_DEFINES):' "${MAKEFILE}"
     88    sed -i 's:INCLUDES = -I. -I$(GSDL_DIR):& $(EXT_INCLUDES):' "${MAKEFILE}"
     89    else
     90    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}"
     91    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}"
     92    fi
     93    echo 'Done!'
     94else
     95    echo 'already enabled'
     96fi
     97grep -q 'DUSE_TDB' "${MAKEFILE}"
     98if [ $? -eq 1 ]
     99then
     100    echo "Error! Update of ${MAKEFILE} failed."
     101    exit
    78102fi
    79103
     
    83107if [ $? -eq 1 ]
    84108then
    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
     109    grep -q '@EXTENSION HEADERS@' "${SRCFILE}"
     110    if [ $? -eq 1 ]
     111    then
     112    sed -i 's:collectset\:\:collectset (text_t& gsdlhome, text_t& collecthome):// @EXTENSION HEADERS@\n#include "tdbclass.h //TDB\n\n&:' "${SRCFILE}"
     113    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}"
     114    else
     115    sed -i 's:// @EXTENSION HEADERS@:&\n#include "tdbclass.h" //TDB:' "${SRCFILE}"
     116    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}"
     117    fi
    94118fi
    95119grep -q 'tdbclass.h' "${SRCFILE}"
    96120if [ $? -eq 1 ]
    97121then
    98   echo "Error! Update of ${SRCFILE} failed."
    99   exit
     122    echo "Error! Update of ${SRCFILE} failed."
     123    exit
    100124fi
    101125
     
    108132if [ $? -eq 1 ]
    109133then
    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
     134    grep -q '@EXTENSION DATASOURCES@' "${SRCFILE}"
     135    if [ $? -eq 1 ]
     136    then
     137    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}"
     138    else
     139    sed -i 's:  // @EXTENSION DATASOURCES@:&\n  if (infodbtype == "tdb") { return; } // TDB Do nothing\n  if (infodbtype == "tdbserver") { return; } // TDBServer Do nothing:' "${SRCFILE}"
     140    fi
    117141fi
    118142grep -q 'TDB' "${SRCFILE}"
    119143if [ $? -eq 1 ]
    120144then
    121   echo "Error! Update of ${SRCFILE} failed."
    122   exit
    123 fi
    124 
    125 echo ' - enabling TDB support in Greenstone receptionist'
     145    echo "Error! Update of ${SRCFILE} failed."
     146    exit
     147fi
     148
     149printf ' * Enabling TDB support in Greenstone receptionist... '
    126150# - Makefile.in
    127151MAKEFILE="${GSDLHOME}/runtime-src/src/recpt/Makefile.in"
     
    129153if [ $? -eq 1 ]
    130154then
    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
    145 fi
    146 grep -q 'DUSE_TDB' "${MAKEFILE}"
    147 if [ $? -eq 1 ]
    148 then
    149   echo "Error! Update of ${MAKEFILE} failed."
    150 fi
    151 
    152 
    153 echo ' - enabling TDB support in OAI Server receptionist'
     155    grep -q 'EXT_DEFINES' "${MAKEFILE}"
     156    if [ $? -eq 1 ]
     157    then
     158    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}"
     159    sed -i 's:DEFS = @DEFS@ -DNZDL -DQUIET -DSHORT_SUFFIX -DPARADOCNUM -DHAVE_CONFIG_H:& $(EXT_DEFINES):' "${MAKEFILE}"
     160    sed -i 's:INCLUDES = -I. -I$(GSDL_DIR):& $(EXT_INCLUDES):' "${MAKEFILE}"
     161    sed -i 's:LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@:& $(EXT_LDFLAGS):' "${MAKEFILE}"
     162    sed -i 's:LIBS = @LIBS@ $(GDBM_LIBS):& $(EXT_LIBS):' "${MAKEFILE}"
     163    else
     164    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}"
     165    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}"
     166    sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib:' "${MAKEFILE}"
     167    sed -i 's:EXT_LIBS =.*:& -ltdb:' "${MAKEFILE}"
     168    fi
     169    echo 'Done!'
     170else
     171    echo 'already enabled'
     172fi
     173grep -q 'DUSE_TDB' "${MAKEFILE}"
     174if [ $? -eq 1 ]
     175then
     176    echo "Error! Update of ${MAKEFILE} failed."
     177fi
     178
     179
     180printf ' * Enabling TDB support in OAI Server receptionist... '
    154181# - Makefile.in
    155182MAKEFILE="${GSDLHOME}/runtime-src/src/oaiservr/Makefile.in"
     
    157184if [ $? -eq 1 ]
    158185then
    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
    173 fi
    174 grep -q 'DUSE_TDB' "${MAKEFILE}"
    175 if [ $? -eq 1 ]
    176 then
    177   echo "Error! Update of ${MAKEFILE} failed."
     186    grep -q 'EXT_DEFINES' "${MAKEFILE}"
     187    if [ $? -eq 1 ]
     188    then
     189    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}"
     190    sed -i 's:DEFS = @DEFS@:& $(EXT_DEFINES):' "${MAKEFILE}"
     191    sed -i 's:INCLUDES = -I$(COMMON_DIR)/src/lib:& $(EXT_INCLUDES):' "${MAKEFILE}"
     192    sed -i 's:LDFLAGS = @LDFLAGS@ @ARCH_DEP_FLAGS@:& $(EXT_LDFLAGS):' "${MAKEFILE}"
     193    sed -i 's:LIBS = @LIBS@ $(GDBM_LIBS):& $(EXT_LIBS):' "${MAKEFILE}"
     194    else
     195    sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' "${MAKEFILE}"
     196    sed -i 's:EXT_INCLUDES =.*:& -I$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/include -I$(GSDL_DIR)/ext/'${EXTNAME}'/src/lib:' "${MAKEFILE}"
     197    sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/'${EXTNAME}'/'${GSDLOS}'/lib:' "${MAKEFILE}"
     198    sed -i 's:EXT_LIBS =.*:& -ltdb:' "${MAKEFILE}"
     199    fi
     200    echo 'Done!'
     201else
     202    echo 'already enabled'
     203fi
     204grep -q 'DUSE_TDB' "${MAKEFILE}"
     205if [ $? -eq 1 ]
     206then
     207    echo "Error! Update of ${MAKEFILE} failed."
    178208fi
    179209
Note: See TracChangeset for help on using the changeset viewer.