File: tuxguitar.sh

package info (click to toggle)
tuxguitar 1.2-13+deb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 10,380 kB
  • ctags: 13,450
  • sloc: java: 75,206; xml: 2,213; ansic: 1,169; makefile: 982; cpp: 424; sh: 220
file content (182 lines) | stat: -rw-r--r-- 5,231 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#! /bin/sh
#@ident "$Id: tuxguitar.sh,v 1.3 2008/04/16 17:04:50 rzr Exp $"
#@Author: www.philippe.coval.online.fr -- revision: $Author: rzr $
#@Licence: LGPL
#@Description: Wrapper script for starting java application tuxguitar
###############################################################################
PACKAGE="tuxguitar"
[ ! -z $DEBUG ] && set -e
[ ! -z $DEBUG ] && set -x

#/// guess JAVA_HOME if undefined
java_guess_()
{
    d="/opt/java/"
    [ -d "$t" ] && d="$t"
    d="/usr/local/opt/java/"
    [ -d "$t" ] && d="$t"
# windows
    t="C:\\Program\ Files\\Java\\jre1.6.0_03/"
    [ -d "$t" ] && d="$t"
    t="\\Program\ Files\\Java\\jre1.6.0_03/"
    [ -d "$t" ] && d="$t"
    t="/Program\ Files/Java/jre1.6.0_03/"
    [ -d "$t" ] && d="$t"
# macosx
    t="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/"
    [ -d "$t" ] && d="$t"
# opensuse
    t="/etc/profile.d/alljava.sh"
    [ -r $t ] && . $t && echo ${JAVA_HOME} && return
    t="/usr/lib/jvm/java"
    [ -d "$t" ] && d="$t"
    t="/usr/lib64/jvm/java"
    [ -d "$t" ] && d="$t"
# mandriva
    t="/usr/lib/jvm/jre-1.6.0-sun/bin/../"
    [ -d "$t" ] && d="$t"
# gentoo
    t="/opt/sun-jdk-1.5.0.14/"
    [ -d "$t" ] && d="$t"
    t="/opt/sun-jdk-1.6.0.04/"
    [ -d "$t" ] && d="$t"
# debian
    if [ -r /etc/debian_version  ]; then
        t="/usr/lib/jvm/java-gcj/jre/bin/../../"
        [ -d "$t" ] && d="$t"
        t="/usr/lib/jvm/java-1.5.0-sun/jre/bin/../../"
        [ -d "$t" ] && d="$t"
        t="/usr/lib/jvm/java-6-sun/jre/bin/../../"
        [ -d "$t" ] && d="$t"
        t="/usr/lib/jvm/java-6-openjdk/jre/bin/../../"
        [ -d "$t" ] && d="$t"
    fi
# results
    [ -d "$d" ] && echo "$d"
}

# last match wins (no short-circuit evaluation)
swt_guess_()
{
    t="/usr/lib/eclipse/plugins/org.eclipse.swt.gtk.linux.*.jar"
    [ -r "$t" ] && f="$t"
    t="/usr/lib/java/swt3.2-gtk.jar"
    [ -r "$t" ] && f="$t"
    t="/usr/share/java/swt-gtk-3.4.jar"
    [ -r "$t" ] && f="$t"
    t="/usr/lib/java/swt-gtk-3.5.1.jar"
    [ -r "$t" ] && f="$t"
    t="/etc/alternatives/swt.jar"
    [ -r "$t" ] && f="$t"
    t="/usr/share/java/swt.jar"
    [ -r "$t" ] && f="$t"
    t="/usr/lib/java/swt.jar"
    [ -r "$t" ] && f="$t"
    file -L "$f" >/dev/null 2>&1 || f=""
    echo "$f"
}

#/// org.eclipse.swt.SWTError: No more handles
#/// [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]
mozilla_guess_()
{
    t="/usr/lib/mozilla"
    test -r "$t/libxpcom.so" && d="$t"
    t="/usr/lib/iceape/"
    test -r "$t/libxpcom.so" && d="$t"
    t="/usr/lib/icedove/"
    test -r "$t/libxpcom.so" && d="$t"
    t="/usr/lib/firefox/"
    test -r "$t/libxpcom.so" && d="$t"
    t="/usr/lib/iceweasel"
    test -r "$t/libxpcom.so" && d="$t"
    t="/usr/lib/xulrunner"
    test -r "$t/libxpcom.so" && d="$t"
    t="/usr/lib/xulrunner-1.9"
    test -r "$t/libxpcom.so" && d="$t"
    t="/usr/lib/xulrunner-1.9.1"
    test -r "$t/libxpcom.so" && d="$t"
    t="/usr/lib/xulrunner-5.0"
    test -r "$t/libxpcom.so" && d="$t"
    t="/usr/lib/xulrunner-6.0"
    test -r "$t/libxpcom.so" && d="$t"
    t="/usr/lib/xulrunner-7.0"
    test -r "$t/libxpcom.so" && d="$t"
    echo "$d"
}


#
env_()
{
    t="/etc/default/${PACKAGE}/env.sh"
    [ -r "$t" ] && . "$t"

    t="/etc/${PACKAGE}/env.sh"
    [ -r "$t" ] && . "$t"

# java
    [ -z ${JAVA_HOME} ] && t=$(java_guess_) && [ -d "$t" ] && JAVA_HOME="$t"
    if [ -d "${JAVA_HOME}" ] ; then
        export JAVA_HOME
        JAVA="${JAVA:=${JAVA_HOME}/jre/bin/java}"
        [ -x ${JAVA} ] && export JAVA
    else
        JAVA=${JAVA:=java}
        export JAVA
    fi

# mozilla
    [ -z ${MOZILLA_FIVE_HOME} ] \
	&& t=$(mozilla_guess_) && [ -d "$t" ] && MOZILLA_FIVE_HOME=$t
    if [ -d "$MOZILLA_FIVE_HOME" ] ; then
        export MOZILLA_FIVE_HOME
        export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MOZILLA_FIVE_HOME"
    else
        echo '$MOZILLA_FIVE_HOME not valid : check doc shipped w/ tuxguitar'
    fi

    [ ! -z ${DEBUG} ] && echo "# MOZILLA_FIVE_HOME=${MOZILLA_FIVE_HOME}"
    [ ! -z ${DEBUG} ] && echo "# JAVA_HOME=${JAVA_HOME}"}
}


tuxguitar_()
{
    local PACKAGE=${PACKAGE:=tuxguitar}
    local PACKAGE_HOME=${PACKAGE_HOME:=/usr/share/${PACKAGE}/}
    local PACKAGE_MAIN=${PACKAGE_MAIN:=org.herac.tuxguitar.gui.TGMain}
    local PACKAGE_LIB=${PACKAGE_LIB:=/usr/lib/jni}
# java env
    JAVA=${JAVA:=java}
    CLASSPATH=${CLASSPATH}
    t="${PACKAGE_HOME}"
    [ -d "$t" ] && CLASSPATH=${CLASSPATH}:$t
    t="${PACKAGE_HOME}/${PACKAGE}.jar"
    [ -r "$t" ] && CLASSPATH=${CLASSPATH}:$t
    t="/usr/share/java/itext.jar"
    [ -r "$t" ] && CLASSPATH=${CLASSPATH}:$t
    t=$(swt_guess_)
    [ -r "$t" ] && CLASSPATH=${CLASSPATH}:$t

    JAVA_FLAGS=${JAVA_FLAGS:="-Xms128m -Xmx128m"}
    JAVA_FLAGS=" ${JAVA_FLAGS} \
        -Djava.library.path=${PACKAGE_LIB} \
        -D${PACKAGE}.share.path=/usr/share/${PACKAGE} \
        -cp ${CLASSPATH}:${PACKAGE_CLASSPATH} \
        "
    local arg=""
    [ -z "$1" ] && arg="/usr/share/tuxguitar/tuxguitar.tg"
# run java
    [ ! -z ${DEBUG} ] && ${JAVA} -version
    [ ! -z ${DEBUG} ] && ${JAVA} ${JAVA_FLAGS} ${PACKAGE_MAIN} --version

    ${JAVA} ${JAVA_FLAGS} ${PACKAGE_MAIN} $arg "$@"
}

# main

env_
tuxguitar_ "$@"

#eof