Changeset 31972


Ignore:
Timestamp:
2017-09-15T20:55:51+12:00 (5 years ago)
Author:
ak19
Message:

GS2 on Mac now comes with a bundled JRE, since Maverick or Yosemite onwards, we're not guaranteed to have a system Java. So now GS2 needs to also set the Java env vars to the JAVA found (JRE_HOME or JAVA_HOME, and update PATH). This is necessary if GLI for instance needs to build a lucene collection, which requires java in the environment to launch it.

Location:
main/trunk/greenstone2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/IncrementalBuildUtils.pm

    r27303 r31972  
    7979# Ensure the collection specific binaries are on the search path
    8080my $path_separator = ":";
    81 if($ENV{'GSDLOS'} =~ /win/) {
     81if($ENV{'GSDLOS'} =~ /^win/) {
    8282  $path_separator = ";";
    8383}
  • main/trunk/greenstone2/setup.bash

    r31829 r31972  
    300300fi
    301301
     302# Only for GS2: work out java, and if the bundled jre is found, then set Java env vars with it
     303# Then the same java will be consistently available for all aspects of GS2 (server or GLI, and any subshells these launch)
     304if [ "x$GSDL3SRCHOME" = "x" ] ; then
     305    echo "@@@@ SETUP.BASH: Found GS2 installation"
     306
     307    SEARCH4J_EXECUTABLE="$GSDLHOME/bin/$GSDLOS$GSDLARCH/search4j"
     308    if [ -f "$SEARCH4J_EXECUTABLE" ]; then
     309    MINIMUM_JAVA_VERSION=1.5.0_00   
     310   
     311    # Give search4j a hint to find Java depending on the platform
     312        # we now include a JRE with Mac (Mountain) Lion, because from Yosemite onwards there's no system Java on Macs
     313    HINT=`cd "$GSDLHOME";pwd`/packages/jre   
     314   
     315        # we can't use boolean operator -a to do the AND, since it doesn't "short-circuit" if the first test fails
     316        # see http://www.tldp.org/LDP/abs/html/comparison-ops.html
     317    if [ "x$GSDLOS" = "xdarwin" ] && [ ! -d "$HINT" ]; then
     318           # http://java.dzone.com/articles/java-findingsetting
     319       # explains that /usr/libexec/java_home will print the default JDK
     320       # regardless of which Mac OS we're on. Tested on Maverick, Lion, Leopard
     321       # (run `/usr/libexec/java_home -v 1.7` to find a specific version)
     322        HINT=`/usr/libexec/java_home`
     323    fi
     324   
     325    javahome="`"$SEARCH4J_EXECUTABLE" -p "$HINT" -m $MINIMUM_JAVA_VERSION`"
     326    BUNDLED_JRE="$GSDLHOME/packages/jre"
     327
     328    if [ "$?" != "0" ]; then
     329        echo "setup.bash: Could not find Java in the environment or installation."
     330        echo "Set JAVA_HOME or JRE_HOME, and put it on the PATH, if working with Java tools like Lucene."
     331    elif [ "x$javahome" != "x$BUNDLED_JRE" ]; then
     332        if [ "x$JAVA_HOME" = "x" ]; then
     333        # if Java env vars not already set, then set them to the $javahome found
     334        echo "Found a Java on the system. Setting up GS2's Java environment to use this"
     335        export JAVA_HOME=$javahome
     336        export PATH=$JAVA_HOME/bin:$PATH
     337        fi
     338        # else JAVA_HOME, and PATH presumably too, would already be set
     339    elif [ -d "$GSDLHOME/packages/jre" ]; then
     340        echo "Found a bundled JRE. Setting up GS2's Java environment to use this"
     341        export JRE_HOME=$GSDLHOME/packages/jre   
     342        export PATH=$JRE_HOME/bin:$PATH
     343    else
     344        # can we ever really get here?
     345        echo "Java environment not set and bundled JRE doesn't exist. Some tools need the Java environment. Proceeding without..."
     346    fi
     347    fi
     348fi
    302349
    303350# if the Perl-for-greenstone tarfile has been installed in the bin/linux
Note: See TracChangeset for help on using the changeset viewer.