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