Changeset 31472

Show
Ignore:
Timestamp:
08.03.2017 20:23:06 (3 years ago)
Author:
ak19
Message:

Better debug statements and tabbing without * characters, DEBUG flag (set to false by default) to reduce output on regular runs, removed trailing whitespace in newer code section, if no gdbmjava.dll we will jump to setupjavahome not testjavahome, broke up long lines using the recommended caret mark with space where a space is needed.

Files:
1 modified

Legend:

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

    r31471 r31472  
    22 
    33setlocal enabledelayedexpansion 
     4 
     5set DEBUG=false 
    46 
    57set java_min_version=1.5.0_00 
     
    9092 
    9193:: ---- if gs2build is there, run its setup.bat file ---- 
    92 endlocal & set RUNJAVA=%RUNJAVA%& set PATH=%PATH%& set GSDLOS=%GSDLOS%& set GSDLHOME=%GSDLHOME%& set GSDL3HOME=%GSDL3HOME%& set GSDL3SRCHOME=%GSDL3SRCHOME%& set JAVA_HOME=%JAVA_HOME%& set JRE_HOME=%JRE_HOME%& set ANT_HOME=%ANT_HOME%& set CLASSPATH=%CLASSPATH% 
     94:: http://stackoverflow.com/questions/69068/long-commands-split-over-multiple-lines-in-windows-vista-batch-bat-file 
     95endlocal & set DEBUG=%DEBUG%& set RUNJAVA=%RUNJAVA%& set PATH=%PATH%& set GSDLOS=%GSDLOS%& set GSDLHOME=%GSDLHOME%& set GSDL3HOME=%GSDL3HOME%^ 
     96 & set GSDL3SRCHOME=%GSDL3SRCHOME%& set JAVA_HOME=%JAVA_HOME%& set JRE_HOME=%JRE_HOME%& set ANT_HOME=%ANT_HOME%& set CLASSPATH=%CLASSPATH% 
    9397 
    9498if exist gs2build\setup.bat ( 
     
    139143 
    140144echo. 
    141 echo ******************************************************************** 
     145if "%DEBUG%" == "true" echo ******************************************************************** 
    142146 
    143147rem Check if any Java found matches the bitness of the Greenstone installation's binaries 
     
    165169::      gs2build\bin\windows\wvWare.exe; PE32 executable for MS Windows (console) Intel 80386 32-bit 
    166170:: To just get the "PE32" part of that output, set the delimiter char to space and request only the 2nd token: 
    167 :: Note: Using call before the command to allow 2 sets of double quotes, see  
     171:: Note: Using call before the command to allow 2 sets of double quotes, see 
    168172:: http://stackoverflow.com/questions/6474738/batch-file-for-f-doesnt-work-if-path-has-spaces 
    169173:: Could use shortfilenames, see http://stackoverflow.com/questions/10227144/convert-long-filename-to-short-filename-8-3-using-cmd-exe 
    170 if not exist "!GSDL3SRCHOME!\lib\jni\gdbmjava.dll" set bitness=UNKNOWN& goto testjavahome 
     174if not exist "!GSDL3SRCHOME!\lib\jni\gdbmjava.dll" set bitness=UNKNOWN& goto setupjavahome 
    171175for /f "usebackq tokens=2 delims= " %%G IN (`call "!GSDLHOME!\bin\windows\GNUfile\bin\file.exe" "!GSDL3SRCHOME!\lib\jni\gdbmjava.dll"`) do set bitness=%%G 
    172176 
     
    179183        echo The installed Greenstone is 32 bit 
    180184    ) else ( 
    181         echo WARNING: Greenstone installation is of unknown bitness. "%bitness%" is neither 32 nor 64 bit        
     185        echo WARNING: Greenstone installation is of unknown bitness. "%bitness%" is neither 32 nor 64 bit 
    182186        set bitness=UNKNOWN 
    183187    ) 
     
    195199if DEFINED FOUNDJAVAHOME  ( 
    196200    if "%bitness%" == "UNKNOWN" goto setupjavahome 
    197     echo *** Testing bitness of JAVA_HOME found at !FOUNDJAVAHOME!: 
     201    if "%DEBUG%" == "true" echo    Testing bitness of JAVA_HOME found at !FOUNDJAVAHOME!: 
    198202    "!FOUNDJAVAHOME!\bin\java.exe" -d%bitness% -version 2> nul 
    199     if !ERRORLEVEL! equ 1 echo *** The detected JDK java is incompatible with !bitness! bit GS& goto testjre     
     203    if !ERRORLEVEL! equ 1 if "%DEBUG%" == "true" echo     The detected JDK java is incompatible with !bitness! bit GS& goto testjre 
    200204    if !ERRORLEVEL! equ 0 ( 
    201         echo *** The detected JDK java is a matching %bitness% bit 
     205        if "%DEBUG%" == "true" echo    The detected JDK java is a matching %bitness% bit 
    202206        goto setupjavahome 
    203     )    
     207    ) 
    204208) 
    205209 
     
    207211if DEFINED FOUNDJREHOME  ( 
    208212    if "%bitness%" == "UNKNOWN" goto setupjrehome 
    209     echo *** Testing bitness of JRE_HOME found at !FOUNDJREHOME!: 
     213    if "%DEBUG%" == "true" echo    Testing bitness of JRE_HOME found at !FOUNDJREHOME!: 
    210214    "!FOUNDJREHOME!\bin\java.exe" -d%bitness% -version 2> nul 
    211     if !ERRORLEVEL! equ 1 echo *** The detected JRE java is incompatible with !bitness! bit GS& goto testbundledjre 
     215    if !ERRORLEVEL! equ 1 if "%DEBUG%" == "true" echo    The detected JRE java is incompatible with !bitness! bit GS& goto testbundledjre 
    212216    if !ERRORLEVEL! equ 0 ( 
    213217        rem The JRE_HOME found by search4j may be the bundled JRE, overriding any system JRE_HOME, 
    214218        rem because the bundled JRE_HOME was provided as HINT to search4j. 
    215         echo *** The detected JRE java is a matching %bitness% bit 
     219        if "%DEBUG%" == "true" echo    The detected JRE java is a matching %bitness% bit 
    216220        goto setupjrehome 
    217     )    
     221    ) 
    218222) 
    219223 
     
    222226if exist "!BUNDLED_JRE!\bin\java.exe" ( 
    223227    if "%bitness%" == "UNKNOWN" goto bundledjre 
    224      
    225     echo *** Testing bitness of bundled JRE at !BUNDLED_JRE!: 
     228    if "%DEBUG%" == "true" echo     Testing bitness of bundled JRE at !BUNDLED_JRE!: 
    226229    "!BUNDLED_JRE!\bin\java.exe" -d%bitness% -version 2> nul 
    227     if !ERRORLEVEL! equ 1 echo *** The detected JRE java is incompatible with !bitness! bit& goto setupjavahome 
     230    if !ERRORLEVEL! equ 1 if "%DEBUG%" == "true" echo     The bundled JRE java is incompatible with !bitness! bit& goto setupjavahome 
    228231    if !ERRORLEVEL! equ 0 ( 
    229         echo *** The detected JRE java is a matching %bitness% bit 
     232        if "%DEBUG%" == "true" echo     The bundled JRE java is a matching %bitness% bit 
     233        echo *** Changing to use Greenstone's bundled JRE. 
    230234        goto bundledjre 
    231235    ) 
     
    236240:: All but MG/MGPP and GDBM should still work with 64 bit java. 
    237241if exist "!BUNDLED_JRE!\bin\java.exe" ( 
    238   echo *** Changing to use Greenstone's bundled jre. 
    239242  set JRE_HOME=!BUNDLED_JRE! 
    240243  ::set JAVA_HOME=!BUNDLED_JRE! 
     
    249252:setupjavahome 
    250253if DEFINED FOUNDJAVAHOME  ( 
    251     echo *** Using the JAVA_HOME detected at !FOUNDJAVAHOME! 
     254    echo Using the JAVA_HOME detected at !FOUNDJAVAHOME! 
    252255    set JAVA_HOME=!FOUNDJAVAHOME! 
    253256    set PATH=!FOUNDJAVAHOME!\bin;!PATH! 
     
    257260 
    258261:setupjrehome 
    259 if DEFINED FOUNDJREHOME ( 
    260     echo *** Using the JRE_HOME detected at !FOUNDJREHOME! 
     262if DEFINED FOUNDJREHOME  ( 
     263    if "!FOUNDJREHOME!" == "!BUNDLED_JRE!" ( 
     264        echo Using the bundled JRE detected at !FOUNDJREHOME! 
     265    ) else ( 
     266        echo Using the JRE detected at !FOUNDJREHOME! 
     267    ) 
    261268    set JRE_HOME=!FOUNDJREHOME! 
    262269    set PATH=!FOUNDJREHOME!\bin;!PATH! 
     
    265272) 
    266273 
    267 if exist "!BUNDLED_JRE!\bin\java.exe" goto bundledjre 
     274if exist "!BUNDLED_JRE!\bin\java.exe" ( 
     275    echo Using the bundled JRE detected at !FOUNDJREHOME! 
     276    goto bundledjre 
     277) 
    268278 
    269279:: 5. Last ditch effort: search4j couldn't find any java, but check any Java env vars set anyway 
    270 echo *** Search4j could not find an appropriate JDK or JRE java. 
    271 echo *** Attempting to use any JAVA_HOME else JRE_HOME in the environment... 
    272      
     280echo     Search4j could not find an appropriate JDK or JRE java. 
     281echo     Attempting to use any JAVA_HOME else JRE_HOME in the environment... 
     282 
    273283if exist "!JAVA_HOME!\bin\java.exe" ( 
    274284  set PATH=!JAVA_HOME!\bin;!PATH! 
     
    305315    echo *** and the Java found at !RUNJAVA!. 
    306316    echo *** Continuing with this Java anyway: 
    307     echo *** This will only affect MG/MGPP collections for searching, and GDBM database collections 
    308     echo *** Else set JAVA_HOME or JRE_HOME to point to an appropriate %bitness%-bit Java 
    309     echo *** Or recompile GS with your system Java: 
     317    echo *** This will only affect MG/MGPP collections for searching, and GDBM database collections. 
     318    echo *** Else set JAVA_HOME or JRE_HOME to point to an appropriate %bitness%-bit Java, 
     319    echo *** or recompile GS with your system Java: 
    310320    if exist "!JAVA_HOME!" ( echo *** JAVA_HOME at !JAVA_HOME! ) else ( echo *** JRE_HOME at !JRE_HOME! ) 
    311321) 
    312322 
    313323:displayvars 
    314 echo ******************************************************************** 
     324if "%DEBUG%" == "true" echo ******************************************************************** 
    315325echo. 
    316326 
     
    332342:done 
    333343:: End localisation of variables that started with the set local/set enabledelayedexpansion command 
    334 :: Restore global variables that would otherwise be lost at script's end due to their having been initialised in a  
     344:: Restore global variables that would otherwise be lost at script's end due to their having been initialised in a 
    335345:: set local/set enabledelayedexpansion section. See http://ss64.com/nt/endlocal.html 
    336 endlocal & set RUNJAVA=%RUNJAVA%& set PATH=%PATH%& set GSDLOS=%GSDLOS%& set GSDLHOME=%GSDLHOME%& set GSDL3HOME=%GSDL3HOME%& set GSDL3SRCHOME=%GSDL3SRCHOME%& set JAVA_HOME=%JAVA_HOME%& set JRE_HOME=%JRE_HOME%& set ANT_HOME=%ANT_HOME%& set CLASSPATH=%CLASSPATH% 
     346endlocal & set RUNJAVA=%RUNJAVA%& set PATH=%PATH%& set GSDLOS=%GSDLOS%& set GSDLHOME=%GSDLHOME%& set GSDL3HOME=%GSDL3HOME%& set GSDL3SRCHOME=%GSDL3SRCHOME%^ 
     347 & set JAVA_HOME=%JAVA_HOME%& set JRE_HOME=%JRE_HOME%& set ANT_HOME=%ANT_HOME%& set CLASSPATH=%CLASSPATH% 
    337348 
    338349:end