1 | #!/bin/bash
|
---|
2 |
|
---|
3 | dst_path=debian/openstreetmap-josm
|
---|
4 |
|
---|
5 | #test -n "$1" || help=1
|
---|
6 | quiet=" -q "
|
---|
7 | verbose=1
|
---|
8 |
|
---|
9 | do_update_icons=true
|
---|
10 | do_update_josm=true
|
---|
11 | do_update_josm_ng=true
|
---|
12 | do_update_plugins=true
|
---|
13 | do_remove_jar=true
|
---|
14 | do_cleanup=true
|
---|
15 |
|
---|
16 | for arg in "$@" ; do
|
---|
17 | case $arg in
|
---|
18 | --dest-path=*) # Destination path to install the final *.jar Files
|
---|
19 | dst_path=${arg#*=}
|
---|
20 | ;;
|
---|
21 |
|
---|
22 | --no-update-icons) # Do not update icons
|
---|
23 | do_update_icons=false
|
---|
24 | ;;
|
---|
25 |
|
---|
26 | --no-update-josm) # Do not update Josm
|
---|
27 | do_update_josm=false
|
---|
28 | ;;
|
---|
29 |
|
---|
30 | --no-update-josm-ng) # Do not update Josm-NG
|
---|
31 | do_update_josm_ng=false
|
---|
32 | ;;
|
---|
33 |
|
---|
34 | --no-update-plugins) # Do not update the plugins
|
---|
35 | do_update_plugins=false
|
---|
36 | ;;
|
---|
37 |
|
---|
38 | --no-remove-jar) # Do not remove old jar Files
|
---|
39 | do_remove_jar=false
|
---|
40 | ;;
|
---|
41 |
|
---|
42 | --no-clean) # no cleanup before build
|
---|
43 | do_cleanup=false
|
---|
44 | ;;
|
---|
45 |
|
---|
46 | *)
|
---|
47 | echo ""
|
---|
48 | echo "!!!!!!!!! Unknown option $arg"
|
---|
49 | echo ""
|
---|
50 | help=1
|
---|
51 | ;;
|
---|
52 | esac
|
---|
53 | done
|
---|
54 |
|
---|
55 | if [ -n "$help" ] ; then
|
---|
56 | # extract options from case commands above
|
---|
57 | options=`grep -E -e esac -e '\s*--.*\).*#' $0 | sed '/esac/,$d;s/.*--/ [--/; s/=\*)/=val]/; s/)[\s ]/]/; s/#.*\s*//; s/[\n/]//g;'`
|
---|
58 | options=`for a in $options; do echo -n " $a" ; done`
|
---|
59 | echo "$0 $options"
|
---|
60 | echo "
|
---|
61 |
|
---|
62 | This script tries to compile and copy all josm Files
|
---|
63 | and all the plugins.
|
---|
64 | In case a plugin will not compile it is omitted.
|
---|
65 | "
|
---|
66 | # extract options + description from case commands above
|
---|
67 | grep -E -e esac -e '--.*\).*#' -e '^[\t\s ]+#' $0 | \
|
---|
68 | grep -v /bin/bash | sed '/esac/,$d;s/.*--/ --/;s/=\*)/=val/;s/)//;s/#//;'
|
---|
69 | exit;
|
---|
70 | fi
|
---|
71 |
|
---|
72 |
|
---|
73 | # define colors
|
---|
74 | ESC=`echo -e "\033"`
|
---|
75 | RED="${ESC}[91m"
|
---|
76 | GREEN="${ESC}[92m"
|
---|
77 | YELLOW="${ESC}[93m"
|
---|
78 | BLUE="${ESC}[94m"
|
---|
79 | MAGENTA="${ESC}[95m"
|
---|
80 | CYAN="${ESC}[96m"
|
---|
81 | WHITE="${ESC}[97m"
|
---|
82 | BG_RED="${ESC}[41m"
|
---|
83 | BG_GREEN="${ESC}[42m"
|
---|
84 | BG_YELLOW="${ESC}[43m"
|
---|
85 | BG_BLUE="${ESC}[44m"
|
---|
86 | BG_MAGENTA="${ESC}[45m"
|
---|
87 | BG_CYAN="${ESC}[46m"
|
---|
88 | BG_WHITE="${ESC}[47m"
|
---|
89 | BRIGHT="${ESC}[01m"
|
---|
90 | UNDERLINE="${ESC}[04m"
|
---|
91 | BLINK="${ESC}[05m"
|
---|
92 | REVERSE="${ESC}[07m"
|
---|
93 | NORMAL="${ESC}[0m"
|
---|
94 |
|
---|
95 | echo "copying Files to '$dst_path'"
|
---|
96 | package_name=openstreetmap-josm
|
---|
97 | dst_path=${dst_path%/}
|
---|
98 |
|
---|
99 | jar_path="$dst_path/usr/local/share/josm"
|
---|
100 | mkdir -p "$jar_path"
|
---|
101 |
|
---|
102 | bin_path="$dst_path/usr/bin"
|
---|
103 | mkdir -p "$bin_path"
|
---|
104 |
|
---|
105 | #plugin_dir="$dst_path/usr/local/share/josm/plugins"
|
---|
106 | plugin_dir="$dst_path/usr/lib/josm/plugins"
|
---|
107 | mkdir -p "$plugin_dir"
|
---|
108 |
|
---|
109 | mkdir -p "$dst_path/usr/share/josm"
|
---|
110 | #( # map-icons to be symlinked
|
---|
111 | # cd "$dst_path/usr/share/josm"
|
---|
112 | # ln -s ../map-icons/classic.small images
|
---|
113 | #)
|
---|
114 |
|
---|
115 | # --------------------------------------------
|
---|
116 | # Try to update Icons
|
---|
117 | if $do_update_icons ; then
|
---|
118 | echo "Now we try our best ... to get more icons ..."
|
---|
119 | find ../../share/map-icons/build/square.small -type f -name "*.png" | while read src_file ; do
|
---|
120 | file=${src_file#.*square.small/}
|
---|
121 | dst_dir="plugins/mappaint/icons/`dirname $file`"
|
---|
122 | mkdir -p $dst_dir
|
---|
123 | #echo "File $file"
|
---|
124 | cp -u "$src_file" "plugins/mappaint/icons/$file"
|
---|
125 | done
|
---|
126 | fi
|
---|
127 | mkdir -p "$dst_path/usr/lib/josm"
|
---|
128 |
|
---|
129 | # ------------------------------------------------------------------
|
---|
130 | # Remove Old Jar Files in dist/*.jar
|
---|
131 |
|
---|
132 | $do_cleanup && {
|
---|
133 | $do_remove_jar && rm -f dist/*.jar
|
---|
134 | $do_remove_jar && rm -f plugins/*/dist/*.jar
|
---|
135 | }
|
---|
136 |
|
---|
137 | # ------------------------------------------------------------------
|
---|
138 | # Compile the Josm Main File(s)
|
---|
139 | if $do_update_josm ; then
|
---|
140 | echo "------------- Compile Josm"
|
---|
141 | cd core
|
---|
142 | $do_cleanup && ant -q clean 2>build.err
|
---|
143 | ant -q dist >>build.log 2>>build.err
|
---|
144 | rc=$?
|
---|
145 | if [ "$rc" -ne "0" ] ; then
|
---|
146 | echo "${BG_RED}!!!!!!!!!! ERROR compiling josm core${NORMAL}"
|
---|
147 | exit -1
|
---|
148 | fi
|
---|
149 | cd ..
|
---|
150 | fi
|
---|
151 |
|
---|
152 | # ------------------------------------------------------------------
|
---|
153 | # Try to Compile as many Josm Plugins as possible
|
---|
154 | if $do_update_plugins ; then
|
---|
155 | echo "------------- Compile Josm Plugin webkit-image for wmsplugin"
|
---|
156 | cd plugins/wmsplugin
|
---|
157 | $do_cleanup && make clean
|
---|
158 | make
|
---|
159 | cd ../..
|
---|
160 | cp plugins/wmsplugin/webkit-image $bin_path/webkit-image
|
---|
161 | fi
|
---|
162 | # ------------------------------------------------------------------
|
---|
163 | # Try to Compile as many Josm Plugins as possible
|
---|
164 | if $do_update_plugins ; then
|
---|
165 | echo "------------- Compile Josm Plugins"
|
---|
166 | compiling_error=''
|
---|
167 | compiling_ok=''
|
---|
168 | cd plugins
|
---|
169 | plugins=`ls */build.xml | sed s,/build.xml,,`
|
---|
170 | echo "Plugins(`echo "$plugins"| wc -l`): " $plugins
|
---|
171 | for dir in $plugins; do
|
---|
172 | cd $dir
|
---|
173 | echo -n -e "----- $dir\r"
|
---|
174 | $do_cleanup && {
|
---|
175 | $do_remove_jar && rm -f dist/*.jar
|
---|
176 | $do_remove_jar && rm -f ../../dist/$dir.jar
|
---|
177 | rm -f *.log
|
---|
178 | echo "ant clean" >build.log
|
---|
179 | echo "ant clean" >build.err
|
---|
180 | ant -q clean >>build.log 2>>build.err
|
---|
181 | }
|
---|
182 | echo "ant dist" >>build.log
|
---|
183 | echo "ant dist" >>build.err
|
---|
184 | ant -q dist >>build.log 2>>build.err
|
---|
185 | rc=$?
|
---|
186 | number_of_jar=`(find . -name "*.jar" ;find ../../dist -name "$dir.jar")| grep -v '/lib'| wc -l`
|
---|
187 | if [ "$rc" -eq "0" ] ; then
|
---|
188 | echo "${GREEN}------------------------- compiling $dir successfull${NORMAL} ( $number_of_jar jar Files)"
|
---|
189 | grep -i -e error -e warn *.log *.err
|
---|
190 | compiling_ok="$compiling_ok $dir"
|
---|
191 | else
|
---|
192 | echo "${BG_RED}!!!!!!!!!! ERROR compiling $dir${NORMAL} ( $number_of_jar jar Files)"
|
---|
193 | #echo "Details see:"
|
---|
194 | #echo " `pwd`/build.log"
|
---|
195 | #echo " `pwd`/build.err"
|
---|
196 | compiling_error="$compiling_error $dir"
|
---|
197 | fi
|
---|
198 | find . -name "*.jar" | grep -v -e '/lib'
|
---|
199 |
|
---|
200 | cd ..
|
---|
201 | done
|
---|
202 | if [ -n "$compiling_error" ] ; then
|
---|
203 | echo "${BG_RED}!!!!!!!!!! ERROR compiling Plugins${NORMAL}"
|
---|
204 | echo "Details see:"
|
---|
205 |
|
---|
206 | err_log_path=''
|
---|
207 | for dir in $compiling_error; do
|
---|
208 | echo " `pwd`/$dir/build.log"
|
---|
209 | err_log_path="$err_log_path $dir/build.log $dir/build.err"
|
---|
210 | done
|
---|
211 | zip -q errors.zip $err_log_path
|
---|
212 | echo "${RED}Combined ERROR Logfiles are at: `pwd`/errors.zip${NORMAL}"
|
---|
213 | echo "${RED}Compiling ERRORs(`echo "$compiling_error"| wc -w`): $compiling_error${NORMAL}"
|
---|
214 | fi
|
---|
215 | echo "Compiling OK(`echo "$compiling_ok"| wc -w`): $compiling_ok"
|
---|
216 | cd ..
|
---|
217 | fi
|
---|
218 |
|
---|
219 | # ------------------------------------------------------------------
|
---|
220 | # Compile the Josm-ng Files
|
---|
221 | if $do_update_josm_ng ; then
|
---|
222 | echo "------------- Compile Josm-ng"
|
---|
223 | cd ../josm-ng
|
---|
224 | $do_cleanup && ant -q clean
|
---|
225 | ant -q josm-ng-impl.jar >>build.log 2>>build.err
|
---|
226 | rc=$?
|
---|
227 | if [ "$rc" -ne "0" ] ; then
|
---|
228 | echo "------------- ERROR Compiling Josm-ng"
|
---|
229 | echo "${RED}!!!!!!!!!!!!!!!!! WARNING Josm-NG is not included into the package${NORMAL}"
|
---|
230 | #exit -1
|
---|
231 | fi
|
---|
232 | cd ../josm
|
---|
233 | fi
|
---|
234 |
|
---|
235 |
|
---|
236 | # ------------------------------------------------------------------
|
---|
237 | echo "------------- Copy Jar Files"
|
---|
238 |
|
---|
239 | cp ./core/dist/josm-custom.jar $jar_path/josm.jar || exit -1
|
---|
240 | rc=$?
|
---|
241 | if [ "$rc" -ne "0" ] ; then
|
---|
242 | echo "${RED}------------- ERROR Compiling Josm-ng${NORMAL}"
|
---|
243 | fi
|
---|
244 | cp ../josm-ng/dist/josm-ng.jar $jar_path/josm-ng.jar || {
|
---|
245 | echo "${RED}!!!!!!!!!!!!!!!!! WARNING Josm-NG is not included into the package${NORMAL}"
|
---|
246 | #exit -1
|
---|
247 | }
|
---|
248 |
|
---|
249 | # Find all existing plugin-jar files and generate a pluginlist from it
|
---|
250 | plugin_jars=`find dist -name "*.jar"`
|
---|
251 | plugins=''
|
---|
252 | for src_fn in $plugin_jars ; do
|
---|
253 | fn="`basename ${src_fn}`"
|
---|
254 | dst_fn="$plugin_dir/$fn"
|
---|
255 | echo "cp $src_fn $dst_fn"
|
---|
256 | cp "$src_fn" "$dst_fn"
|
---|
257 | if [ "$?" -ne "0" ] ; then
|
---|
258 | echo "${RED}------------- ERROR Copying $src_fn ${NORMAL}"
|
---|
259 | exit -1
|
---|
260 | fi
|
---|
261 | plugin_name=${fn%.jar}
|
---|
262 | echo $plugin_name | grep -q -e plastic_laf -e lang && continue
|
---|
263 | plugins="$plugins$plugin_name,"
|
---|
264 | done || exit -1
|
---|
265 |
|
---|
266 | # remove last empty plugin definition ,
|
---|
267 | plugins=${plugins%,}
|
---|
268 |
|
---|
269 | echo "Activated Plugins:"
|
---|
270 | echo "$plugins"
|
---|
271 |
|
---|
272 | # Copy words.cfg for spelling
|
---|
273 | mkdir -p "$jar_path/speller"
|
---|
274 | cp ../../utils/planet.osm/java/speller/words.cfg "$jar_path/speller/" || {
|
---|
275 | echo "!!!!!!!!!! words.cfg is missing"
|
---|
276 | exit -1
|
---|
277 | }
|
---|
278 |
|
---|
279 |
|
---|
280 | # ------------------------------------------------------------------
|
---|
281 | cp "debian/bin/josm.sh" "$bin_path/josm" || {
|
---|
282 | echo "!!!!!!!!!! josm.sh is missing"
|
---|
283 | exit -1
|
---|
284 | }
|
---|
285 |
|
---|
286 | cp "debian/bin/josm-ng.sh" "$bin_path/josm-ng" || {
|
---|
287 | echo "!!!!!!!!!!!!!!!!! WARNING Josm-NG is not included into the package"
|
---|
288 | #exit -1
|
---|
289 | }
|
---|
290 |
|
---|
291 | # add plugins to default preferences
|
---|
292 | sed "s/PLUGIN_LIST/$plugins/;" <debian/bin/preferences >"$jar_path/preferences" || {
|
---|
293 | echo "!!!!!!!! WARNING cannot create preferences"
|
---|
294 | exit -1
|
---|
295 | }
|
---|
296 |
|
---|
297 |
|
---|
298 | # Copy default Bookmarks
|
---|
299 | cp nsis/bookmarks "$jar_path/bookmarks"
|
---|
300 |
|
---|
301 | exit 0
|
---|