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

Last change on this file since 15969 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
RevLine 
[13391]1#!/bin/bash
[4308]2
[12474]3dst_path=debian/openstreetmap-josm
[4308]4
[12474]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
[15969]14do_cleanup=true
[12474]15
16for arg in "$@" ; do
17 case $arg in
18 --dest-path=*) # Destination path to install the final *.jar Files
[15969]19 dst_path=${arg#*=}
20 ;;
[12474]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 ;;
[15969]41
42 --no-clean) # no cleanup before build
43 do_cleanup=false
44 ;;
45
[12474]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;
[4308]70fi
71
[12474]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
[4308]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"
[4958]110#( # map-icons to be symlinked
111# cd "$dst_path/usr/share/josm"
112# ln -s ../map-icons/classic.small images
113#)
[12474]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
[4308]127mkdir -p "$dst_path/usr/lib/josm"
[5126]128
[4308]129# ------------------------------------------------------------------
[12474]130# Remove Old Jar Files in dist/*.jar
[4308]131
[15969]132$do_cleanup && {
133 $do_remove_jar && rm -f dist/*.jar
134 $do_remove_jar && rm -f plugins/*/dist/*.jar
135 }
[4308]136
[12474]137# ------------------------------------------------------------------
138# Compile the Josm Main File(s)
139if $do_update_josm ; then
140 echo "------------- Compile Josm"
141 cd core
[15969]142 $do_cleanup && ant -q clean 2>build.err
[12474]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
[12610]155 echo "------------- Compile Josm Plugin webkit-image for wmsplugin"
156 cd plugins/wmsplugin
[15969]157 $do_cleanup && make clean
[12610]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
[12474]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"
[15969]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 }
[12474]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# ------------------------------------------------------------------
[7739]220# Compile the Josm-ng Files
[12474]221if $do_update_josm_ng ; then
222 echo "------------- Compile Josm-ng"
223 cd ../josm-ng
[15969]224 $do_cleanup && ant -q clean
[12474]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}"
[11707]230 #exit -1
[12474]231 fi
232 cd ../josm
233fi
[4308]234
[7739]235
[4308]236# ------------------------------------------------------------------
[7739]237echo "------------- Copy Jar Files"
[4308]238
239cp ./core/dist/josm-custom.jar $jar_path/josm.jar || exit -1
[12474]240rc=$?
241if [ "$rc" -ne "0" ] ; then
242 echo "${RED}------------- ERROR Compiling Josm-ng${NORMAL}"
243fi
[11707]244cp ../josm-ng/dist/josm-ng.jar $jar_path/josm-ng.jar || {
[12474]245 echo "${RED}!!!!!!!!!!!!!!!!! WARNING Josm-NG is not included into the package${NORMAL}"
[11707]246 #exit -1
247}
[4308]248
[12474]249# Find all existing plugin-jar files and generate a pluginlist from it
[6101]250plugin_jars=`find dist -name "*.jar"`
[12474]251plugins=''
[4308]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"
[12474]256 cp "$src_fn" "$dst_fn"
257 if [ "$?" -ne "0" ] ; then
258 echo "${RED}------------- ERROR Copying $src_fn ${NORMAL}"
259 exit -1
260 fi
[4308]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
[12474]272# Copy words.cfg for spelling
[5213]273mkdir -p "$jar_path/speller"
[15969]274cp ../../utils/planet.osm/java/speller/words.cfg "$jar_path/speller/" || {
275 echo "!!!!!!!!!! words.cfg is missing"
276 exit -1
277}
[4308]278
[15969]279
[4308]280# ------------------------------------------------------------------
[15969]281cp "debian/bin/josm.sh" "$bin_path/josm" || {
282 echo "!!!!!!!!!! josm.sh is missing"
283 exit -1
284}
285
[11707]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}
[4308]290
[12474]291# add plugins to default preferences
[15969]292sed "s/PLUGIN_LIST/$plugins/;" <debian/bin/preferences >"$jar_path/preferences" || {
293 echo "!!!!!!!! WARNING cannot create preferences"
294 exit -1
295}
296
[12474]297
298# Copy default Bookmarks
[5213]299cp nsis/bookmarks "$jar_path/bookmarks"
[15969]300
301exit 0
Note: See TracBrowser for help on using the repository browser.