~ubuntu-branches/ubuntu/trusty/jython/trusty-proposed

« back to all changes in this revision

Viewing changes to debian/whichjava

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2005-03-25 15:25:34 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050325152534-1266yogb9boq4nox
Tags: 2.1.0-20
* Use libservlet2.3-java instead of libservlet2.2-java (closes: #301042).
* If /usr/bin/java is broken or missing, use $JAVA_HOME/bin/java as a
  final fallback (closes: #297546).  Displays prominent warnings if this
  is necessary, since it means the system is misconfigured.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
set -e
3
 
 
4
 
# whichjava - determine properties of the given Java runtime
5
 
#
6
 
# Copyright (c) 2001 Ben Burton <benb@acm.org>
7
 
# Written for Debian GNU/Linux
8
 
# Released under GPL
9
 
#
10
 
# See man page for further details.
11
 
 
12
 
echoerr () {
13
 
        echo "$1" > /dev/stderr
14
 
}
15
 
 
16
 
usage () {
17
 
        echoerr "Usage: $0 <runtime> [ <action> ] [ <variable> ... ]"
18
 
        echoerr
19
 
        echoerr "Runtime: path to a Java runtime command (eg. /usr/bin/java)"
20
 
        echoerr "Actions: --eval, --print, --value (default)"
21
 
        echoerr "Variables: bootstrap, jvm"
22
 
        echoerr
23
 
        echoerr "See the man page for further details."
24
 
        echoerr
25
 
        exit 1
26
 
}
27
 
 
28
 
addaction () {
29
 
        if [ -z "$action" ]; then
30
 
                action="$1"
31
 
        else
32
 
                echoerr "More than one action has been specified!"
33
 
                echoerr
34
 
                usage
35
 
        fi
36
 
}
37
 
 
38
 
addvariable () {
39
 
        if [ -z "$variables" ]; then
40
 
                variables="$1"
41
 
        else
42
 
                variables="$variables $1"
43
 
        fi
44
 
}
45
 
 
46
 
classesnotfound () {
47
 
        echoerr "The core $1 classes could not be found."
48
 
        echoerr
49
 
        echoerr "Set the environment variable \$BOOTSTRAP_CLASSES to a"
50
 
        echoerr "colon-separated list of jars or directories containing"
51
 
        echoerr "the core $1 classes (such as $2)"
52
 
        echoerr "and try again."
53
 
        echoerr
54
 
        exit 1
55
 
}
56
 
 
57
 
# Pull the runtime command from the command line.
58
 
if [ -z "$1" ]; then
59
 
        usage
60
 
fi
61
 
 
62
 
JAVA="$1"
63
 
shift
64
 
 
65
 
if ! which "$JAVA" 2>&1 > /dev/null; then
66
 
        echoerr "The command \"$JAVA\" cannot be found."
67
 
        echoerr
68
 
        usage
69
 
fi
70
 
 
71
 
# Find which action and variables were specified on the command line.
72
 
action=
73
 
variables=
74
 
for param; do
75
 
        case "$param" in
76
 
                bootstrap )
77
 
                        addvariable BOOTSTRAP_CLASSES
78
 
                ;;
79
 
                jvm )
80
 
                        addvariable JVM
81
 
                ;;
82
 
                --eval )
83
 
                        addaction doeval
84
 
                ;;
85
 
                --print )
86
 
                        addaction doprint
87
 
                ;;
88
 
                --value )
89
 
                        addaction dovalue
90
 
                ;;
91
 
                * )
92
 
                        echoerr "Unknown command-line argument: $param"
93
 
                        echoerr
94
 
                        usage
95
 
        esac
96
 
done
97
 
 
98
 
# Use default if nothing was specified.
99
 
if [ -z "$variables" ]; then
100
 
        variables="JVM BOOTSTRAP_CLASSES"
101
 
fi
102
 
if [ -z "$action" ]; then
103
 
        action=dovalue
104
 
fi
105
 
 
106
 
# Determine whose JVM we are using.
107
 
if [ -z "$JVM" ]; then
108
 
        version=
109
 
        version=`"$JAVA" -version 2>&1` || true
110
 
        case "$version" in
111
 
                # Search for a string not included in $JAVA so we don't accidentally
112
 
                # catch output such as "kaffe: Command not found" and the like.
113
 
                *[Bb]lackdown* )
114
 
                        JVM=blackdown
115
 
                ;;
116
 
                *libgcj* )
117
 
                        JVM=gij
118
 
                ;;
119
 
                *[Tt]ransvirtual* )
120
 
                        JVM=kaffe
121
 
                ;;
122
 
                *Open\ Runtime\ Platform* )
123
 
                        JVM=orp
124
 
                ;;
125
 
                java\ version\ \"1.1.8\" )
126
 
                        JVM=sun
127
 
                ;;
128
 
                * )
129
 
                        # No idea.
130
 
                        JVM=unknown
131
 
                ;;
132
 
        esac
133
 
fi
134
 
 
135
 
# Determine the bootstrap classes.
136
 
if [ -z "$BOOTSTRAP_CLASSES" ]; then
137
 
        case "$JVM" in
138
 
                gij )
139
 
                        if [ -e /usr/share/java/libgcj.jar ]; then
140
 
                                BOOTSTRAP_CLASSES=/usr/share/java/libgcj.jar
141
 
                        else
142
 
                                classesnotfound "GNU Java" /usr/share/java/libgcj.jar
143
 
                        fi
144
 
                ;;
145
 
                kaffe )
146
 
                        if [ -e /usr/lib/kaffe/lib/rt.jar ]; then
147
 
                                kaffejars=`ls /usr/lib/kaffe/lib/*.jar`
148
 
                                BOOTSTRAP_CLASSES=`echo $kaffejars | tr ' ' ':'`
149
 
                        elif [ -e /usr/share/kaffe/Klasses.jar ]; then
150
 
                                kaffejars=`ls /usr/share/kaffe/*.jar`
151
 
                                BOOTSTRAP_CLASSES=`echo $kaffejars | tr ' ' ':'`
152
 
                        else
153
 
                                classesnotfound "Kaffe" /usr/share/kaffe/Klasses.jar
154
 
                        fi
155
 
                ;;
156
 
                orp )
157
 
                        if [ -e /usr/share/orp/classpath/java/lang/Object.class ]; then
158
 
                                BOOTSTRAP_CLASSES=/usr/share/orp/classpath
159
 
                        else
160
 
                                classesnotfound "ORP" /usr/share/orp/classpath
161
 
                        fi
162
 
                ;;
163
 
                blackdown )
164
 
                        if [ -e /usr/lib/j2se/1.3/jre/lib/rt.jar ]; then
165
 
                                jrejars=`ls /usr/lib/j2se/1.3/jre/lib/*.jar`
166
 
                                BOOTSTRAP_CLASSES=`echo $jrejars | tr ' ' ':'`
167
 
                        elif [ -e /usr/lib/j2re1.3/lib/rt.jar ]; then
168
 
                                jrejars=`ls /usr/lib/j2re1.3/lib/*.jar`
169
 
                                BOOTSTRAP_CLASSES=`echo $jrejars | tr ' ' ':'`
170
 
                        else
171
 
                                classesnotfound "Blackdown Java" /usr/lib/j2se/1.3/jre/lib/rt.jar
172
 
                        fi
173
 
                ;;
174
 
                sun )
175
 
                        if [ -e /usr/lib/jdk1.1/lib/classes.zip ]; then
176
 
                                BOOTSTRAP_CLASSES=/usr/lib/jdk1.1/lib/classes.zip
177
 
                        else
178
 
                                classesnotfound "Sun Java" /usr/lib/jdk1.1/lib/classes.zip
179
 
                        fi
180
 
                ;;
181
 
                * )
182
 
                        # No idea which JVM we're using.
183
 
                        BOOTSTRAP_CLASSES=
184
 
                ;;
185
 
        esac
186
 
fi
187
 
 
188
 
# Output according to the requested action.
189
 
 
190
 
for v in $variables; do
191
 
        case "$action" in
192
 
                doeval )
193
 
                        command="echo \"$v=\\\"\$$v\\\" ;\""
194
 
                ;;
195
 
                doprint )
196
 
                        command="echo $v: \$$v"
197
 
                ;;
198
 
                dovalue )
199
 
                        command="echo \$$v"
200
 
                ;;
201
 
                * )
202
 
                        command=echo
203
 
                ;;
204
 
        esac
205
 
        eval $command
206
 
done
207