Changeset 31469 for main/trunk


Ignore:
Timestamp:
2017-03-07T18:19:54+13:00 (7 years ago)
Author:
ak19
Message:
  1. Failing gracefully if we can't determine the bitness of GS3 (for example, it's still compiling up or has to be compiled up, but we run gs3-devel.bat in preparation for compiling>. 2. Better variable naming and messages.
File:
1 edited

Legend:

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

    r31468 r31469  
    126126:: ---- Search for java ----
    127127set JAVA_MIN_VERSION=1.5.0_00
    128 set HINT=!CD!\packages\jre
     128set BUNDLED_JRE=!CD!\packages\jre
     129set HINT=!BUNDLED_JRE!
    129130
    130131::if search4j is present, use it
     
    167168:: http://stackoverflow.com/questions/6474738/batch-file-for-f-doesnt-work-if-path-has-spaces
    168169:: Could use shortfilenames, see http://stackoverflow.com/questions/10227144/convert-long-filename-to-short-filename-8-3-using-cmd-exe
    169 for /f "usebackq tokens=2 delims= " %%G IN (`call "%GSDLHOME%\bin\windows\GNUfile\bin\file.exe" "%GSDL3SRCHOME%\lib\jni\gdbmjava.dll"`) do set bitness=%%G
     170for /f "usebackq tokens=2 delims= " %%G IN (`call "%GSDLHOME%\bin\windows\GNUfile\bin\file.exe" "%GSDL3SRCHOME%\bin\search4j.exe"`) do set bitness=%%G
     171
     172echo JAVAHOME: %JAVA_HOME%
     173if not "%FOUNDJAVAHOME%" == "" echo FOUNDJAVAHOME !FOUNDJAVAHOME!
     174if not "%FOUNDJREHOME%" == "" echo FOUNDJAVAHOME !FOUNDJREHOME!
    170175
    171176if "%bitness%" == "PE32+" (
     
    177182        echo The installed Greenstone is 32 bit
    178183    ) else (
    179         echo WARNING: Greenstone installation is of unknown bitness. "%bitness%" is neither 32 nor 64 bit& goto bundledjre
     184        echo WARNING: Greenstone installation is of unknown bitness. "%bitness%" is neither 32 nor 64 bit       
    180185        set bitness=UNKNOWN
    181186    )
     
    192197:: https://ss64.com/nt/errorlevel.html
    193198if DEFINED FOUNDJAVAHOME  (
     199    if "%bitness%" == "UNKNOWN" goto setupjavahome
    194200    echo *** Testing bitness of JAVA_HOME found at !FOUNDJAVAHOME!:
    195201    "!FOUNDJAVAHOME!\bin\java.exe" -d%bitness% -version 2> nul
    196     if !ERRORLEVEL! equ 1 echo *** The detected JDK java is an incompatible bit architecture& goto testjre 
     202    if !ERRORLEVEL! equ 1 echo *** The detected JDK java is incompatible with !bitness! bit GS& goto testjre   
    197203    if !ERRORLEVEL! equ 0 (
    198204        echo *** The detected JDK java is a matching %bitness% bit     
     
    203209:testjre
    204210if DEFINED FOUNDJREHOME  (
     211    if "%bitness%" == "UNKNOWN" goto setupjrehome
    205212    echo *** Testing bitness of JRE_HOME found at !FOUNDJREHOME!:
    206213    "!FOUNDJREHOME!\bin\java.exe" -d%bitness% -version 2> nul
    207     if !ERRORLEVEL! equ 1 echo *** The detected JRE java is an incompatible bit architecture& goto bundledjre
     214    if !ERRORLEVEL! equ 1 echo *** The detected JRE java is incompatible with !bitness! bit GS& goto testbundledjre
    208215    if !ERRORLEVEL! equ 0 (
    209216        rem The JRE_HOME found by search4j may be the bundled JRE, overriding any system JRE_HOME,
     
    215222
    216223:: 3. Fall back to 32 bit JRE bundled with GS
     224:testbundledjre
     225if exist "!BUNDLED_JRE!\bin\java.exe" (
     226    if "%bitness%" == "UNKNOWN" goto bundledjre
     227   
     228    echo *** Testing bitness of bundled JRE at !BUNDLED_JRE!:
     229    "!BUNDLED_JRE!\bin\java.exe" -d%bitness% -version 2> nul
     230    if !ERRORLEVEL! equ 1 echo *** The detected JRE java is incompatible with !bitness! bit& goto setupjavahome
     231    if !ERRORLEVEL! equ 0 (
     232        echo *** The detected JRE java is a matching %bitness% bit         
     233        goto bundledjre
     234    )
     235)
     236
    217237:bundledjre
    218238:: We bundled a 32 bit JRE, but what if GS was compiled with 64 bit Java?
    219239:: All but MG/MGPP and GDBM should still work with 64 bit java.
    220 if exist "!HINT!\bin\java.exe" (
    221   echo *** Changing to use Greenstone's bundled 32-bit jre.
    222   set JRE_HOME=!HINT!
    223   ::set JAVA_HOME=!HINT!
     240if exist "!BUNDLED_JRE!\bin\java.exe" (
     241  echo *** Changing to use Greenstone's bundled jre.
     242  set JRE_HOME=!BUNDLED_JRE!
     243  ::set JAVA_HOME=!BUNDLED_JRE!
    224244  set PATH=!JRE_HOME!\bin;!PATH!
    225245  set RUNJAVA=!JRE_HOME!\bin\java.exe
     
    247267    goto summaryThenEnd
    248268)
     269
     270if exist "!BUNDLED_JRE!\bin\java.exe" goto bundledjre
    249271
    250272:: 5. Last ditch effort: search4j couldn't find any java, but check any Java env vars set anyway
     
    280302:summaryThenEnd
    281303:: 6. Check that the bitness of any Java found is appropriate and warn if it is not.
     304if "%bitness%" == "UNKNOWN" goto displayvars
    282305"!RUNJAVA!" -d%bitness% -version 2> nul
    283306if !ERRORLEVEL! equ 1 (
     
    291314)
    292315
     316:displayvars
    293317echo ********************************************************************
    294318echo.
Note: See TracChangeset for help on using the changeset viewer.