File: eclipse.sh

package info (click to toggle)
eclipse 3.2.1-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 54,216 kB
  • ctags: 71
  • sloc: sh: 8,046; makefile: 496
file content (178 lines) | stat: -rw-r--r-- 5,386 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
#!/bin/bash

# Having any sort of classpath causes massive breakage, with Kaffe at least.
unset CLASSPATH; export CLASSPATH

# Allow the user to specify their own Java home, we check for it later.
#unset JAVA_HOME; export JAVA_HOME

CMDLINEARGS=""
VMARGS=""
INSTALL="/usr/lib/eclipse"
STARTUP="/usr/lib/eclipse/startup.jar"

if [ -x /usr/bin/zenity ]; then
    DIALOG=/usr/bin/zenity
    DIALOGW="$DIALOG --warning"
elif [ -x /usr/bin/kdialog ]; then
    DIALOG=/usr/bin/kdialog
    DIALOGW="$DIALOG --warningyesno"
elif [ -x /usr/bin/xdialog ]; then
    DIALOG=/usr/bin/xdialog
    DIALOGW="$DIALOG --warning"
else
    DIALOG=echo
    DIALOGW="$DIALOG"
fi


# Make sure this directory exists.
if [ ! -d ~/.eclipse ]; then
    mkdir ~/.eclipse > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        $DIALOG \
            --error \
            --title="Could not launch Eclipse Platform" \
            --text="Could not create settings directory at ~/.eclipse."
    fi
fi

# Just in case Eclipse tries to put something in the home directory.
cd ~

# Load default settings from the user's configuration file.
if [ -f ~/.eclipse/eclipserc ]; then
    . ~/.eclipse/eclipserc
fi

# Process the command line options. These override the eclipserc file, so we do
# them after parsing that file.
while [ "$1" ]; do
    if [ "$1" = "-h" -o "$1" = "--help" ]; then
        echo "Eclipse Starter Script"
	echo "Usage:"
	echo "eclipse [options [value]]"
	echo "See eclipse(1) for more information."
	echo ""
	echo "Also see ~/.eclipse/eclipserc, which provides some default values"
        exit 0
    elif [ "$1" = "-vm" ]; then
        shift
        unset JAVA_HOME
        JAVACMD="$1"
        shift
    elif [ "$1" = "-install" ]; then
        shift
        INSTALL="$1"
        shift
    elif [ "$1" = "-startup" ]; then
        shift
        STARTUP="$1"
        shift
    elif [ "$1" = "-vmargs" ]; then
        shift
	while [ "$1" ]; do
		VMARGS="${VMARGS} $1"
	        shift
        done
    else
        CMDLINEARGS="${CMDLINEARGS} $1"
        shift
    fi
done

# If the user has specified a custom JAVA, we check it for validity.
# JAVA defines the virtual machine that Eclipse will use to launch itself.
if [ -n "${JAVA_HOME}" ]; then
    echo "using specified vm: ${JAVA_HOME}"
    if [ ! -x "${JAVA_HOME}/bin/java" ]; then
        $DIALOG \
            --error \
            --title="Could not launch Eclipse Platform" \
            --text="The custom VM you have chosen is not a valid executable."
        exit 1
    fi
fi

# If the user has not set JAVA_HOME, cycle through our list of compatible VM's
# and pick the first one that exists.
if [ -z "${JAVA_HOME}" -a ! -n "${JAVACMD}" ]; then
    echo "searching for compatible vm..."
    javahomelist=`cat /etc/eclipse/java_home  | grep -v '^#' | grep -v '^$' | while read line ; do echo -n $line ; echo -n ":" ; done`
    OFS="$IFS"
    IFS=":"
    for JAVA_HOME in $javahomelist ; do
        echo -n "  testing ${JAVA_HOME}..."
        if [ -x "${JAVA_HOME}/bin/java" ]; then
            export JAVA_HOME
            echo "found"
            break
        else
            echo "not found"
        fi
    done
    IFS="$OFS"
fi

# If we don't have a JAVA_HOME yet, we're doomed.
if [ -z "${JAVA_HOME}" -a ! -n "${JAVACMD}" ]; then
    $DIALOG \
        --error \
        --title="Could not launch Eclipse Platform" \
        --text="A suitable Java Virtual Machine for running the Eclipse Platform could not be located."
    exit 1
fi

# Set JAVACMD from JAVA_HOME
if [ -n "${JAVA_HOME}" -a -z "${JAVACMD}" ]; then
    JAVACMD="$JAVA_HOME/bin/java"
fi

# Set path for the Mozilla SWT binding
MOZILLA_FIVE_HOME=${MOZILLA_FIVE_HOME%*/}
if false && [ -n "$MOZILLA_FIVE_HOME" -a -e $MOZILLA_FIVE_HOME/libgtkembedmoz.so ]; then
    :
elif [ -e @MOZILLA_FIVE_HOME_DEFAULT@/libgtkembedmoz.so ]; then
    export MOZILLA_FIVE_HOME=@MOZILLA_FIVE_HOME_DEFAULT@
elif [ -e /usr/lib/firefox/libgtkembedmoz.so ]; then
    export MOZILLA_FIVE_HOME=/usr/lib/firefox
elif [ -e /usr/lib/xulrunner/libgtkembedmoz.so ]; then
    export MOZILLA_FIVE_HOME=/usr/lib/xulrunner
elif [ -e /usr/lib/mozilla-firefox/libgtkembedmoz.so ]; then
    export MOZILLA_FIVE_HOME=/usr/lib/mozilla-firefox
elif [ -e /usr/lib/mozilla/libgtkembedmoz.so ]; then
    export MOZILLA_FIVE_HOME=/usr/lib/mozilla
else
    $DIALOGW \
        --title="Integrated browser support not working" \
        --text="This Eclipse build doesn't have support for the integrated browser."
    [ $? -eq 0 ] || exit 1
fi

EXT=/usr/local/lib/eclipse/.eclipseextension
if [ ! -f $EXT ]; then
    if ! touch $EXT 2>/dev/null; then
	cat <<-EOF
	Could not create $EXT. Please run as root:
	    touch $EXT
	    chmod 2775 $EXT
	    chown root:staff $EXT
	EOF
    fi
    chmod 2775 $EXT 2> /dev/null || true
    chown root:staff $EXT 2> /dev/null || true
fi

# libraries from the mozilla choosen take precedence
LD_LIBRARY_PATH=$MOZILLA_FIVE_HOME${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

# Do the actual launch of Eclipse with the selected VM.
exec /usr/lib/eclipse/eclipse \
    -vm "${JAVACMD}" \
    -install "${INSTALL}" \
    -startup "${STARTUP}" \
    ${CMDLINEARGS} \
    -vmargs -Djava.library.path=/usr/lib/jni \
            -Dgnu.gcj.precompiled.db.path=/var/lib/gcj-4.1/classmap.db \
            -Dgnu.gcj.runtime.VMClassLoader.library_control=never \
            -Dosgi.locking=none ${VMARGS}