chiark / gitweb /
f6fe699d3e207ea0ec529fd958cf5ab4671f323d
[jarrg-owen.git] / jwrap-script
1 #!/bin/bash
2 set -e$JWRAP_SCRIPT_X
3
4 unwire () {
5         ldp="$LD_PRELOAD:"
6         ldp2=''
7
8         while [ "x$ldp" != x ]; do
9                 this="${ldp%%:*}"
10                 ldp="${ldp#*:}"
11                 case "$this" in
12                 *libjwrap*.so.*)                                ;;
13                 *)                      ldp2="$ldp2$this:"      ;;
14                 esac
15         done
16
17         if [ "x$ldp2" != x ]; then
18                 LD_PRELOAD="${ldp2%:}"
19         else
20                 unset LD_PRELOAD
21         fi
22
23         unset JWRAP_SCRIPT
24 }
25
26 echo ":$*"
27
28 path="$1"; shift
29 arg0="$1"; shift
30
31 args=( "$@" )
32 nargs=${#args[*]}
33 lastarg="${args[$(( $nargs - 1 ))]}"
34
35 fail () {
36         echo >&2 "jwrap-script: $*"
37         exit 127
38 }
39
40 if [ x"$lastarg" = x"com.threerings.yohoho.client.YoApp" ]; then
41         case "$path" in
42         */bin/java) ;;
43         *)      fail "unexpected path format $path" ;;
44         esac
45         [ x"$JWRAP_EXTDIR" != x ] || fail 'JWRAP_EXTDIR not set'
46         extdirs="$JWRAP_EXTDIR:${path%/bin/java}/lib/ext"
47
48         set     -e$JWRAP_SCRIPT_X -- \
49                 -Djavax.accessibility.assistive_technologies=com.tedpearson.ypp.market.MarketUploader \
50                 -Djava.ext.dirs="$extdirs" \
51                 "$@"
52
53         unwire
54 fi
55
56 exec -a "$arg0" /dev/jwrap/bypass "$path" "$@"