source: osm/applications/editors/josm/debian/make_install_files.sh@ 16589

Last change on this file since 16589 was 15969, checked in by joerg, 15 years ago

Do not automatically cleanup before building a debian package

  • Property svn:executable set to *
File size: 8.1 KB
Line 
1#!/bin/bash
2
3dst_path=debian/openstreetmap-josm
4
5#test -n "$1" || help=1
6quiet=" -q "
7verbose=1
8
9do_update_icons=true
10do_update_josm=true
11do_update_josm_ng=true
12do_update_plugins=true
13do_remove_jar=true
14do_cleanup=true
15
16for 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
53done
54
55if [ -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;
70fi
71
72
73# define colors
74ESC=`echo -e "\033"`
75RED="${ESC}[91m"
76GREEN="${ESC}[92m"
77YELLOW="${ESC}[93m"
78BLUE="${ESC}[94m"
79MAGENTA="${ESC}[95m"
80CYAN="${ESC}[96m"
81WHITE="${ESC}[97m"
82BG_RED="${ESC}[41m"
83BG_GREEN="${ESC}[42m"
84BG_YELLOW="${ESC}[43m"
85BG_BLUE="${ESC}[44m"
86BG_MAGENTA="${ESC}[45m"
87BG_CYAN="${ESC}[46m"
88BG_WHITE="${ESC}[47m"
89BRIGHT="${ESC}[01m"
90UNDERLINE="${ESC}[04m"
91BLINK="${ESC}[05m"
92REVERSE="${ESC}[07m"
93NORMAL="${ESC}[0m"
94
95echo "copying Files to '$dst_path'"
96package_name=openstreetmap-josm
97dst_path=${dst_path%/}
98
99jar_path="$dst_path/usr/local/share/josm"
100mkdir -p "$jar_path"
101
102bin_path="$dst_path/usr/bin"
103mkdir -p "$bin_path"
104
105#plugin_dir="$dst_path/usr/local/share/josm/plugins"
106plugin_dir="$dst_path/usr/lib/josm/plugins"
107mkdir -p "$plugin_dir"
108
109mkdir -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
117if $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
126fi
127mkdir -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)
139if $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 ..
150fi
151
152# ------------------------------------------------------------------
153# Try to Compile as many Josm Plugins as possible
154if $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
161fi
162# ------------------------------------------------------------------
163# Try to Compile as many Josm Plugins as possible
164if $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 ..
217fi
218
219# ------------------------------------------------------------------
220# Compile the Josm-ng Files
221if $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
233fi
234
235
236# ------------------------------------------------------------------
237echo "------------- Copy Jar Files"
238
239cp ./core/dist/josm-custom.jar $jar_path/josm.jar || exit -1
240rc=$?
241if [ "$rc" -ne "0" ] ; then
242 echo "${RED}------------- ERROR Compiling Josm-ng${NORMAL}"
243fi
244cp ../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
250plugin_jars=`find dist -name "*.jar"`
251plugins=''
252for 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,"
264done || exit -1
265
266# remove last empty plugin definition ,
267plugins=${plugins%,}
268
269echo "Activated Plugins:"
270echo "$plugins"
271
272# Copy words.cfg for spelling
273mkdir -p "$jar_path/speller"
274cp ../../utils/planet.osm/java/speller/words.cfg "$jar_path/speller/" || {
275 echo "!!!!!!!!!! words.cfg is missing"
276 exit -1
277}
278
279
280# ------------------------------------------------------------------
281cp "debian/bin/josm.sh" "$bin_path/josm" || {
282 echo "!!!!!!!!!! josm.sh is missing"
283 exit -1
284}
285
286cp "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
292sed "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
299cp nsis/bookmarks "$jar_path/bookmarks"
300
301exit 0
Note: See TracBrowser for help on using the repository browser.