~ubuntu-branches/ubuntu/utopic/freemind/utopic

« back to all changes in this revision

Viewing changes to freemind/freemind.sh

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-01-03 14:19:19 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100103141919-m5az7dkicy21hqop
Tags: 0.9.0~rc6+dfsg-1ubuntu1
* Merge from Debian unstable (LP: #182927), remaining changes:
  - debian/copyright: add license/copyright for
    freemind/freemind/main/ExampleFileFilter.java

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# 2004-02-13, modified for Debian by deb@zorglub.s.bawue.de
3
3
# 2004-06-19, rewritten for Linux/UN*X by deb@zorglub.s.bawue.de
4
4
#             (based on Jan Schulz's input)
5
 
# 2005-01-08, removed bashisms (resp. HP-UX posixsms) and made it POSIX conform
 
5
# 2004-11-28, minor changes for version 0.8.0 by deb@zorglub.s.bawue.de
 
6
# 2005-01-08, removed bashims to make script POSIX conform
 
7
# 2005-01-16, added usage of FREEMIND_BASE_DIR variable
 
8
# 2005-02-18, add -Dfreemind.base.dir to make plugins work, add some ""
 
9
#             and enhance debug mode.
 
10
# 2005-11-08, adding commons-codec to classpath.
 
11
# 2005-11-09, add some dpkg/rpm information and check for Sun/Blackdown VM.
 
12
# 2006-10-29, follow links to this script using readlink.
 
13
# 2008-02-02, improve Java recognition, add lsb_release, fix -x which being empty
 
14
#             add -Dgnu.java.awt.peer.gtk.Graphics=Graphics2D for non-Sun JREs
 
15
# 2008-02-03, add debug values script and exit
 
16
# 2008-05-20 (fc): -Xmx256M added
 
17
# 2008-08-08 (ewl) accept OpenJDK as valid VM to run FreeMind.
 
18
 
 
19
# we only want to test the script, not FreeMind itself
 
20
if ( echo "${DEBUG}" | grep -qe "script" )
 
21
then
 
22
        set -x
 
23
fi
 
24
 
 
25
########## FUNCTIONS DEFINITIONS #######################################
6
26
 
7
27
_debug() {
8
28
        if [ -n "${DEBUG}" ]
27
47
 
28
48
findjava() {
29
49
        # We try hard to find the proper 'java' command
30
 
        if [ -n "${FREEMIND_JAVA}" ] && [ -x "${FREEMIND_JAVA}" ]
31
 
        then
32
 
                JAVACMD="${FREEMIND_JAVA}"
33
 
                _debug "Using \$FREEMIND_JAVA to find java virtual machine."
34
 
        elif [ -n "${JAVACMD}" ] && [ -x "${JAVACMD}" ]
 
50
        if [ -n "${JAVACMD}" ] && [ -x "${JAVACMD}" ]
35
51
        then
36
52
                _debug "Using \$JAVACMD to find java virtual machine."
37
53
        elif [ -n "${JAVA_BINDIR}" ] && [ -x "${JAVA_BINDIR}/java" ]
42
58
        then
43
59
                JAVACMD="${JAVA_HOME}/bin/java"
44
60
                _debug "Using \$JAVA_HOME to find java virtual machine."
45
 
        elif [ -x /usr/lib/jvm/java-7-icedtea/jre/bin/java ]
46
 
        then
47
 
                JAVACMD='/usr/lib/jvm/java-7-icedtea/jre/bin/java'
48
 
                _debug "Using /usr/lib/jvm/java-7-icedtea/jre/bin/java to find java virtual machine."
49
61
        else
50
62
                JAVACMD=$(which java)
51
63
                if [ -n "${JAVACMD}" ] && [ -x "${JAVACMD}" ]
62
74
        if [ -n "${JAVACMD}" ] && [ -x "${JAVACMD}" ]
63
75
        then
64
76
                _debug "Using '$JAVACMD' as java virtual machine..."
 
77
                if [ -n "${DEBUG}" ]
 
78
                then
 
79
                        "$JAVACMD" -version >&2
 
80
                fi
 
81
                if (! "${JAVACMD}" -version 2>&1 | grep -qe 'Java(TM)' \
 
82
                                                        -e 'OpenJDK')
 
83
                then
 
84
                        _error "Your Java VM is not a complete implementation," \
 
85
                               "=======================================" \
 
86
                               "FREEMIND WILL MOST PROBABLY *NOT* WORK," \
 
87
                               "=======================================" \
 
88
                               "define JAVACMD, JAVA_BINDIR, JAVA_HOME or PATH in order" \
 
89
                               "to point to such a VM. See the manpage of freemind(1) for details."
 
90
                        JAVA_TYPE=other
 
91
                else
 
92
                        JAVA_TYPE=sun
 
93
                fi
65
94
                return 0
66
95
        else
67
96
                _error "Couldn't find a java virtual machine," \
69
98
                return 1
70
99
        fi
71
100
}
 
101
 
72
102
_source() {
73
103
        if [ -f "$1" ]
74
104
        then
77
107
        fi
78
108
}
79
109
 
80
 
_debug "Freemind parameters are '${@}'."
 
110
output_debug_info() {
 
111
        if [ -z "${DEBUG}" ]
 
112
        then
 
113
                return 0
 
114
        fi
 
115
        _debug "Freemind parameters are '${@}'."
 
116
        _debug "$(uname -a)"
 
117
        if [ -x "$(which lsb_release 2>/dev/null)" ]
 
118
        then
 
119
                _debug "$(lsb_release -a)"
 
120
        else
 
121
                _debug "System is not LSB conform, 'lsb_release' does not exist."
 
122
        fi
 
123
        if [ -x "$(which dpkg 2>/dev/null)" ]
 
124
        then
 
125
                _debug "The following DEB packages are installed:"
 
126
                COLUMNS=132 dpkg -l | grep -i -e freemind >&2
 
127
        elif [ -x "$(which rpm 2>/dev/null)" ]
 
128
        then
 
129
                _debug "The following RPM packages are installed:"
 
130
                rpm -qa | grep -i -e freemind >&2
 
131
        else
 
132
                _debug "Neither dpkg nor rpm is installed."
 
133
        fi
 
134
}
 
135
 
 
136
########## START MAIN PART #############################################
 
137
 
 
138
#--------- Put the environment together --------------------------------
81
139
 
82
140
_source /etc/freemind/freemindrc
83
141
_source ~/.freemind/freemindrc
88
146
        exit 1
89
147
fi
90
148
 
91
 
freepath=$(dirname "$0")
 
149
output_debug_info
 
150
 
 
151
if [ -L "$0" ] && [ -x $(which readlink) ]
 
152
then # if the script is a link and we have 'readlink' to follow it
 
153
        # -m should be faster and link does always resolve, else this script
 
154
        # wouldn't be called, would it?
 
155
        freefile=$(readlink -mn "$0")
 
156
        _debug "Link '$0' resolved to '${freefile}'."
 
157
else
 
158
        freefile="$0"
 
159
fi
 
160
freepath=$(dirname "${freefile}")
92
161
freepath="${freepath%/bin}" # nothing happens if freemind is not installed
93
162
                            # under something/bin
94
163
 
95
164
# we try different possibilities to find freemind.jar
96
 
for jar in "${freepath}" "${freepath}/share/freemind" "${freepath}/freemind"
 
165
for jar in "${FREEMIND_BASE_DIR}" \
 
166
        "${freepath}" "${freepath}/share/freemind" "${freepath}/freemind"
97
167
do
98
168
        if [ -f "${jar}/lib/freemind.jar" ]
99
169
        then
120
190
        cp /etc/freemind/patterns.xml ~/.freemind/patterns.xml
121
191
fi
122
192
 
 
193
#--------- Call (at last) FreeMind -------------------------------------
 
194
 
123
195
# The CLASSPATH also lets one specify additional jars, which is good, if
124
196
# you want to add a new Look&Feel jar (the motif one is so ugly...).
125
 
export CLASSPATH="${ADD_JARS}:${CLASSPATH}:${freedir}/lib/freemind.jar"
126
 
${JAVACMD} freemind.main.FreeMind  $@
127
 
# ${JAVACMD} -jar "${freedir}/lib/freemind.jar" $@ # original alternative
 
197
 
198
CLASSPATH="${ADD_JARS}:${CLASSPATH}:${freedir}/lib/freemind.jar:\
 
199
${freedir}/lib/jibx/jibx-run.jar:\
 
200
${freedir}/lib/jibx/xpp3.jar:\
 
201
${freedir}/lib/bindings.jar:\
 
202
${freedir}/lib/commons-lang-2.0.jar:\
 
203
${freedir}/lib/forms-1.0.5.jar:\
 
204
${freedir}"
 
205
if [ "${JAVA_TYPE}" = "sun" ]
 
206
then
 
207
        _debug "Calling: '${JAVACMD} -Dfreemind.base.dir=${freedir} -cp ${CLASSPATH} freemind.main.FreeMindStarter  $@'."
 
208
        ( echo "${DEBUG}" | grep -qe "exit" ) && exit 0 # do not start FreeMind
 
209
        "${JAVACMD}" -Xmx256M -Dfreemind.base.dir="${freedir}" -cp "${CLASSPATH}" freemind.main.FreeMindStarter "$@"
 
210
else # non-Sun environments don't work currently.
 
211
        _debug "Calling: '${JAVACMD} -Dgnu.java.awt.peer.gtk.Graphics=Graphics2D -Dfreemind.base.dir=${freedir} -cp ${CLASSPATH} freemind.main.FreeMindStarter  $@'."
 
212
        ( echo "${DEBUG}" | grep -qe "exit" ) && exit 0 # do not start FreeMind
 
213
        "${JAVACMD}" -Xmx256M -Dgnu.java.awt.peer.gtk.Graphics=Graphics2D -Dfreemind.base.dir="${freedir}" -cp "${CLASSPATH}" freemind.main.FreeMindStarter "$@"
 
214
fi