usage () { cat <<END
-usage: .../jpctb /path/to/dir/with/PCTB*.jar /path/to/yohoho/yohoho [...]
+usage: .../jpctb /path/to/yohoho/yohoho [...]
END
}
echo >&2 "jpctb: $*"
exit 127
}
+badusage () {
+ fail "bad usage: $*"
+}
-if [ $# -lt 2 ]; then usage; fail 'bad usage'; exit 127; fi
+while [ $# -ge 1 ]; do
+ case "$1" in
+ -) shift; break;;
+ --jpctb)
+ shift
+ srcjardir="$1"
+ shift || badusage "--jpctb needs a value"
+ ;;
+ -*) badusage "unknown option \`$1'"
+ ;;
+ *)
+ break
+ esac
+done
+
+if [ $# -lt 1 ]; then usage; badusage "need path to yohoho"; exit 127; fi
-srcjardir="$1"; shift
yohoho="$1"; shift
#---------- find ourselves ----------
*) jpctbdir="$PWD/$jpctbdir" ;;
esac
+if [ x"$srcjardir" = x ]; then
+ srcjardir="$jpctbdir"
+fi
+
#---------- find YPP client and the Java installation it uses ----------
yppdir="${yohoho%/*}"
+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"
-else
- fail "could not find java runtime system"
+ 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
+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
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
rm -- "$wrapper"
export JPCTB_EXTDIR="$extdir"
-export JPCTB_JRE="$javadir/jre"
cat <<'END' >"$wrapper"
#!/bin/bash