-
Notifications
You must be signed in to change notification settings - Fork 2
/
josm_svn.sh
executable file
·196 lines (163 loc) · 5.62 KB
/
josm_svn.sh
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
#
#
# Copyright (C) [2009] [Max Andre - Benutzer Telegnom bei Openstreetmap.org]
#
# This program is free software; you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without #even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# To get a copy of the GNU General Public License see <http://www.gnu.org/licenses/>.
#
#
###
# Die Vorgabewerte bitte den eigenen Bedürfnissen anpassen:
###
# Verzeichnis in das das SVN ausgecheckt wird
source_dir=~/source/josm
# Maximaler Heap mit dem die Java-VM gestartet werden soll (in MB)
maxmem="1024"
# Minimaler Heap mit dem die Java-VM gestartet werden soll (in MB)
minmem="128"
# 2D-Beschleunigung aktivieren ja=true; nein=false
acc2d="false"
###
# Beginn des Scripts, aber hier nichts mehr verändern!
###
# Prüfen ob die nötigen Tools installiert sind und im globalen Suchpfad vorhandenen sind.
reqMissing=0;
echo "Überprüfe ob die notwendigen Tools installiert sind...";
which ant > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Apache Ant wurde nicht gefunden.";
reqMissing=1;
fi
which svn > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Subversion (SVN) wurde nicht gefunden.";
reqMissing=1;
fi
if [ $reqMissing -ne 0 ]; then
echo "Installiere die fehlenden Abhänigkeiten und führe das Script erneut aus.";
exit 1;
else
echo "okay";
fi
# Parsen der übergebenen Parameter
set -- `getopt "hlorm:" "$@"`
while [ "$1" != "" ]; do
case "$1" in
-h) echo "Hilfe: `basename $0` [-h] [-l] [-o] [-r] [-m] [Dateien]";
#-n) echo "Repository wird nicht ausgecheckt. Lokale Version wird gestartet";
echo "-h : zeigt diese Hilfe an";
echo "-l : zeigt die lokale Versionsnummer an";
echo "-o : zeigt die Versionsnummer im Repository an";
echo "-m : Speicher der JOSM zugewiesen wird (in MB). Muss größer als $minmem sein";
echo "-r : Erneute Kompilierung der lokal vorhandenen Quellen.";
exit;;
-l) shift; showloc=1;;
-o) shift; showonline=1;;
-m) shift; maxmem="$1";;
-r) shift; build=1;;
--) break;;
esac
shift
done
if [ "$showloc" == "1" ]; then
if svn info $source_dir > /dev/null; then
echo "Lokale Version:"
svn info $source_dir | grep Revision
else
echo "Keine lokalen Quellen gefunden."
fi
exit 1
fi
if [ "$showonline" == "1" ]; then
if ping josm.openstreetmap.de -c 2 > /dev/null; then
echo "Aktuelle Version im Repository:"
svn info http://josm.openstreetmap.de/svn/trunk | grep Revision
else
echo "Repository ist nicht erreichbar / offline"
fi
exit 1
fi
if [ "$build" == "1" ]; then
if svn info $source_dir > /dev/null; then
echo "Quellen lokal vorhanden, kompiliere Quellen erneut."
else
echo "Quellen lokal nicht vorhanden. Script wird abgebrochen."
exit 1
fi
else
# prüfung, ob svn-repository erreichbar ist
if ping josm.openstreetmap.de -c 2 > /dev/null; then
version_svn=`svn info http://josm.openstreetmap.de/svn/trunk | grep Revision | awk '{print $2}'`
echo "Repository ist erreichbar."
else
# Wenn das Repository nicht erreichbar ist, wird die svn-version auf -1 gesetzt
version_svn=-1
fi
echo "Überprüfe ob Verzeichnis $source_dir existiert..."
# Prüfung ob das angegebene Verzeichnis existiert
if [ -d $source_dir ]; then
echo Verzeichnis $source_dir existiert
# Prüfung ob REVISION-Datei aus dem SVN lokal vorhanden ist
version_lokal=`svn info $source_dir | grep Revision | awk '{print $2}'`
if [ -z $version_lokal ]; then
echo "Lokale Kopie existiert nicht"
# Falls keine lokale Version ermittelt werden konnte, Version auf 0 setzen
version_lokal=0
fi
else
# falls das verzeichnis nicht gefunden wurde, wird es angelegt
echo "Verzeichnis $source_dir wird angelegt"
mkdir -p $source_dir
# lokale Version wird auf 0 gesetzt
version_lokal=0
fi
echo "lokale Version: $version_lokal"
echo "aktuelle Version: $version_svn"
# wenn keine lokale Version vorhanden ist und das SVN-Repository nicht erreichbar ist, wird das Script abgebrochen
if [ $version_svn -eq -1 ]; then
echo "Repository ist nicht erreichbar."
if [ $version_lokal -eq 0 ]; then
# abbruch des scripts
echo "Lokale Version existiert nicht, Script wird abgebrochen."
exit 1
fi
# wenn die lokale Version kleiner ist als die svn version wird das Repository ausgecheckt und kompiliert.
elif [ $version_lokal -lt $version_svn ]; then
echo "Die lokale Version ist veraltet. Aktuelle Version wird herunter geladen."
# auschecken des Repository
svn co http://josm.openstreetmap.de/svn/trunk $source_dir
echo "Kompiliere aktualisierte Version."
# kompilieren der aktuellen JOSM-Version
build=1;
else
if [ -f $source_dir/dist/josm-custom.jar ]; then
echo "Lokale Version ist aktuell."
else
echo "Jarfile kann nicht gefunden werden. Neu kompilieren mit -r"
exit
fi
fi
fi
if [ "$build" == "1" ]; then
if ant clean dist -f $source_dir/build.xml; then
echo "Kompilieren erfolgreich beendet!"
else
echo "Fehler beim Kompilieren. Abbruch"
exit 1
fi
fi
version_aktuell=`svn info $source_dir | grep Revision | awk '{print $2}'`
echo "Starte JOSM Version $version_aktuell"
# JOSM mit den oben gewählten Parametern startem
java -Xms"$minmem"M -Xmx"$maxmem"M -Dsun.java2d.opengl=$acc2d -jar $source_dir/dist/josm-custom.jar $@ &
# ProzessID mit der JOSM gestartet wurde augeben
echo "JOSM wurde mit der ProzessID $! gestartet"
exit