Changeset 31447 for main/trunk/greenstone3
- Timestamp:
- 2017-02-27T19:27:59+13:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/gs3-setup.bat
r30592 r31447 127 127 set JAVA_MIN_VERSION=1.5.0_00 128 128 set HINT=!CD!\packages\jre 129 129 130 ::if search4j is present, use it 130 131 set FOUNDJAVAHOME= … … 135 136 ) 136 137 138 139 echo. 140 echo ******************************************************************** 141 142 rem Check if any Java found matches the bitness of the Greenstone installation's binaries 143 rem The sort of output we want: 144 :: Installed GS as 32 bit 145 :: Detected java is 64 bit 146 :: Changing to use the GS bundled 32 bit jre 147 :: We've detected a mismatch, this will only affect MG/MGPP collections for searching and GDBM database collections 148 149 :: 1. What bit-ness are this Greenstone installation's binaries? 150 :: GNUfile: http://stackoverflow.com/questions/2689168/checking-if-file-is-32bit-or-64bit-on-windows 151 :: http://gnuwin32.sourceforge.net/packages/file.htm 152 :: using Cygwin's file utility: 153 :: http://stackoverflow.com/questions/2062020/how-can-i-tell-if-im-running-in-64-bit-jvm-or-32-bit-jvm-from-within-a-program 154 :: http://stackoverflow.com/questions/4089641/programatically-determine-if-native-exe-is-32-bit-or-64-bit 155 :: http://cygwin.com/cgi-bin2/package-grep.cgi?grep=utility 156 :: https://cygwin.com/licensing.html 157 :: Messy way: http://superuser.com/questions/358434/how-to-check-if-a-binary-is-32-or-64-bit-on-windows 158 159 :: "%GSDLHOME%\bin\windows\GNUfile\bin\file.exe" "%GSDLHOME%\bin\windows\wvWare.exe" 160 161 :: See https://ss64.com/nt/for_cmd.html for using batch FOR to loop against the results of another command. 162 :: Running 163 :: for /f "usebackq delims=" %%G IN (`"gs2build\bin\windows\GNUfile\bin\file.exe" gs2build\bin\windows\wvWare.exe`) do echo %%G 164 :: prints out the entire output, e.g.: 165 :: gs2build\bin\windows\wvWare.exe; PE32 executable for MS Windows (console) Intel 80386 32-bit 166 :: 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 168 :: http://stackoverflow.com/questions/6474738/batch-file-for-f-doesnt-work-if-path-has-spaces 169 :: Could use shortfilenames, see http://stackoverflow.com/questions/10227144/convert-long-filename-to-short-filename-8-3-using-cmd-exe 170 for /f "usebackq tokens=2 delims= " %%G IN (`call "%GSDLHOME%\bin\windows\GNUfile\bin\file.exe" "%GSDLHOME%\bin\windows\wvWare.exe"`) do set bitness=%%G 171 172 if "%bitness%" == "PE32+" ( 173 set bitness=64 174 echo The installed Greenstone is 64 bit 175 ) else ( 176 if "%bitness%" == "PE32" ( 177 set bitness=32 178 echo The installed Greenstone is 32 bit 179 ) else ( 180 echo WARNING: Greenstone installation is of unknown bitness. "%bitness%" is neither 32 nor 64 bit& goto bundledjre 181 set bitness=UNKNOWN 182 ) 183 ) 184 185 :: 2. What bitness are any JAVA_HOME else JRE_HOME found by search4j? 186 :: If you run the non-existent program "pinky" from batch or the DOS console, the exit value is 9009 187 :: The same must be true if java is not installed and therefore not found. echo %errorlevel% produces 9009 188 :: If java exists and is 32 bit, then running "java -d32 -version" has a return value of 1. echo %errorlevel% (1) 189 :: If java exists and is 64 bit, then running "java -d32 -version" has a return value of 0. echo %errorlevel% (0) 190 191 :testjavahome 192 :: http://www.robvanderwoude.com/errorlevel.php 193 :: https://ss64.com/nt/errorlevel.html 137 194 if DEFINED FOUNDJAVAHOME ( 138 set JAVA_HOME=!FOUNDJAVAHOME! 139 set PATH=!FOUNDJAVAHOME!\bin;!PATH! 140 set RUNJAVA=!FOUNDJAVAHOME!\bin\java.exe 141 goto summaryThenEnd 142 ) 143 144 if DEFINED FOUNDJREHOME ( 145 set JRE_HOME=!FOUNDJREHOME! 146 set PATH=!FOUNDJREHOME!\bin;!PATH! 147 set RUNJAVA=!FOUNDJREHOME!\bin\java.exe 148 goto summaryThenEnd 149 ) 150 195 echo *** Testing bitness of JAVA_HOME found at !FOUNDJAVAHOME!: 196 "!FOUNDJAVAHOME!\bin\java.exe" -d%bitness% -version 2> nul 197 if !ERRORLEVEL! equ 1 echo *** The detected system JDK java is an incompatible bit architecture& goto testjre 198 if !ERRORLEVEL! equ 0 ( 199 echo *** The detected system JDK java is a matching %bitness% bit 200 echo *** Using the system JAVA_HOME detected 201 set JAVA_HOME=!FOUNDJAVAHOME! 202 set PATH=!FOUNDJAVAHOME!\bin;!PATH! 203 set RUNJAVA=!FOUNDJAVAHOME!\bin\java.exe 204 goto summaryThenEnd 205 ) 206 ) 207 208 :testjre 209 if DEFINED FOUNDJREHOME ( 210 echo *** Testing bitness of JRE_HOME found at !FOUNDJREHOME!: 211 "!FOUNDJREHOME!\bin\java.exe" -d%bitness% -version 2> nul 212 if !ERRORLEVEL! equ 1 echo *** The detected JRE java is an incompatible bit architecture& goto bundledjre 213 if !ERRORLEVEL! equ 0 ( 214 rem The JRE_HOME found by search4j may be the bundled JRE, overriding any system JRE_HOME, 215 rem because the bundled JRE_HOME was provided as HINT to search4j. 216 echo *** The detected JRE java is a matching %bitness% bit 217 echo *** Using the JRE_HOME detected 218 set JRE_HOME=!FOUNDJREHOME! 219 set PATH=!FOUNDJREHOME!\bin;!PATH! 220 set RUNJAVA=!FOUNDJREHOME!\bin\java.exe 221 goto summaryThenEnd 222 ) 223 ) 224 225 :: 3. Fall back to 32 bit JRE bundled with GS 226 :bundledjre 227 :: We bundled a 32 bit JRE, but what if GS was compiled with 64 bit Java? 228 :: All but MG/MGPP and GDBM should still work with 64 bit java. 151 229 if exist "!HINT!\bin\java.exe" ( 230 echo *** Changing to use the GS bundled 32-bit jre. 152 231 set JAVA_HOME=!HINT! 153 232 set PATH=!JAVA_HOME!\bin;!PATH! … … 156 235 ) 157 236 237 :: 4. Last ditch effort: search4j couldn't find any java, but check any Java env vars set anyway 238 echo *** Search4j could not find an appropriate JAVA or JRE. 239 echo *** Attempting to use any JAVA_HOME else JRE_HOME in the environment... 240 158 241 if exist "!JAVA_HOME!\bin\java.exe" ( 159 242 set PATH=!JAVA_HOME!\bin;!PATH! … … 163 246 echo The source distribution of Greenstone3 requires Java 1.5 or greater 164 247 echo SVN users may still use Java 1.4 248 echo. 165 249 goto summaryThenEnd 166 250 ) … … 170 254 set RUNJAVA=!JRE_HOME!\bin\java.exe 171 255 echo Using Java at !JRE_HOME! 172 echo WARNING: Greenstone has not checked the version number of this J avainstallation256 echo WARNING: Greenstone has not checked the version number of this JRE installation 173 257 echo The source distribution of Greenstone3 requires Java 1.5 or greater 174 258 echo SVN users may still use Java 1.4 259 echo. 175 260 goto summaryThenEnd 176 261 ) 177 262 178 263 echo ERROR: Failed to locate Java 179 echo Please set JAVA_HOME or JRE_HOME to point to an appropriate Java264 echo Please set JAVA_HOME or JRE_HOME to point to an appropriate %bitness% bit Java 180 265 goto end 181 266 182 267 :summaryThenEnd 268 :: Check that the bitness of any Java found is appropriate and warn if it is not. 269 "!RUNJAVA!" -d%bitness% -version 2> nul 270 if !ERRORLEVEL! equ 1 ( 271 echo *** WARNING: Detected mismatch between the bit-ness of your Greenstone installation ^(%bitness% bit^) and the Java found. 272 echo *** Continuing with this Java anyway: 273 echo *** This will only affect MG/MGPP collections for searching, and GDBM database collections 274 echo *** Else set JAVA_HOME or JRE_HOME to point to an appropriate %bitness%-bit Java 275 echo *** Or recompile GS with your system Java: 276 if exist "!JAVA_HOME!" ( echo *** JAVA_HOME at !JAVA_HOME! ) else ( echo *** JRE_HOME at !JRE_HOME! ) 277 ) 278 279 echo ******************************************************************** 280 echo. 183 281 184 282 echo GSDL3SRCHOME : !GSDL3SRCHOME!
Note:
See TracChangeset
for help on using the changeset viewer.