Changeset 34568


Ignore:
Timestamp:
2020-11-26T14:06:49+13:00 (3 years ago)
Author:
kjdon
Message:

changed [..==..] to [..=..] as that works in zsh, which is the new default shell for Mocos catalina. on macs, we have .jnilib instead of .so, so changed the test for determining gs bitness to use the jnilib file, if on a mac.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/gs3-setup.sh

    r34317 r34568  
    4343# script so don't do it again. UNLESS, GSDL3SRCHOME doesn't match the
    4444# current directory in which case it was a different gs3 installation, so lets
    45 # do it now.x
     45# do it now.
    4646function testAlreadySourced() {
    4747  if [ ! -z "$GSDL3SRCHOME" ]; then
    4848    localgs3sourcehome="`pwd`"
    49     if [ "$GSDL3SRCHOME" == "$localgs3sourcehome" ]; then
     49    if [ "$GSDL3SRCHOME" = "$localgs3sourcehome" ]; then
    5050      echo "Your environment is already set up for Greenstone3"
    5151      return 1
     
    7474  fi
    7575  export GSDLOS
    76   echo "  - Exported GSDL3HOME, GSDL3SRCHOME and GSDLOS"
     76  echo "  - Exported GSDL3HOME=$GSDL3HOME"
     77  echo "             GSDL3SRCHOME=$GSDL3SRCHOME"
     78  echo "             GSDLOS=$GSDLOS"
    7779
    7880  #change this if external tomcat
     
    8587  addtopath PATH "$GSDL3SRCHOME/bin"
    8688  echo "  - Adjusted PATH"
     89  if [ "$DEBUG" = "true" ]; then
     90    echo "     = $PATH"
     91  fi
    8792
    8893  #MANPATH
    8994  addtopath MANPATH "$GSDL3SRCHOME/doc/man"
    9095  echo "  - Adjusted MANPATH"
     96  if [ "$DEBUG" = "true" ]; then
     97    echo "     = $MANPATH"
     98  fi
    9199 
    92100  #CLASSPATH
     
    102110 
    103111  # Tomcat 5 jar files
     112  if test -d "$TOMCAT_HOME"/common/endorsed ; then
    104113  for JARFILE in "$TOMCAT_HOME"/common/endorsed/*.jar; do
    105114    addtopath CLASSPATH "$JARFILE"
    106115  done   
     116  fi     
    107117  # Tomcat 6 jar files
     118  if test -d "$TOMCAT_HOME"/lib ; then
    108119  for JARFILE in "$TOMCAT_HOME"/lib/*.jar; do
    109120    addtopath CLASSPATH "$JARFILE"
    110121  done   
    111  
     122  fi
     123
    112124  #shouldn't need these as they will have been copied to their correct locations elsewhere in the greenstone3 installation
    113125  #for JARFILE in "$GSDL3SRCHOME"/build/*.jar; do
     
    116128
    117129  echo "  - Adjusted CLASSPATH"
     130  if [ "$DEBUG" = "true" ]; then
     131    echo "     = $CLASSPATH"
     132  fi
    118133
    119134  #LD_LIBRARY_PATH
    120135  addtopath LD_LIBRARY_PATH "$GSDL3SRCHOME/lib/jni"
    121136  addtopath DYLD_LIBRARY_PATH "$GSDL3SRCHOME/lib/jni"
    122   echo "  - Adjusted LD_LIBRARY_PATH and DYLD_LIBRARY_PATH"
     137  echo "  - Adjusted LD_LIBRARY_PATH"
     138  if [ "$DEBUG" = "true" ]; then
     139    echo "     = $LD_LIBRARY_PATH"
     140  fi
     141
     142  echo "  - Adjusted DYLD_LIBRARY_PATH"
     143  if [ "$DEBUG" = "true" ]; then
     144    echo "     = $DYLD_LIBRARY_PATH"
     145  fi
    123146
    124147  #ImageMagick
     
    165188  BUNDLED_JRE="`pwd`/packages/jre"
    166189  HINT=$BUNDLED_JRE
    167  
    168   #if [ "$GSDLOS" = "darwin" ] && [ ! -d "$HINT" ]; then
     190
    169191  if [ "$GSDLOS" = "darwin" ]; then
    170       if [ "$JAVA_HOME" != "" ] && [ -d "$JAVA_HOME" ]; then
     192    # try $JAVA_HOME first, if it is set
     193    if [ "$JAVA_HOME" != "" ] && [ -d "$JAVA_HOME" ]; then
    171194      HINT=$JAVA_HOME
    172       elif [ ! -d "$HINT" ]; then
    173       HINT=`/usr/libexec/java_home`
    174           # old code used as fallback:
     195    elif [ ! -d "$HINT" ]; then
     196    #we test for the existence of bundled_jre - will be present in binary release. Use that if it is there as we know that it works with GS
     197    # but if its not there, try the following:
     198    # this will print out the path to java
     199    HINT=`/usr/libexec/java_home`
     200        # old code used as fallback:
     201    # But actually this is not valid for Mojave and Catalina
    175202      if [ ! -d "$HINT" ]; then
    176203              HINT=/System/Library/Frameworks/JavaVM.framework/Home
     
    179206  fi
    180207
    181   if [ "$DEBUG" == "true" ]; then echo "**********************************************"; fi
     208  if [ "$DEBUG" = "true" ]; then echo "**********************************************"; fi
    182209
    183210  # If the file utility exists, use it to determine the bitness of this GS3,
    184   # particularly of this GS3's lib\jni\libgdbmjava.so (gdbmjava.dll), since we prefer a matching java
     211  # particularly of this GS3's lib/jni/libgdbmjava.so/jnilib, since we prefer a matching java
    185212  # If any executable doesn't exist, the return value is 127.
    186213  # If file utility exists, then 0 is returned on successful execution, 1 is an error exit code
     
    188215
    189216  # Determine the bitness of this GS3 installation, by running:
    190   # `file lib/jni/libgdbmjava.so`
     217  # `file lib/jni/libgdbmjava.so/jnilib`
    191218  # Output:
    192219  #    lib/jni/libgdbmjava.so: ELF 64-bit LSB  shared object, x86-64, version 1 (SYSV),
     
    197224  fileexists=`file 2&> /dev/null`
    198225
     226  TESTFILE="$GSDL3SRCHOME/lib/jni/libgdbmjava.so"
     227  if test "$GSDLOS" = "darwin"; then
     228     TESTFILE="$GSDL3SRCHOME/lib/jni/libgdbmjava.jnilib"
     229  fi
     230
    199231  # Integer comparison, http://tldp.org/LDP/abs/html/comparison-ops.html
    200232  #    can also use double brackets:  if [[ $? > 1 ]]; then ...
    201233  if [ "$?" -gt "1" ]; then
    202       if [ "$DEBUG" == "true" ]; then
     234      if [ "$DEBUG" = "true" ]; then
    203235      echo "    'file' utility not found installed on this unix-based system."
    204236      echo "    Unable to use 'file' utility to determine bitness of this GS3 to see if it matches that of any Java found."
    205237      fi
    206238      bitness=-1
    207   elif [ ! -f "$GSDL3SRCHOME/lib/jni/libgdbmjava.so" ]; then
     239  elif [ ! -f "$TESTFILE" ]; then
    208240      # the file we want to test the bitness of, to determine GS3's bitness by, doesn't exist yet
     241      echo "    $TESTFILE is not found, unable to determine bitness of this Greenstone3"
    209242      bitness=-1
    210243  else
    211       bitness=`file $GSDL3SRCHOME/lib/jni/libgdbmjava.so`
    212       if [[ $bitness == *"64-bit"* ]]; then
     244      bitness=`file $TESTFILE` 
     245      if [[ $bitness = *"64-bit"* ]]; then
    213246      bitness=64
    214247      echo "The installed Greenstone is $bitness bit"
    215       elif [[ $bitness == *"32-bit"* ]]; then
     248      elif [[ $bitness = *"32-bit"* ]]; then
    216249      bitness=32
    217250      echo "The installed Greenstone is $bitness bit"
     
    221254      fi
    222255  fi
     256 echo bitness = $bitness
    223257
    224258  # If search4j is present, use it to locate a java.
     
    237271
    238272  # 1. check the bitness of any JDK java found by search4j, and use if appropriate
    239   if [ "$javahome_retval" == "0" ]; then
     273  if [ "$javahome_retval" = "0" ]; then
    240274      setJavaIfOK "$DEBUG" "$bitness" "$FOUNDJAVAHOME" "JDK"
    241       if [ "$?" == "0" ]; then javaset="true"; fi
     275      if [ "$?" = "0" ]; then javaset="true"; fi
    242276  fi
    243277
    244278  # 2. check the bitness of any JRE java found by search4j, and use if appropriate
    245   if [ "$javaset" != "true" ] && [ "$jrehome_retval" == "0" ]; then
     279  if [ "$javaset" != "true" ] && [ "$jrehome_retval" = "0" ]; then
    246280      setJavaIfOK "$DEBUG" "$bitness" "$FOUNDJREHOME" "JRE"
    247       if [ "$?" == "0" ]; then javaset="true"; fi
     281      if [ "$?" = "0" ]; then javaset="true"; fi
    248282  fi
    249283 
     
    252286  if [ "$javaset" != "true" ] && [ -d "$BUNDLED_JRE" ]; then
    253287      setJavaIfOK "$DEBUG" "$bitness" "$BUNDLED_JRE" "bundled JRE"
    254       if [ "$?" == "0" ]; then javaset="true"; fi
     288      if [ "$?" = "0" ]; then javaset="true"; fi
    255289  fi
    256290
     
    262296  if [ "$javaset" != "true" ]; then
    263297      # go with any JAVA_HOME else JRE_HOME that search4j found, else with any bundled JRE if present
    264       if [ "$javahome_retval" == "0" ]; then
     298      if [ "$javahome_retval" = "0" ]; then
    265299      setupJavaAt "$FOUNDJAVAHOME" "JDK"
    266300      javaset=true
    267       elif [ "$jrehome_retval" == "0" ]; then
     301      elif [ "$jrehome_retval" = "0" ]; then
    268302      setupJavaAt "$FOUNDJREHOME" "JRE"
    269303      javaset=true
     
    290324      #echo "*** Attempting to use JAVA_HOME else JRE_HOME in the environment"
    291325      echo "Checking for Java explicitly set through environment variables"
    292       if [ "$JAVA_HOME" != "" ] && [ "`which java`" == "$JAVA_HOME/bin/java" ]; then
     326      if [ "$JAVA_HOME" != "" ] && [ "`which java`" = "$JAVA_HOME/bin/java" ]; then
    293327      echo "  - Using Java at $JAVA_HOME"
    294328      echo "  - Detected Java version: `$JAVA_HOME/bin/java -version 2>&1 | head -n 1`"
     
    297331#     echo "             The source distribution of Greenstone3 requires java 1.5 or greater"
    298332#     echo "             (SVN users may still use java 1.4)"
    299       elif [ "$JRE_HOME" != "" ] && [ "`which java`" == "$JRE_HOME/bin/java" ]; then
     333      elif [ "$JRE_HOME" != "" ] && [ "`which java`" = "$JRE_HOME/bin/java" ]; then
    300334      echo "  - Using java at $JRE_HOME"
    301335      echo "  - Detected Java version: `$JAVA_HOME/bin/java -version 2>&1 | head -n 1`"
     
    326360      fi
    327361      checkJavaBitnessAgainstGSBitness "$JAVA_FOUND" "$bitness"
    328       if [ "$?" == "1" ]; then
     362      if [ "$?" = "1" ]; then
    329363      echo "*** WARNING: Detected mismatch between the bit-ness of your GS installation ($bitness bit)"
    330364      echo "*** and the Java found at $JAVA_FOUND/bin/java"
     
    341375  fi
    342376
    343   if [ "$DEBUG" == "true" ]; then echo "**********************************************"; fi
     377  if [ "$DEBUG" = "true" ]; then echo "**********************************************"; fi
    344378
    345379}
     
    348382function setJavaIfOK {
    349383
    350     if [ "$DEBUG" == "true" ]; then echo "Testing java at $3"; fi
     384    if [ "$DEBUG" = "true" ]; then echo "Testing java at $3"; fi
    351385
    352386    DEBUG=$1
     
    360394    isjavaset=false
    361395
    362     if [ "$check_status" == "0" ]; then
     396    if [ "$check_status" = "0" ]; then
    363397    # http://tldp.org/LDP/abs/html/comparison-ops.html
    364     if [ "$bitness" != "-1" ] && [ "$DEBUG" == "true" ]; then
     398    if [ "$bitness" != "-1" ] && [ "$DEBUG" = "true" ]; then
    365399        # java matches GS bitness
    366         if [[ "$JDKorJRE" == *"bundled"* ]]; then
     400        if [[ "$JDKorJRE" = *"bundled"* ]]; then
    367401        echo "*** Changing to use Greenstone's $bitness-bit $JDKorJRE at $PATHTOJAVA"
    368402        else
     
    373407    isjavaset=true
    374408   
    375     elif [ "$bitness" != "-1" ] && [ "$DEBUG" == "true" ]; then
    376     if [[ "$JDKorJRE" == *"bundled"* ]]; then
     409    elif [ "$bitness" != "-1" ] && [ "$DEBUG" = "true" ]; then
     410    if [[ "$JDKorJRE" = *"bundled"* ]]; then
    377411        echo "    The $JDKorJRE java is an incompatible bit architecture"
    378412    else
     
    381415    fi
    382416   
    383     if [ "$isjavaset" == "true" ]; then
     417    if [ "$isjavaset" = "true" ]; then
    384418    return 0 # success
    385419    else
     
    390424# if bitness (parameter #2) is -1, then this function returns 0 (generally meaning success).
    391425function checkJavaBitnessAgainstGSBitness() {
    392 #    if [ "$DEBUG" == "true" ]; then echo "Testing bitness of java found at $java_installation"; fi
     426#    if [ "$DEBUG" = "true" ]; then echo "Testing bitness of java found at $java_installation"; fi
    393427    java_installation="$1"
    394428    bitness="$2"
     
    396430    # bitness can be -1 if the 'file' utility could not be found to determine bitness
    397431    # or if its output no longer prints "32-bit" or "64-bit". Should continue gracefully
    398     if [ "$bitness" == "-1" ]; then
     432    if [ "$bitness" = "-1" ]; then
    399433    return 0
    400434    fi
     
    405439    `$java_installation/bin/java -d$bitness -version 2> /dev/null`
    406440
    407     if [ "$?" == "0" ]; then
     441    if [ "$?" = "0" ]; then
    408442    return 0
    409     elif [ "$?" == "1" ]; then
     443    elif [ "$?" = "1" ]; then
    410444
    411445        # Newer Java's don't support -d, so result to using 'file' to determin bitness of 'java' binary
    412446        java_bitness=`file $java_installation/bin/java`
    413         if [[ $java_bitness == *"$bitness-bit"* ]]; then
     447        if [[ $java_bitness = *"$bitness-bit"* ]]; then
    414448        return 0
    415449    else
     
    426460
    427461  # check the second parameter if non-null
    428   if [ -n "$2" ] && [ "$2" == "JRE" ]; then
     462  if [ -n "$2" ] && [ "$2" = "JRE" ]; then
    429463    export JRE_HOME="$1"
    430464    addtopath PATH "$JRE_HOME/bin"
    431465
    432466    BUNDLED_JRE="`pwd`/packages/jre"   
    433     if [[ "$JRE_HOME" == *"$BUNDLED_JRE"* ]]; then
     467    if [[ "$JRE_HOME" = *"$BUNDLED_JRE"* ]]; then
    434468    msg="the bundled"
    435469    fi
     
    452486function isinpath() {
    453487  for file in `echo $1 | sed 's/:/ /g'`; do
    454     if [ "$file" == "$2" ]; then
     488    if [ "$file" = "$2" ]; then
    455489      echo true
    456490      return
     
    463497  eval "PV=\$$1"
    464498  #echo "$1 += $2"
    465   if [ "$PV" == "" ]; then
     499  if [ "$PV" = "" ]; then
    466500    cmd="$1=\"$2\""
    467501  else
     
    473507
    474508# Note: use return not exit from a sourced script otherwise it kills the shell
    475 echo
    476509testSource
    477 if [ "$?" == "1" ]; then
     510if [ "$?" = "1" ]; then
    478511return
    479512fi
     513
    480514testAlreadySourced
    481 if [ "$?" == "1" ]; then
     515if [ "$?" = "1" ]; then
    482516return
    483517fi
     518
    484519setGS3ENV
     520
     521echo "done"
    485522
    486523if test -e gs2build/setup.bash ; then
     
    534571  else
    535572    which ant &> /dev/null
    536     if [ "$?" == "0" ]; then
     573    if [ "$?" = "0" ]; then
    537574      echo "  - System install ant detected"
    538575      echo "  - `ant -version`"
Note: See TracChangeset for help on using the changeset viewer.