Changeset 25408

Show
Ignore:
Timestamp:
18.04.2012 10:32:48 (8 years ago)
Author:
jmt12
Message:

Greatly expanded script to allow it to insert EXT_DEFINE etc rules into Makefile.ins that lack them, and also added tests to ensure that changes actually occur (after I spent an hour trying to figure out why TDB wasn't working only to find the enable script wasn't actually changing any files)

Files:
1 modified

Legend:

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

    r25251 r25408  
    1717ln -f -s $GSDLHOME/ext/tdb-edit/src/lib/tdbclass.cpp $GSDLHOME/common-src/src/lib/tdbclass.cpp 
    1818# - Makefile.in 
    19 grep -q 'DUSE_TDB' $GSDLHOME/common-src/src/lib/Makefile.in 
     19MAKEFILE=$GSDLHOME/common-src/src/lib/Makefile.in 
     20# - I have no idea why this is commented out in the Makefile 
     21sed -i 's:#GSDL_DIR = ../../..:GSDL_DIR = ../../..:' ${MAKEFILE} 
     22grep -q 'DUSE_TDB' ${MAKEFILE} 
    2023if [ $? -eq 1 ] 
    2124then 
    22   sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' $GSDLHOME/common-src/src/lib/Makefile.in 
    23   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:' $GSDLHOME/common-src/src/lib/Makefile.in 
    24   sed -i 's:EXT_SOURCES =.*:& tdbclass.cpp:' $GSDLHOME/common-src/src/lib/Makefile.in 
    25   sed -i 's:EXT_OBJECTS =.*:& tdbclass.o:' $GSDLHOME/common-src/src/lib/Makefile.in 
     25  # - Test for extension support in the makefile 
     26  grep -q 'EXT_DEFINES' ${MAKEFILE} 
     27  if [ $? -eq 1 ] 
     28  then 
     29    # - 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  else 
     36    # - 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 
     42fi 
     43grep -q 'DUSE_TDB' ${MAKEFILE} 
     44if [ $? -eq 1 ] 
     45then 
     46  echo Error! Update of ${MAKEFILE} failed. 
     47  exit 
    2648fi 
    2749 
    2850echo ' - enabling TDB support in collection server' 
    2951# - Makefile.in 
    30 grep -q 'DUSE_TDB' $GSDLHOME/runtime-src/src/colservr/Makefile.in 
     52MAKEFILE=$GSDLHOME/runtime-src/src/colservr/Makefile.in 
     53grep -q 'DUSE_TDB' ${MAKEFILE} 
    3154if [ $? -eq 1 ] 
    3255then 
    33   sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' $GSDLHOME/runtime-src/src/colservr/Makefile.in 
    34   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:' $GSDLHOME/runtime-src/src/colservr/Makefile.in 
     56  # - Test for extension support in the makefile 
     57  grep -q 'DUSE_TDB' ${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 
    3567fi 
    36 # - collectset.cpp 
    37 grep -q 'tdbclass.h' $GSDLHOME/runtime-src/src/colservr/collectset.cpp 
     68grep -q 'DUSE_TDB' ${MAKEFILE} 
    3869if [ $? -eq 1 ] 
    3970then 
    40   sed -i 's:// @EXTENSION HEADERS@:&\n#include "tdbclass.h" //TDB:' $GSDLHOME/runtime-src/src/colservr/collectset.cpp 
    41   sed -i 's:// @EXTENSION DATASOURCES@:&\nif (infodbtype == "tdb") {db_ptr = new tdbclass(gsdlhome);} //TDB:' $GSDLHOME/runtime-src/src/colservr/collectset.cpp 
     71  echo Error! Update of ${MAKEFILE} failed. 
     72  exit 
     73fi 
     74 
     75# - collectset.cpp 
     76SRCFILE=$GSDLHOME/runtime-src/src/colservr/collectset.cpp 
     77grep -q 'tdbclass.h' ${SRCFILE} 
     78if [ $? -eq 1 ] 
     79then 
     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\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:' ${SRCFILE} 
     88  fi 
     89fi 
     90grep -q 'tdbclass.h' ${SRCFILE} 
     91if [ $? -eq 1 ] 
     92then 
     93  echo Error! Update of ${SRCFILE} failed. 
     94  exit 
    4295fi 
    4396 
     
    4699# infodbtype are compiled into colservr. While not fatal to leave this as is, 
    47100# it does cause vast amounts of error messages in (Apache) logs 
    48 grep -q 'tdb' $GSDLHOME/runtime-src/src/colservr/collectserver.cpp 
     101SRCFILE=$GSDLHOME/runtime-src/src/colservr/collectserver.cpp 
     102grep -q 'TDB' ${SRCFILE} 
    49103if [ $? -eq 1 ] 
    50104then 
    51   sed -i 's:// @EXTENSION HEADERS@:&\nif (infodbtype == "tdb") { } // TDB Do nothing:' $GSDLHOME/runtime-src/src/colservr/collectset.cpp 
     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\n&:' ${SRCFILE} 
     109  else 
     110    sed -i 's:  // @EXTENSION DATASOURCES@:&\n  if (infodbtype == "tdb") { return; } // TDB Do nothing:' ${SRCFILE} 
     111  fi 
     112fi 
     113grep -q 'TDB' ${SRCFILE} 
     114if [ $? -eq 1 ] 
     115then 
     116  echo Error! Update of ${SRCFILE} failed. 
     117  exit 
    52118fi 
    53119 
    54120echo ' - enabling TDB support in Greenstone receptionist' 
    55121# - Makefile.in 
    56 grep -q 'DUSE_TDB' $GSDLHOME/runtime-src/src/recpt/Makefile.in 
     122MAKEFILE=$GSDLHOME/runtime-src/src/recpt/Makefile.in 
     123grep -q 'DUSE_TDB' ${MAKEFILE} 
    57124if [ $? -eq 1 ] 
    58125then 
    59   sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' $GSDLHOME/runtime-src/src/recpt/Makefile.in 
    60   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:' $GSDLHOME/runtime-src/src/recpt/Makefile.in 
    61   sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib:' $GSDLHOME/runtime-src/src/recpt/Makefile.in 
    62   sed -i 's:EXT_LIBS =.*:& -ltdb:' $GSDLHOME/runtime-src/src/recpt/Makefile.in 
     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 
    63140fi 
     141grep -q 'DUSE_TDB' ${MAKEFILE} 
     142if [ $? -eq 1 ] 
     143then 
     144  echo Error! Update of ${MAKEFILE} failed. 
     145fi 
     146 
    64147 
    65148echo ' - enabling TDB support in OAI Server receptionist' 
    66149# - Makefile.in 
    67 grep -q 'DUSE_TDB' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
     150MAKEFILE=$GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
     151grep -q 'DUSE_TDB' ${MAKEFILE} 
    68152if [ $? -eq 1 ] 
    69153then 
    70   sed -i 's:EXT_DEFINES =.*:& -DUSE_TDB:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
    71   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:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
    72   sed -i 's:EXT_LDFLAGS =.*:& -L$(GSDL_DIR)/ext/tdb-edit/linux/lib -L$(GSDL_DIR)/ext/tdb-edit/darwin/lib:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
    73   sed -i 's:EXT_LIBS =.*:& -ltdb:' $GSDLHOME/runtime-src/src/oaiservr/Makefile.in 
     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 
     168fi 
     169grep -q 'DUSE_TDB' ${MAKEFILE} 
     170if [ $? -eq 1 ] 
     171then 
     172  echo Error! Update of ${MAKEFILE} failed. 
    74173fi 
    75174