Changeset 31481
- Timestamp:
- 2017-03-09T19:10:38+13:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/gs3-setup.sh
r31462 r31481 9 9 # java_min_version gets passed to search4j as the minimum java version 10 10 java_min_version=1.5.0_00 11 11 DEBUG=false 12 12 13 13 function testSource(){ … … 180 180 181 181 # we now include a JRE with Mac (Mountain) Lion too, because from Yosemite onwards there's no system Java on Macs 182 HINT="`pwd`/packages/jre" 182 BUNDLED_JRE="`pwd`/packages/jre" 183 HINT=$BUNDLED_JRE 183 184 184 185 #if [ "$GSDLOS" = "darwin" ] && [ ! -d "$HINT" ]; then … … 195 196 fi 196 197 197 echo "**********************************************"198 if [ "$DEBUG" == "true" ]; then echo "**********************************************"; fi 198 199 199 200 # If the file utility exists, use it to determine the bitness of this GS3, … … 216 217 # can also use double brackets: if [[ $? > 1 ]]; then ... 217 218 if [ "$?" -gt "1" ]; then 218 echo "*** 'file' utility not found installed on this unix-based system." 219 echo "*** Unable to use 'file' utility to determine bitness of this GS3 to see if it matches that of any Java found." 219 if [ "$DEBUG" == "true" ]; then 220 echo " 'file' utility not found installed on this unix-based system." 221 echo " Unable to use 'file' utility to determine bitness of this GS3 to see if it matches that of any Java found." 222 fi 223 bitness=-1 224 elif [ ! -f "$GSDL3SRCHOME/lib/jni/libgdbmjava.so" ]; then 225 # the file we want to test the bitness of, to determine GS3's bitness by, doesn't exist yet 220 226 bitness=-1 221 227 else … … 239 245 # we'll print a warning about this bitness mismatch at the end 240 246 247 javaset=false 241 248 if [ -x bin/search4j ] ; then 242 FOUNDJAVAHOME="`bin/search4j -p \"$HINT\" -m $java_min_version`" 243 if [ "$?" == "0" ]; then 249 FOUNDJAVAHOME="`bin/search4j -d -p \"$HINT\" -m $java_min_version`" 250 javahome_retval=$? 251 FOUNDJREHOME="`bin/search4j -r -p \"$HINT\" -m $java_min_version`" 252 jrehome_retval=$? 253 fi 254 255 # 1. check the bitness of any JDK java found by search4j, and use if appropriate 256 if [ "$javahome_retval" == "0" ]; then 244 257 checkJavaBitnessAgainstGSBitness "$FOUNDJAVAHOME" "$bitness" 245 258 246 259 if [ "$?" == "0" ]; then 247 260 #found a suitable java 248 if [ "$bitness" != "-1" ] ; then249 echo " *** The detected javais a matching $bitness bit"261 if [ "$bitness" != "-1" ] && [ "$DEBUG" == "true" ]; then 262 echo " The detected JDK at $FOUNDJAVAHOME is a matching $bitness bit" 250 263 fi 251 setupJavaAt "$FOUNDJAVAHOME" 252 else 253 if [ "$bitness" != "-1" ]; then 254 echo "*** The detected java is an incompatible bit architecture" 264 setupJavaAt "$FOUNDJAVAHOME" "JDK" 265 javaset=true 266 267 elif [ "$bitness" != "-1" ] && [ "$DEBUG" == "true" ]; then 268 echo " The detected JDK java at $FOUNDJAVAHOME is an incompatible bit architecture" 269 fi 270 fi 271 272 # 2. check bitness of any JRE java found by search4j, and use if appropriate 273 # http://tldp.org/LDP/abs/html/comparison-ops.html 274 if [ "$javaset" != "true" ] && [ "$jrehome_retval" == "0" ]; then 275 checkJavaBitnessAgainstGSBitness "$FOUNDJREHOME" "$bitness" 276 277 if [ "$?" == "0" ]; then 278 #found a suitable jre 279 if [ "$bitness" != "-1" ] && [ "$DEBUG" == "true" ]; then 280 echo " The detected JRE at $FOUNDJREHOME is a matching $bitness bit" 255 281 fi 256 257 # check any bundled JRE 258 if [ -d "$HINT" ]; then 259 # For linux, the bundled JRE will be of a bitness matching this OS. 282 setupJavaAt "$FOUNDJREHOME" "JRE" 283 javaset=true 284 285 elif [ "$bitness" != "-1" ] && [ "$DEBUG" == "true" ]; then 286 echo " The detected JRE java at $FOUNDJREHOME is an incompatible bit architecture" 287 fi 288 fi 289 290 # 3. check the bitness of any bundled JRE, and use if appropriate 291 if [ "$javaset" != "true" ] && [ -d "$BUNDLED_JRE" ]; then 292 checkJavaBitnessAgainstGSBitness "$FOUNDJREHOME" "$bitness" 293 294 # For linux, the bundled JRE ought to be of a bitness matching this OS. 295 if [ "$?" == "0" ]; then 296 if [ "$bitness" != "-1" ] && [ "$DEBUG" == "true" ]; then 297 # bundled JRE matches GS bitness 260 298 echo "*** Changing to use Greenstone's bundled $bitness-bit jre" 261 setupJavaAt "$HINT" "JRE"262 else263 # go with the JAVA_HOME that search4j found264 echo "*** Using the Java detected: "265 setupJavaAt "$FOUNDJAVAHOME"266 299 fi 267 fi 268 else 269 #no suitable java exists 270 echo " - ERROR: Failed to locate java $java_min_version or greater" 300 setupJavaAt "$BUNDLED_JRE" "JRE" 301 javaset=true 302 303 elif [ "$bitness" != "-1" ] && [ "$DEBUG" == "true" ]; then 304 echo " The bundled JRE java is an incompatible bit architecture" 305 fi 306 fi 307 308 # 4. None of the java found so far, if any (via search4j, bundled_jre), may have matched bitness wise 309 # So, fall back to using whichever is available in sequence anyway. 310 # We'll print a warning of bitness mismatch later 311 312 if [ "$javaset" != "true" ]; then 313 # go with any JAVA_HOME else JRE_HOME that search4j found, else with any bundled JRE if present 314 if [ "$javahome_retval" == "0" ]; then 315 setupJavaAt "$FOUNDJAVAHOME" "JDK" 316 javaset=true 317 elif [ "$jrehome_retval" == "0" ]; then 318 setupJavaAt "$FOUNDJREHOME" "JRE" 319 javaset=true 320 elif [ -d "$BUNDLED_JRE" ]; then 321 # bundled JRE should be >= than minimum version of java required 322 setupJavaAt "$BUNDLED_JRE" "JRE" 323 javaset=true 324 fi 325 fi 326 327 # 5. lastly, check if java already setup 328 if [ "$javaset" != "true" ]; then 329 330 if [ -x bin/search4j ]; then 331 332 # no suitable java could be found by search4j 333 echo " - ERROR: Failed to locate java $java_min_version or greater" 271 334 echo " Please set JAVA_HOME or JRE_HOME to point to an appropriate java" 272 335 echo " And add JAVA_HOME/bin or JRE_HOME/bin to your PATH" 273 fi 274 275 #otherwise no search4j, manually try the hint (the bundled jre) if it exists 276 elif [ -d "$HINT" ]; then 277 #found a suitable java 278 setupJavaAt "$HINT" "JRE" 279 280 #lastly, check if java already setup 281 else 336 337 else 338 # search4j wasn't present, and no bundled JRE, so check JAVA_HOME or JRE_HOME manually 282 339 echo "*** Could not find an appropriate JDK or JRE java" 283 340 echo "*** Attempting to use JAVA_HOME else JRE_HOME in the environment" … … 302 359 return 303 360 fi 361 fi 304 362 fi 305 363 … … 329 387 fi 330 388 331 echo "**********************************************" 332 } 333 389 if [ "$DEBUG" == "true" ]; then echo "**********************************************"; fi 390 391 } 392 393 # if bitness (parameter #2) is -1, then this function returns 0 (generally meaning success). 334 394 function checkJavaBitnessAgainstGSBitness() { 335 # echo "Checking bitness"395 # if [ "$DEBUG" == "true" ]; then echo "Testing bitness of java found at $java_installation"; fi 336 396 java_installation="$1" 337 397 bitness="$2" … … 360 420 361 421 function setupJavaAt() { 362 export JAVA_HOME="$1" 363 addtopath PATH "$JAVA_HOME/bin" 364 echo " - Exported JAVA_HOME to $JAVA_HOME" 422 423 # check the second parameter if non-null 424 if [ -n "$2" ] && [ "$2" == "JRE" ]; then 425 export JRE_HOME="$1" 426 addtopath PATH "$JAVA_HOME/bin" 427 428 BUNDLED_JRE="`pwd`/packages/jre" 429 if [[ "$JRE_HOME" == *"$BUNDLED_JRE"* ]]; then 430 msg="the bundled" 431 fi 432 433 echo " - Exported JRE_HOME to $msg $JRE_HOME" 434 else 435 export JAVA_HOME="$1" 436 addtopath PATH "$JAVA_HOME/bin" 437 echo " - Exported JAVA_HOME to $JAVA_HOME" 438 fi 439 440 365 441 } 366 442
Note:
See TracChangeset
for help on using the changeset viewer.