chiark / gitweb /
jpctb: Fix syntax
[jarrg-owen.git] / jpctb
diff --git a/jpctb b/jpctb
index e04b95682e39124f03c11e7540da67341a9448bc..f6c60e1552d879c28dceb7a34a66608ee19fc47e 100755 (executable)
--- a/jpctb
+++ b/jpctb
@@ -32,6 +32,12 @@ fail () {
        echo >&2 "jpctb: $*"
        exit 127
 }
        echo >&2 "jpctb: $*"
        exit 127
 }
+
+nojre () {
+       fail "couldn't find the right jre: $*
+ perhaps you should make ypp's java symlink (normally yohoho/java)
+ point to your jre, eg to /usr/lib/jvm/java-6-sun"
+
 badusage () {
        fail "bad usage: $*"
 }
 badusage () {
        fail "bad usage: $*"
 }
@@ -73,35 +79,63 @@ fi
 
 yppdir="${yohoho%/*}"
 
 
 yppdir="${yohoho%/*}"
 
-openjdk=/usr/lib/jvm/java-6-openjdk
+# this replicates the java-searching logic from yohoho/yohoho:
+if [ -x "$yohoho/java/bin/java" ]; then
+       yppjava="$yohoho/java/bin/java"
+elif [ -x "$JAVA_HOME/bin/java" ]; then
+       yppjava="$JAVA_HOME/bin/java"
+else
+       set +e
+       yppjava=`type -p java 2>&1`
+       set -e
+fi
 
 
-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
-       javadir=$openjdk
+cat <<END
+jpctb:
+   jpctb tree:  "$jpctbdir"
+   yohoho:       "$yohoho"
+   ypp uses:     "$yppjava"
+END
+
+if ! [ -x "$yppjava" ]; then
+       nojre "bad java ypp"
+fi
+
+javadir="${yppjava#/bin/java}"
+if [ -x "$javadir/jre/bin/java" ]; then
+       echo "   java/ points to the jre, good"
 else
 else
-       fail "could not find java runtime system
- please check that $yppdir/java points to your Java installation"
+       echo "   java/ has just the executable bin/java, trying readlink"
+       absjava=`readlink -f "$yppjava"`
+       echo "   abs. java:    \"$absjava\""
+       case "$absjava" in
+       */jre/bin/java)
+               echo "   found jre directory, good"
+               javadir="${absjava%/jre/bin/java}"
+               ;;
+       *)
+               nojre "java binary not in jre dir"
+               ;;
+       esac
 fi
 
 case "$javadir" in
 fi
 
 case "$javadir" in
-/*)    ;;
-*)     javadir="$PWD/$javadir" ;;
+|/|/usr)       nojre "javadir is $javadir (and even found $javadir/jre!)" ;;
+/*)            ;;
+*)             javadir="$PWD/$javadir" ;;
 esac
 
 jtmp="$jpctbdir/tmp"
 linkfarm="$jtmp/linkfarm"
 extdir="$jtmp/ext"
 
 esac
 
 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
 #---------- confirm for the user which paths we're using ----------
 
 cat <<END
-jpctb:
-   jpctb tree:  "$jpctbdir"
-   yohoho:       "$yohoho"
    java:         "$javadir"
    java:         "$javadir"
+   JRE:          "$JPCTB_JRE"
    PCTB jars:    "$srcjardir"
    jpctb tmpdir: "$jtmp"
 END
    PCTB jars:    "$srcjardir"
    jpctb tmpdir: "$jtmp"
 END
@@ -116,7 +150,7 @@ rm -rf -- "$jtmp"
 mkdir -- "$jtmp" "$extdir" "$linkfarm"
 cp "$srcjardir"/PCTB*.jar "$extdir"
 
 mkdir -- "$jtmp" "$extdir" "$linkfarm"
 cp "$srcjardir"/PCTB*.jar "$extdir"
 
-lndir -silent "$javadir" "$linkfarm"
+cp -Rs "$javadir"/. "$linkfarm"/.
 
 #---------- edit the linkfarm to have our jvm wrapper ----------
 
 
 #---------- edit the linkfarm to have our jvm wrapper ----------
 
@@ -124,7 +158,6 @@ wrapper="$linkfarm"/jre/bin/java
 rm -- "$wrapper"
 
 export JPCTB_EXTDIR="$extdir"
 rm -- "$wrapper"
 
 export JPCTB_EXTDIR="$extdir"
-export JPCTB_JRE="$javadir/jre"
 
 cat <<'END' >"$wrapper"
 #!/bin/bash
 
 cat <<'END' >"$wrapper"
 #!/bin/bash