chiark / gitweb /
Try harder to find the JRE (eg if yohoho/java is a symlink to /usr
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 22 Aug 2010 17:54:09 +0000 (18:54 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 22 Aug 2010 17:54:09 +0000 (18:54 +0100)
jpctb

diff --git a/jpctb b/jpctb
index e04b956..c55f90c 100755 (executable)
--- a/jpctb
+++ b/jpctb
@@ -73,20 +73,63 @@ fi
 
 yppdir="${yohoho%/*}"
 
-openjdk=/usr/lib/jvm/java-6-openjdk
+cat <<END
+jpctb:
+   jpctb tree:  "$jpctbdir"
+   yohoho:       "$yohoho"
+END
 
 if [ -x "$yppdir/java/bin/java" ]; then
-       javadir="$yppdir/java"
-elif [ x"$JAVA_HOME" != x ] && [ -x "$JAVA_HOME/bin/java" ]; then
-       javadir="$JAVA_HOME"
-elif [ -x $openjdk/bin/java ]; then
+       if [ test -d "$yppdir/java/jre" ]; then
+               echo "   yohoho/java/bin and yohoho/java/jre exist, good"
+               javadir="$yppdir/java"
+       else
+               absjava=`readlink -f "$javadir/bin/java"`
+               cat <<END
+   yohoho/java/bin exists but yohoho/java/jre does not
+   abs. java:    "$absjava"
+END
+               case "$absjava" in
+               */jre/bin/java)
+                       echo "   found jre directory, good"
+                       javadir="${absjava%/jre/bin/java}"
+                       ;;
+               *)
+                       echo "   java binary not in jre dir as expected, hmm."
+                       ;;
+               esac
+       fi
+fi
+
+if [ "x$javadir" = x ] && [ x"$JAVA_HOME" != x ] && \
+   [ -x "$JAVA_HOME/bin/java" ]; then
+cat <<END
+   yohoho/java/bin/java nonexistent or unsuitable, trying JAVA_HOME"
+   JAVA_HOME:    "$JAVA_HOME"
+END
+       if [ -d "$JAVA_HOME/jre" ]; then
+               javadir="$JAVA_HOME"
+       else
+               echo "   JAVA_HOME has no jre subdirectory, hmm."
+       fi
+fi
+
+openjdk=/usr/lib/jvm/java-6-openjdk
+
+if [ "x$javadir" = x ] && [ -x $openjdk/bin/java ]; then
+       echo "  using openjdk, hopefully it will work with YPP!"
        javadir=$openjdk
-else
+fi
+
+if [ "x$javadir" = x ]; then
        fail "could not find java runtime system
  please check that $yppdir/java points to your Java installation"
 fi
 
 case "$javadir" in
+/usr)  fail "javadir is still /usr (and even found /usr/jre!)
+ please make $yppdir/java point somewhere more sensible and/or
+ reinstall YPP not telling it your java is in /usr.  sorry." ;;
 /*)    ;;
 *)     javadir="$PWD/$javadir" ;;
 esac
@@ -95,13 +138,13 @@ jtmp="$jpctbdir/tmp"
 linkfarm="$jtmp/linkfarm"
 extdir="$jtmp/ext"
 
+export JPCTB_JRE="$javadir/jre"
+
 #---------- confirm for the user which paths we're using ----------
 
 cat <<END
-jpctb:
-   jpctb tree:  "$jpctbdir"
-   yohoho:       "$yohoho"
    java:         "$javadir"
+   JRE:          "$JPCTB_JRE"
    PCTB jars:    "$srcjardir"
    jpctb tmpdir: "$jtmp"
 END
@@ -124,7 +167,6 @@ wrapper="$linkfarm"/jre/bin/java
 rm -- "$wrapper"
 
 export JPCTB_EXTDIR="$extdir"
-export JPCTB_JRE="$javadir/jre"
 
 cat <<'END' >"$wrapper"
 #!/bin/bash