[13391] | 1 | #!/bin/bash
|
---|
[4308] | 2 |
|
---|
[12474] | 3 | dst_path=debian/openstreetmap-josm
|
---|
[4308] | 4 |
|
---|
[12474] | 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
|
---|
[15969] | 14 | do_cleanup=true
|
---|
[12474] | 15 |
|
---|
| 16 | for 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
|
---|
| 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;
|
---|
[4308] | 70 | fi
|
---|
| 71 |
|
---|
[12474] | 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 |
|
---|
[4308] | 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"
|
---|
[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
|
---|
| 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
|
---|
[4308] | 127 | mkdir -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)
|
---|
| 139 | if $do_update_josm ; then
|
---|
| 140 | echo "------------- Compile Josm"
|
---|
| 141 | cd core
|
---|
[16661] | 142 | $do_cleanup && ant clean 2>build.err
|
---|
| 143 | ant dist >>build.log 2>>build.err
|
---|
[12474] | 144 | rc=$?
|
---|
| 145 | if [ "$rc" -ne "0" ] ; then
|
---|
[16661] | 146 | cat build.log build.err
|
---|
| 147 | echo "${BG_RED}!!!!!!!!!! ERROR $rc compiling josm core${NORMAL}"
|
---|
| 148 | echo "${BG_RED}!!!!!!!!!! See build.log build.err${NORMAL}"
|
---|
[12474] | 149 | exit -1
|
---|
| 150 | fi
|
---|
| 151 | cd ..
|
---|
| 152 | fi
|
---|
| 153 |
|
---|
| 154 | # ------------------------------------------------------------------
|
---|
| 155 | # Try to Compile as many Josm Plugins as possible
|
---|
| 156 | if $do_update_plugins ; then
|
---|
[12610] | 157 | echo "------------- Compile Josm Plugin webkit-image for wmsplugin"
|
---|
| 158 | cd plugins/wmsplugin
|
---|
[15969] | 159 | $do_cleanup && make clean
|
---|
[12610] | 160 | make
|
---|
| 161 | cd ../..
|
---|
| 162 | cp plugins/wmsplugin/webkit-image $bin_path/webkit-image
|
---|
| 163 | fi
|
---|
| 164 | # ------------------------------------------------------------------
|
---|
| 165 | # Try to Compile as many Josm Plugins as possible
|
---|
| 166 | if $do_update_plugins ; then
|
---|
[12474] | 167 | echo "------------- Compile Josm Plugins"
|
---|
| 168 | compiling_error=''
|
---|
| 169 | compiling_ok=''
|
---|
| 170 | cd plugins
|
---|
| 171 | plugins=`ls */build.xml | sed s,/build.xml,,`
|
---|
| 172 | echo "Plugins(`echo "$plugins"| wc -l`): " $plugins
|
---|
| 173 | for dir in $plugins; do
|
---|
| 174 | cd $dir
|
---|
| 175 | echo -n -e "----- $dir\r"
|
---|
[15969] | 176 | $do_cleanup && {
|
---|
| 177 | $do_remove_jar && rm -f dist/*.jar
|
---|
| 178 | $do_remove_jar && rm -f ../../dist/$dir.jar
|
---|
| 179 | rm -f *.log
|
---|
| 180 | echo "ant clean" >build.log
|
---|
| 181 | echo "ant clean" >build.err
|
---|
| 182 | ant -q clean >>build.log 2>>build.err
|
---|
| 183 | }
|
---|
[12474] | 184 | echo "ant dist" >>build.log
|
---|
| 185 | echo "ant dist" >>build.err
|
---|
| 186 | ant -q dist >>build.log 2>>build.err
|
---|
| 187 | rc=$?
|
---|
| 188 | number_of_jar=`(find . -name "*.jar" ;find ../../dist -name "$dir.jar")| grep -v '/lib'| wc -l`
|
---|
| 189 | if [ "$rc" -eq "0" ] ; then
|
---|
| 190 | echo "${GREEN}------------------------- compiling $dir successfull${NORMAL} ( $number_of_jar jar Files)"
|
---|
| 191 | grep -i -e error -e warn *.log *.err
|
---|
| 192 | compiling_ok="$compiling_ok $dir"
|
---|
| 193 | else
|
---|
| 194 | echo "${BG_RED}!!!!!!!!!! ERROR compiling $dir${NORMAL} ( $number_of_jar jar Files)"
|
---|
| 195 | #echo "Details see:"
|
---|
| 196 | #echo " `pwd`/build.log"
|
---|
| 197 | #echo " `pwd`/build.err"
|
---|
| 198 | compiling_error="$compiling_error $dir"
|
---|
| 199 | fi
|
---|
| 200 | find . -name "*.jar" | grep -v -e '/lib'
|
---|
| 201 |
|
---|
| 202 | cd ..
|
---|
| 203 | done
|
---|
| 204 | if [ -n "$compiling_error" ] ; then
|
---|
| 205 | echo "${BG_RED}!!!!!!!!!! ERROR compiling Plugins${NORMAL}"
|
---|
| 206 | echo "Details see:"
|
---|
| 207 |
|
---|
| 208 | err_log_path=''
|
---|
| 209 | for dir in $compiling_error; do
|
---|
| 210 | echo " `pwd`/$dir/build.log"
|
---|
| 211 | err_log_path="$err_log_path $dir/build.log $dir/build.err"
|
---|
| 212 | done
|
---|
| 213 | zip -q errors.zip $err_log_path
|
---|
| 214 | echo "${RED}Combined ERROR Logfiles are at: `pwd`/errors.zip${NORMAL}"
|
---|
| 215 | echo "${RED}Compiling ERRORs(`echo "$compiling_error"| wc -w`): $compiling_error${NORMAL}"
|
---|
| 216 | fi
|
---|
| 217 | echo "Compiling OK(`echo "$compiling_ok"| wc -w`): $compiling_ok"
|
---|
| 218 | cd ..
|
---|
| 219 | fi
|
---|
| 220 |
|
---|
| 221 | # ------------------------------------------------------------------
|
---|
[7739] | 222 | # Compile the Josm-ng Files
|
---|
[12474] | 223 | if $do_update_josm_ng ; then
|
---|
| 224 | echo "------------- Compile Josm-ng"
|
---|
| 225 | cd ../josm-ng
|
---|
[15969] | 226 | $do_cleanup && ant -q clean
|
---|
[12474] | 227 | ant -q josm-ng-impl.jar >>build.log 2>>build.err
|
---|
| 228 | rc=$?
|
---|
| 229 | if [ "$rc" -ne "0" ] ; then
|
---|
| 230 | echo "------------- ERROR Compiling Josm-ng"
|
---|
| 231 | echo "${RED}!!!!!!!!!!!!!!!!! WARNING Josm-NG is not included into the package${NORMAL}"
|
---|
[11707] | 232 | #exit -1
|
---|
[12474] | 233 | fi
|
---|
| 234 | cd ../josm
|
---|
| 235 | fi
|
---|
[4308] | 236 |
|
---|
[7739] | 237 |
|
---|
[4308] | 238 | # ------------------------------------------------------------------
|
---|
[7739] | 239 | echo "------------- Copy Jar Files"
|
---|
[4308] | 240 |
|
---|
| 241 | cp ./core/dist/josm-custom.jar $jar_path/josm.jar || exit -1
|
---|
[12474] | 242 | rc=$?
|
---|
| 243 | if [ "$rc" -ne "0" ] ; then
|
---|
| 244 | echo "${RED}------------- ERROR Compiling Josm-ng${NORMAL}"
|
---|
| 245 | fi
|
---|
[11707] | 246 | cp ../josm-ng/dist/josm-ng.jar $jar_path/josm-ng.jar || {
|
---|
[12474] | 247 | echo "${RED}!!!!!!!!!!!!!!!!! WARNING Josm-NG is not included into the package${NORMAL}"
|
---|
[11707] | 248 | #exit -1
|
---|
| 249 | }
|
---|
[4308] | 250 |
|
---|
[12474] | 251 | # Find all existing plugin-jar files and generate a pluginlist from it
|
---|
[6101] | 252 | plugin_jars=`find dist -name "*.jar"`
|
---|
[12474] | 253 | plugins=''
|
---|
[4308] | 254 | for src_fn in $plugin_jars ; do
|
---|
| 255 | fn="`basename ${src_fn}`"
|
---|
| 256 | dst_fn="$plugin_dir/$fn"
|
---|
| 257 | echo "cp $src_fn $dst_fn"
|
---|
[12474] | 258 | cp "$src_fn" "$dst_fn"
|
---|
| 259 | if [ "$?" -ne "0" ] ; then
|
---|
| 260 | echo "${RED}------------- ERROR Copying $src_fn ${NORMAL}"
|
---|
| 261 | exit -1
|
---|
| 262 | fi
|
---|
[4308] | 263 | plugin_name=${fn%.jar}
|
---|
| 264 | echo $plugin_name | grep -q -e plastic_laf -e lang && continue
|
---|
| 265 | plugins="$plugins$plugin_name,"
|
---|
| 266 | done || exit -1
|
---|
| 267 |
|
---|
| 268 | # remove last empty plugin definition ,
|
---|
| 269 | plugins=${plugins%,}
|
---|
| 270 |
|
---|
| 271 | echo "Activated Plugins:"
|
---|
| 272 | echo "$plugins"
|
---|
| 273 |
|
---|
[12474] | 274 | # Copy words.cfg for spelling
|
---|
[5213] | 275 | mkdir -p "$jar_path/speller"
|
---|
[15969] | 276 | cp ../../utils/planet.osm/java/speller/words.cfg "$jar_path/speller/" || {
|
---|
| 277 | echo "!!!!!!!!!! words.cfg is missing"
|
---|
| 278 | exit -1
|
---|
| 279 | }
|
---|
[4308] | 280 |
|
---|
[15969] | 281 |
|
---|
[4308] | 282 | # ------------------------------------------------------------------
|
---|
[15969] | 283 | cp "debian/bin/josm.sh" "$bin_path/josm" || {
|
---|
| 284 | echo "!!!!!!!!!! josm.sh is missing"
|
---|
| 285 | exit -1
|
---|
| 286 | }
|
---|
| 287 |
|
---|
[11707] | 288 | cp "debian/bin/josm-ng.sh" "$bin_path/josm-ng" || {
|
---|
| 289 | echo "!!!!!!!!!!!!!!!!! WARNING Josm-NG is not included into the package"
|
---|
| 290 | #exit -1
|
---|
| 291 | }
|
---|
[4308] | 292 |
|
---|
[12474] | 293 | # add plugins to default preferences
|
---|
[15969] | 294 | sed "s/PLUGIN_LIST/$plugins/;" <debian/bin/preferences >"$jar_path/preferences" || {
|
---|
| 295 | echo "!!!!!!!! WARNING cannot create preferences"
|
---|
| 296 | exit -1
|
---|
| 297 | }
|
---|
| 298 |
|
---|
[12474] | 299 |
|
---|
| 300 | # Copy default Bookmarks
|
---|
[5213] | 301 | cp nsis/bookmarks "$jar_path/bookmarks"
|
---|
[15969] | 302 |
|
---|
| 303 | exit 0
|
---|