source: subversion/applications/utils/debian/make_install_files.sh @ 12646

Last change on this file since 12646 was 12646, checked in by joerg, 11 years ago

Add error messages if compile fails

  • Property svn:executable set to *
File size: 9.1 KB
Line 
1
2#!/bin/sh
3# This script replaces a make ; make install for creation of the debian package.
4# Maybe you can also use it to install the stuff on your system.
5# If sou please state so here.
6
7dst_path=$1
8
9if [ ! -n "$dst_path" ] ; then
10    echo "Please specify a Directory to use as Basedirectory"
11    echo "Usage:"
12    echo "     $0 <working-dir>"
13    exit -1
14fi
15
16# define Colors
17ESC=`echo -e "\033"`
18RED="${ESC}[91m"
19GREEN="${ESC}[92m"
20YELLOW="${ESC}[93m"
21BLUE="${ESC}[94m"
22MAGENTA="${ESC}[95m"
23CYAN="${ESC}[96m"
24WHITE="${ESC}[97m"
25BG_RED="${ESC}[41m"
26BG_GREEN="${ESC}[42m"
27BG_YELLOW="${ESC}[43m"
28BG_BLUE="${ESC}[44m"
29BG_MAGENTA="${ESC}[45m"
30BG_CYAN="${ESC}[46m"
31BG_WHITE="${ESC}[47m"
32BRIGHT="${ESC}[01m"
33UNDERLINE="${ESC}[04m"
34BLINK="${ESC}[05m"
35REVERSE="${ESC}[07m"
36NORMAL="${ESC}[0m"
37
38echo "copying Files to '$dst_path'"
39package_name=openstreetmap
40dst_path=${dst_path%/}
41
42perl_path="$dst_path/usr/share/perl5"
43bin_path="$dst_path/usr/bin"
44lib_path="$dst_path/usr/lib"
45share_path="$dst_path/usr/share/$package_name"
46man1_path="$dst_path/usr/man/man1"
47mkdir -p "$perl_path"
48mkdir -p "$bin_path"
49mkdir -p "$lib_path"
50mkdir -p "$share_path"
51mkdir -p "$man1_path"
52
53platform=`uname -m`
54
55# ------------------------------------------------------------------
56# Utilities written in C
57
58# ------------------------------------------------------------------
59# Various libs
60for lib in ccoord libosm libimg ; do 
61    if [ "$platform" == "x86_64" ] ; then
62        if echo $lib | grep -q -e libosm -e ccoord ; then
63            echo "Ignored '$lib' because it does not compile on my debian $platform machine"
64            continue
65        fi
66    fi
67
68    echo "${BLUE}----------> lib/$lib${NORMAL}"
69    cd ../lib/$lib
70    # for a in *.cpp ; do perl -p -i -e 's,libshp/shapefil.h,shapefil.h,g' $a; done
71    make clean >build.log 2>build.err
72    make >>build.log 2>>build.err
73    if [ "$?" -ne "0" ] ; then
74        echo "${RED}!!!!!! ERROR compiling $lib ${NORMAL}"
75        exit -1
76    fi
77    cd ..
78    result_lib=$lib/lib${lib}.a
79    result_lib=`find . -name "*${lib}*.a"`
80    test -s "$result_lib" || result_lib="$lib/${lib}.a"
81    if [ ! -s "$result_lib"  ] ; then
82        echo "${RED}!!!!!! ERROR compiling $lib no Resulting '$result_lib'${NORMAL}"
83        exit -1
84    fi
85    cp "$result_lib" "../utils/${lib_path}" || exit -1
86done
87cd ../utils/
88
89
90# ------------------------------------------------------------------
91# Importer
92for import in `ls import/*/Makefile| sed 's,/Makefile,,;s,import/,,'` ; do 
93    if echo $import | grep -q  and_import ; then
94        echo "Ignored '$import' because it does not compile on my debian machine"
95        continue
96    fi
97
98    echo "${BLUE}----------> import/$import${NORMAL}"
99    cd import/$import/
100    make clean >build.log 2>build.err
101    make >>build.log 2>>build.err
102    if [ "$?" -ne "0" ] ; then
103        echo "${RED}!!!!!! ERROR compiling  import/${import} ${NORMAL}"
104        exit -1
105    fi
106    cd ../..
107    cp import/$import/2AND  ${bin_path}/osm2AND
108done
109
110# ------------------------------------------------------------------
111# Filter
112# As soon it compiles here on my debian machine
113# i will remove the excludes
114for filter in `ls filter/*/Makefile| sed 's,/Makefile,,;s,filter/,,'` ; do 
115    if echo $filter | grep -q wayclean ; then
116        echo "Ignored '$filter' because it does not compile on my debian machine"
117        continue
118    fi
119
120    echo "${BLUE}----------> filter/${filter}${NORMAL}"
121    cd filter/${filter}  || exit -1
122    make clean >build.log 2>build.err
123    make >>build.log 2>>build.err
124    if [ "$?" -ne "0" ] ; then
125        echo "${RED}!!!!!! ERROR compiling  filter/${filter} ${NORMAL}"
126        exit -1
127    fi
128    cd ../..
129    cp filter/${filter}/${filter} ${bin_path}
130done
131
132# ------------------------------------------------------------------
133# Export
134# As soon it compiles here on my debian machine
135# i will remove the excludes
136for export in `ls export/*/Makefile| sed 's,/Makefile,,;s,export/,,'` ; do 
137    if echo $export | grep -q -e osmgarminmap -e osm2shp -e osmgoogleearth; then
138        echo "Ignored '$export' because it does not compile on my debian machine"
139        continue
140    fi
141
142    echo "${BLUE}----------> export/${export}${NORMAL}"
143    cd export/${export}  || exit -1
144
145    if [ -s "Makefile.$export" ] ;then
146        custom_makefile=" -f Makefile.$export"
147    else
148        custom_makefile=''
149    fi
150
151    make $custom_makefile clean >build.log 2>build.err
152    make $custom_makefile >>build.log 2>>build.err
153    if [ "$?" -ne "0" ] ; then
154        echo "${RED}!!!!!! ERROR compiling  export/${export} ${NORMAL}"
155        exit -1
156    fi
157    cd ../..
158    cp export/${export}/${export} ${bin_path}
159done
160
161# ------------------------------------------------------------------
162if true ; then
163    echo "${BLUE}----------> color255${NORMAL}"
164    cd color255 || exit -1
165    make clean >build.log 2>build.err
166    make >>build.log 2>>build.err
167    if [ "$?" -ne "0" ] ; then
168        echo "${RED}!!!!!! ERROR compiling color255 ${NORMAL}"
169        exit -1
170    fi
171    cd ..
172    cp color255/color255 ${bin_path}
173fi
174
175# ------------------------------------------------------------------
176if true ; then
177    echo "${BLUE}----------> osm2pqsql${NORMAL}"
178    cd export/osm2pgsql  || exit -1
179    make clean >build.log 2>build.err
180    make >>build.log 2>>build.err
181    if [ "$?" -ne "0" ] ; then
182        echo "${RED}!!!!!! ERROR compiling osm2pgsql ${NORMAL}"
183        exit -1
184    fi
185    cd ../..
186    cp export/osm2pgsql/osm2pgsql ${bin_path}
187    if [ "$?" -ne "0" ] ; then
188        echo "${RED}!!!!!! ERROR osm2pgsql not copied ${NORMAL}"
189        exit -1
190    fi
191    cp export/osm2pgsql/default.style ${share_path}/default.style
192    if [ "$?" -ne "0" ] ; then
193        echo "${RED}!!!!!! ERROR osm2pgsql/default.style no copied ${NORMAL}"
194        exit -1
195    fi
196fi
197
198# ------------------------------------------------------------------
199if true; then
200    echo "${BLUE}----------> UTF8Sanitizer${NORMAL}${NORMAL}"
201    cd planet.osm/C/  || exit -1
202    make clean >build.log 2>build.err
203    make >>build.log 2>>build.err
204    if [ "$?" -ne "0" ] ; then
205        echo "${RED}!!!!!! ERROR compiling color255 ${NORMAL}"
206        exit -1
207    fi
208    cd ../..
209    cp planet.osm/C/UTF8Sanitizer ${bin_path} || exit -1
210fi
211
212# ------------------------------------------------------------------
213echo "${BLUE}----------> Copy Perl libraries${NORMAL}${NORMAL}"
214find perl_lib/ -name "*.pm" | while read src_fn ; do 
215    dst_fn="$perl_path/${src_fn#perl_lib/}"
216    dst_dir=`dirname "$dst_fn"`
217    test -d "$dst_dir" || mkdir -p "$dst_dir"
218    cp "$src_fn" "$dst_fn"
219done
220
221echo "${BLUE}----------> Copy Perl Binaries${NORMAL}${NORMAL}"
222find ./ -name "*.pl" | while read src_fn ; do 
223    dst_fn="$bin_path/${src_fn##*/}"
224    filename="`basename $src_fn`"
225    dst_fn="${dst_fn/.pl}"
226    if ! echo $dst_fn | grep -e osm ; then
227        dst_fn="`dirname ${dst_fn}`/osm-`basename ${dst_fn}`"
228    fi
229    man1_fn="$man1_path/${filename%.pl}.1"
230    if head -1 "$src_fn" | grep -q -e '^#! */usr/bin/perl' ; then
231        cp "$src_fn" "$dst_fn"
232    else
233        echo "${RED}WARNING!!! Perl Hash Bang is missing at File '$src_fn'${NORMAL}"
234        echo "           I'm not adding this File to the debian Package"
235        echo "First Line: `head -1 '$src_fn'`"
236    fi
237
238    # ----- Try to create man Pages
239    if perldoc "$src_fn" >/dev/null 2>&1 ; then
240        echo "Create Man Page from pod '$man1_fn'"
241        pod2man $src_fn >"$man1_fn"
242    else
243        if grep -q -e "--man" "$src_fn"; then
244            echo "Create Man Page '$man1_fn'"
245            perl $src_fn --man >"$man1_fn"
246        else
247            if grep -q -e "--help" "$src_fn"; then
248                echo "Create Man Page from Help '$man1_fn'"
249                perl $src_fn --help >"$man1_fn"
250            else
251                echo "!!!! No idea how to create Man Page for $src_fn"
252            fi
253        fi
254    fi
255done
256
257# --------------------------------------------
258echo "${BLUE}----------> Copy Python Binaries${NORMAL}"
259find ./ -name "*.py" | while read src_fn ; do 
260    dst_fn="$bin_path/${src_fn##*/}"
261    dst_fn="${dst_fn/.py}"
262    if head -1 "$src_fn" | grep -q -e '^#! */usr/bin/python' -e '^#!/opt/python-2_5/bin/python' -e '^#!/usr/bin/env python'; then
263        cp "$src_fn" "$dst_fn"
264    else
265        if head -1 "$src_fn" | grep -q -e '^#!/opt/python-2_5/bin/python' -e '^#!/usr/bin/env python'; then
266            (echo '#!/usr/bin/python2.5'; cat "$src_fn") >"$dst_fn"
267        else
268            echo "${RED}WARNING!!! Python Hash Bang is missing at File '$src_fn'${NORMAL}"
269            echo "           I'm not adding this File to the debian Package"
270            echo "           First Line: `head -1 $src_fn`"
271        fi
272    fi
273done
274
275
276# #######################################################
277# Osmosis
278# #######################################################
279echo "${BLUE}----------> Osmosis${NORMAL}"
280cd osmosis/trunk
281ant clean >build.log 2>build.err
282ant dist >>build.log 2>>build.err
283if [ "$?" -ne "0" ] ; then
284    echo "${RED}!!!!!! ERROR compiling  Osmosis ${NORMAL}"
285    exit -1
286fi
287cd ../..
288mkdir -p $dst_path/usr/local/share/osmosis/
289cp ./osmosis/dist/result/osmosis.jar $dst_path/usr/local/share/osmosis/
290
291cp debian/osmosis.sh "$bin_path/osmosis"
292
293
294#########################################################
295# Mapnik installation tool
296#########################################################
297echo "${BLUE}----------> Mapnik${NORMAL}"
298cp export/osm2pgsql/mapnik-osm-updater.sh "$bin_path"
299cp export/osm2pgsql/900913.sql "$bin_path"
300cp export/osm2pgsql/default.style  "$bin_path"
301
302
303##################################################################
304# XXX
305# For later:
306# Add java tools, but for these a build.xml with a target jar or similar would be best
Note: See TracBrowser for help on using the repository browser.