summarylogtreecommitdiffstats
path: root/deepgit.sh
blob: d3bcb216cad9a62d263e20efbae21a31aca0c394 (plain)
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
#!/bin/bash --login
#
# Editing this script should not be required.
#
# To specify an alternative Java Runtime Environment, set the environment
# variable DEEPGIT_JAVA_HOME or add a
#
# jre=/path/to/jre
#
# line to deepgit.vmoptions (see below).
#
# To specify additional VM options, add them to deepgit.vmoptions
# or ~/.deepgit/deepgit.vmoptions files.

APP_NAME=DeepGit
APP_LOWER=deepgit

parseVmOptions() {
  if [ -f $1 ]; then
    while read LINE || [[ -n "$LINE" ]]; do
      LINE="${LINE#"${LINE%%[![:space:]]*}"}"
      if [ ${#LINE} -gt 0 ] && [ ! ${LINE:0:1} == '#' ]; then
        if [ ${LINE:0:4} == 'jre=' ]; then
          APP_JAVA_HOME="${LINE:4}"
        elif [ ${LINE:0:5} == 'path=' ]; then
          APP_PATH="$APP_PATH:${LINE:5}"
        else
          _VM_PROPERTIES="$_VM_PROPERTIES $LINE"
        fi
      fi
    done < $1
  fi
}

echoJreConfigurationAndExit() {
    mkdir --parents $APP_CONFIG_DIR
    touch $APP_CONFIG_DIR/$APP_LOWER.vmoptions
    echo "Add the line"
    echo "jre=/path/to/jre"
    echo "to $APP_CONFIG_DIR/$APP_LOWER.vmoptions and change the path"
    echo "to the one pointing to the desired JRE."
    exit 1
}

case "$BASH" in
    */bash) :
        ;;
    *)
        exec /bin/bash "$0" "$@"
        ;;
esac


# check system architecture
ARCHITECTURE=`uname -m`
if [ "$ARCHITECTURE" != "x86_64" ] ; then
    echo "$APP_NAME is not supported any more on 32-bit systems."
    exit 1
fi

# Resolve the location of the DeepGit installation.
# This includes resolving any symlinks.
PRG=$0
while [ -h "$PRG" ]; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
  if expr "$link" : '^/' 2> /dev/null >/dev/null; then
    PRG="$link"
  else
    PRG="`dirname "$PRG"`/$link"
  fi
done

APP_BIN=`dirname "$PRG"`

# Absolutize dir
oldpwd=`pwd`
cd "${APP_BIN}";
APP_BIN=`pwd`
cd "${oldpwd}";
unset oldpwd

APP_CONFIG_DIR=${XDG_CONFIG_HOME:$HOME/.config}/$APP_LOWER

APP_HOME=`dirname "$APP_BIN"`
APP_JAVA_HOME=$DEEPGIT_JAVA_HOME
parseVmOptions $APP_BIN/$APP_LOWER.vmoptions
parseVmOptions $HOME/.$APP_LOWER/$APP_LOWER.vmoptions
parseVmOptions $APP_CONFIG_DIR/$APP_LOWER.vmoptions

# Determine Java Runtime
if [ "$APP_JAVA_HOME" = "" ] ; then
    APP_JAVA_HOME=$JAVA_HOME
fi

_JAVA_EXEC="java"
if [ "$APP_JAVA_HOME" != "" ] ; then
    _TMP="$APP_JAVA_HOME/bin/java"
    if [ -f "$_TMP" ] ; then
        if [ -x "$_TMP" ] ; then
            _JAVA_EXEC="$_TMP"
        else
            echo "Warning: $_TMP is not executable"
        fi
    else
        echo "Warning: $_TMP does not exist"
    fi
elif [ -e "$APP_HOME/jre/bin/java" ] ; then
    _JAVA_EXEC="$APP_HOME/jre/bin/java"
fi

if ! which "$_JAVA_EXEC" >/dev/null 2>&1 ; then
    echo "Error: No Java Runtime Environment (JRE) 1.8 or higher found"
    echoJreConfigurationAndExit
fi

if type "lsb_release" > /dev/null 2> /dev/null ; then
    if [ "$XDG_CURRENT_DESKTOP" == "Unity" ] ; then
        # work-around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=419729
        # work-around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=502056
        export UBUNTU_MENUPROXY=0

        # Without the following line sliders are not visible in Ubuntu 12.04
        # (see <https://bugs.eclipse.org/bugs/show_bug.cgi?id=368929>)
        export LIBOVERLAY_SCROLLBAR=0
    fi
fi

if [ "$KDE_SESSION_UID" != "" ] && [ "$GTK2_RC_FILES" == "" ] ; then
    if grep -q "oxygen-gtk" "$HOME/.gtkrc-2.0-kde4"; then
        echo "Please change the GTK+ theme to something else than oxygen-gtk."
        echo "See also http://www.syntevo.com/blog/?p=4143"
        exit -1
    fi
fi

if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
    export GDK_BACKEND=x11
fi

# work-around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=542675
export GTK_IM_MODULE=ibus

_GC_OPTS="-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:InitiatingHeapOccupancyPercent=25 -Xmx1024m -Xss2m"
_MISC_OPTS="-Xverify:none -XX:MaxJavaStackTraceDepth=1000000 -Dsun.io.useCanonCaches=false -XX:ErrorFile=$APP_CONFIG_DIR/@VERSION_MAJOR@/hs_err_pid%p.log"

APP_PATH="$PATH$DEEPGIT_PATH"

(export PATH="$APP_PATH"; "$_JAVA_EXEC" $_GC_OPTS $_MISC_OPTS $_VM_PROPERTIES -jar "/usr/share/java/deepgit/lib/bootloader.jar" "$@")