[pkg-java] r5306 - trunk/batik/debian
fourmond at alioth.debian.org
fourmond at alioth.debian.org
Fri Jan 4 23:30:58 UTC 2008
Author: fourmond
Date: 2008-01-04 23:30:58 +0000 (Fri, 04 Jan 2008)
New Revision: 5306
Modified:
trunk/batik/debian/wrappers.sh
Log:
[batik] Improvements in wrappers.sh
Modified: trunk/batik/debian/wrappers.sh
===================================================================
--- trunk/batik/debian/wrappers.sh 2008-01-04 22:16:22 UTC (rev 5305)
+++ trunk/batik/debian/wrappers.sh 2008-01-04 23:30:58 UTC (rev 5306)
@@ -5,16 +5,25 @@
[ "$JAVA_CLASSPATH" ] || JAVA_CLASSPATH=
-# Use JAVACMD if it is set. If not, check JAVA_HOME, and fall back to
-# 'java' if both are unset.
-
-java_show_debug() {
+# Display a debugging message
+java_debug() {
if [ "$DEBUG" ]; then
echo "[debug] $0: $@" >&2;
fi
}
+# Displays a warning
+java_warning() {
+ echo "[warning] $0: $@" >&2;
+}
+# Exit with an error message
+java_fail() {
+ echo "[error] $0: $@" >&2;
+ exit 1;
+}
+
+
# Try to find a Java runtime and set JAVA_HOME and JAVACMD accordingly.
# If JAVACMD exists, nothing is done. If JAVA_HOME exists, only that
# is searched.
@@ -25,18 +34,36 @@
# * swing : a JVM that has swing
# * fullxml: a JVM that has all XML classes, including
# javax.xml.stream.util.StreamReaderDelegate
+# * sun: sun's JVM, for stuff depending on the infamous com.sun classes
+# * sun6: sun's JVM version 6
#
# If JAVA_DEBUG is set, we try to use jdb rather than java, if it is
# present.
#
# This information is currently *far from complete* !!!
find_java_runtime() {
- # First, some variables
+ # First, known runtimes:
sun_java="/usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun /usr/lib/j2sdk1.4-sun "
gcj2="/usr/lib/jvm/java-*-gcj-4.* "
+ sablevm="/usr/lib/sablevm"
+ kaffe="/usr/lib/kaffe /usr/lib/kaffe/pthreads /usr/lib/kaffe/jthreads"
icedtea="/usr/lib/jvm/java-7-icedtea"
+ cacao="/usr/lib/jvm/cacao"
+
+ # Then, classes of JVM:
+ all_runtimes="$gcj2 $cacao $sablevm $kaffe $icedtea $sun_java /usr/lib/jvm/*"
+
+ # Java2 runtimes:
+ java2_runtimes="$gcj2 $iced_tea $sun_java"
+
+ # Full swing runtimes:
+ full_swing_runtimes="$iced_tea $sun_java"
+
+ # Sun java apparently has some XML functions more than concurrents:
+ xml_extra="/usr/lib/jvm/java-6-sun /usr/lib/jvm/java-1.5.0-sun"
+
if [ "$JAVACMD" ]; then
- java_show_debug "Using already set JAVACMD = $JAVACMD"
+ java_debug "Using already set JAVACMD = $JAVACMD"
return 0; # Nothing to do
fi
@@ -45,18 +72,19 @@
# First, narrow the choices, approximately according to what
# was asked
case $1 in
- 2) DIRS="$icedtea $gcj2 $sun_java";
+ # A java2 runtime
+ 2) DIRS=$java2_runtimes
;;
- # So far, only Sun and IcedTea have swing...
swing) DIRS="$icedtea $sun_java";
;;
- sun) DIRS="$sun_java" # To make sure only sun is found...
+ sun) DIRS=$sun_java
;;
- xml) DIRS="$icedtea /usr/lib/jvm/java-6-sun ";
+ sun6) DIRS=/usr/lib/jvm/java-6-sun
;;
- *) DIRS=/usr/lib/jvm/*
- DIRS="$DIRS /usr/lib/kaffe"
+ fullxml) DIRS=$xml_extra
;;
+ *) DIRS=$all_runtimes
+ ;;
esac
# And pick up the first one that works
for dir in $DIRS; do
@@ -72,13 +100,20 @@
else
JAVACMD="$JAVA_HOME/bin/java"
fi
- java_show_debug "Found JAVA_HOME = $JAVA_HOME"
- java_show_debug "Found JAVACMD = $JAVACMD"
+ java_debug "Found JAVA_HOME = $JAVA_HOME"
+ java_debug "Found JAVACMD = $JAVACMD"
return 0 # Fine
else
- exit 1;
+ java_warning "No java runtime was found for flavor '${1:-none}'"
+ return 1;
fi
+}
+# Same as find_java_runtime, but fails with an error if
+# nothing is found.
+require_java_runtime() {
+ find_java_runtime "$@" || \
+ java_fail "Unable to find an appropriate java runtime"
}
# Find jars and add them to the classpath
@@ -89,18 +124,38 @@
elif [ -r $DESTDIR/usr/share/java/$jar.jar ]; then
JAVA_CLASSPATH=$JAVA_CLASSPATH:$DESTDIR/usr/share/java/$jar.jar
else
- echo "error: Unable to locate $jar in $DESTDIR/usr/share/java/" >&2
+ java_warning "Unable to locate $jar in $DESTDIR/usr/share/java/"
fi
done
}
+# Adds the first jar found to the classpath. Useful for alternative
+# dependencies.
+find_one_jar_in() {
+ for jar in $@ ; do
+ if [ -r $DESTDIR/usr/share/java/$jar ]; then
+ JAVA_CLASSPATH=$JAVA_CLASSPATH:$DESTDIR/usr/share/java/$jar
+ return 0
+ elif [ -r $DESTDIR/usr/share/java/$jar.jar ]; then
+ JAVA_CLASSPATH=$JAVA_CLASSPATH:$DESTDIR/usr/share/java/$jar.jar
+ return 0
+ fi
+ done
+ java_warning "Could fine none of $@ in $DESTDIR/usr/share/java/"
+ return 1
+}
+
# Runs the program !
run_java() {
+ if [ -z "$JAVACMD"]; then
+ java_warning "No JAVACMD set for run_java, using JAVACMD = java"
+ JAVACMD=java
+ fi
if [ "$JAVA_CLASSPATH" ]; then
cp="-cp $JAVA_CLASSPATH";
else
cp="";
fi
- java_show_debug "Runnning $JAVACMD $JAVA_ARGS $cp $@"
+ java_debug "Runnning $JAVACMD $JAVA_ARGS $cp $@"
exec $JAVACMD $JAVA_ARGS $cp "$@"
}
\ No newline at end of file
More information about the pkg-java-commits
mailing list