X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=jarrg-ian.git;a=blobdiff_plain;f=jpctb;h=a2cb243e910b5754201bc56757f7b2e230e8a39a;hp=c50b43baaed84e476373a57e34db8b99fd39cce4;hb=f990674d59428070dc501681c7fafd6a2e7e07d7;hpb=801ee8fc524bfda06f4bbfbec51caf228258d3fe diff --git a/jpctb b/jpctb index c50b43b..a2cb243 100755 --- a/jpctb +++ b/jpctb @@ -4,15 +4,116 @@ usage: .../jpctb /path/to/dir/with/PCTB*.jar /path/to/yohoho/yohoho [...] END } -jpctb_base="$0" -jpctb_base="${jpctb_base%/*}" +fail () { + echo >&2 "jpctb: $*" + exit 127 +} + +if [ $# -lt 2 ]; then usage; fail 'bad usage'; exit 127; fi + +srcjardir="$1"; shift +yohoho="$1"; shift + +#---------- find ourselves ---------- + +jpctbdir="$0" +jpctbdir="${jpctbdir%/*}" + +case "$jpctbdir" in +/*) ;; +*) jpctbdir="$PWD/$jpctbdir" ;; +esac + +#---------- find YPP client and the Java installation it uses ---------- + +yppdir="${yohoho%/*}" + +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" +fi + +case "$javadir" in +/*) ;; +*) javadir="$PWD/$javadir" ;; +esac + +jtmp="$jpctbdir/tmp" +linkfarm="$jtmp/linkfarm" +extdir="$jtmp/ext" + +#---------- confirm for the user which paths we're using ---------- + +cat <&2; exit 127; fi +lndir -silent "$javadir" "$linkfarm" + +#---------- edit the linkfarm to have our jvm wrapper ---------- + +wrapper="$linkfarm"/jre/bin/java +rm -- "$wrapper" + +export JPCTB_EXTDIR="$extdir" +export JPCTB_JRE="$javadir/jre" + +cat <<'END' >"$wrapper" +#!/bin/bash + set -e$JPCTB_JWRAP_X + + log () { + lh=`date +'%Y/%m/%d %H:%M:%S jpctb'` + printf >&2 "%s: %s |\f\n" "$lh" "$*" + } + + log "invoked as $*" + +#echo >&2 "$djava-wrap +#exec 4>>/home/ian/u +#date >&4 +#exec 4>&- + + yppclass=com.threerings.yohoho.client.YoApp + atclass=com.tedpearson.ypp.market.MarketUploader + + args=( "$@" ) + nargs=${#args[*]} + lastarg="${args[$(( $nargs - 1 ))]}" + + fail () { echo >&2 "jpctb-java: $*"; exit 127; } + + if [ x"$lastarg" = x"$yppclass" ]; then + + [ x"$JPCTB_EXTDIR" != x ] || fail 'JPCTB_EXTDIR not set' + + set -e$JPCTB_JWRAP_X -- \ + -Djavax.accessibility.assistive_technologies=$atclass \ + -Djava.ext.dirs="$JPCTB_EXTDIR:$JPCTB_JRE/lib/ext" \ + "$@" + fi + + real="$JPCTB_JRE/bin/java" + log "running $real $*" + exec "$real" "$@" +END -export JWRAP_EXTDIR="$1"; shift -export JWRAP_SCRIPT="$jpctb_base/jwrap-script-jpctb" +chmod +x -- "$wrapper" -if [ x"$LD_PRELOAD" != x ]; then LD_PRELOAD="$LD_PRELOAD:"; fi -export LD_PRELOAD="${LD_PRELOAD}$jpctb_base/libjwrap.so.1.0" +#---------- now run it ---------- -exec "$@" +exec "$yohoho" -Djava.home="$linkfarm/jre"