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

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

Disable osmosis in debuild , since it got it's own debian Package

  • Property svn:executable set to *
File size: 11.4 KB
Line 
1#!/bin/bash
2# This script replaces a make ; make install for creation of the debian package.
3# Maybe you can also use it to install the stuff on your system.
4# If you are successfull, please write how to do this here
5# PS.: Any improvements/additions to this installer are welcome.
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%/}
41platform=`uname -m`
42
43perl_path="$dst_path/usr/share/perl5"
44bin_path="$dst_path/usr/bin"
45lib_path="$dst_path/usr/lib"
46share_path="$dst_path/usr/share/$package_name"
47man1_path="$dst_path/usr/man/man1"
48mkdir -p "$perl_path"
49mkdir -p "$bin_path"
50mkdir -p "$lib_path"
51mkdir -p "$share_path"
52mkdir -p "$man1_path"
53
54
55# #######################################################
56# Osmosis
57# #######################################################
58if false; then
59    echo "${BLUE}----------> applications/utils/osmosis/trunk Osmosis${NORMAL}"
60
61    cd osmosis
62
63    # Osmosis moves it's Binary arround, so to be sure we do not catch old Versions and don't
64    # recognize it we remove all osmosis.jar Files first
65    ( find . -name "osmosis*.jar" | while read file ; do rm "$file" ; done ) || true
66
67    cd trunk
68
69    ant clean >build.log 2>build.err
70    ant dist >>build.log 2>>build.err
71    if [ "$?" -ne "0" ] ; then
72        echo "${RED}!!!!!! ERROR compiling  Osmosis ${NORMAL}"
73        exit -1
74    fi
75    cd ../..
76
77    osmosis_dir="$dst_path/usr/local/share/osmosis/"
78    mkdir -p $osmosis_dir
79    cp osmosis/trunk/build/binary/osmosis.jar $osmosis_dir
80    if [ "$?" -ne "0" ] ; then
81        echo "${RED}!!!!!! ERROR cannot find resulting osmosis.jar ${NORMAL}"
82        exit -1
83    fi
84
85    # copy needed libs
86    mkdir -p $osmosis_dir/lib/
87    cp osmosis/trunk/lib/default/*.jar $osmosis_dir/lib/
88    if [ "$?" -ne "0" ] ; then
89        echo "${RED}!!!!!! ERROR cannot copy needed libs for osmosis${NORMAL}"
90        exit -1
91    fi
92
93    # Osmosis script
94    src_fn="osmosis/trunk/bin/osmosis"
95    man1_fn="$man1_path/osmosis.1"
96    if grep -q -e "--help" "$src_fn"; then
97        echo "Create Man Page from Help '$man1_fn'"
98        perl $src_fn --help >"$man1_fn"
99    else
100        echo "!!!! No idea how to create Man Page for $src_fn"
101    fi
102    mkdir -p $osmosis_dir/bin
103    cp $src_fn "$osmosis_dir/bin/osmosis"
104    if [ "$?" -ne "0" ] ; then
105        echo "${RED}!!!!!! ERROR cannot find resulting osmosis script ${NORMAL}"
106        exit -1
107    fi
108
109    ln -sf /usr/local/share/osmosis/bin/osmosis $bin_path/osmosis
110fi
111
112# ------------------------------------------------------------------
113# Utilities written in C
114
115# ------------------------------------------------------------------
116# Various libs
117for lib in ccoord libosm libimg  ; do 
118    allow_error=false
119    if [ "$platform" == "x86_64" ] ; then
120        if echo $lib | grep -q -e libosm -e ccoord -e libimg ; then
121            allow_error=true
122        fi
123    fi
124
125    echo "${BLUE}----------> applications/lib/$lib${NORMAL}"
126    cd ../lib/$lib
127
128    # for a in *.cpp ; do perl -p -i -e 's,libshp/shapefil.h,shapefil.h,g' $a; done
129    make clean >build.log 2>build.err
130
131    make >>build.log 2>>build.err
132    if [ "$?" -ne "0" ] ; then
133        if $allow_error ; then
134            echo "Ignored Errors in 'applications/lib/$lib' because it does not compile on my debian $platform machine"
135            cd ..
136            continue
137        fi
138        echo "${RED}!!!!!! ERROR compiling $lib ${NORMAL}"
139        echo "Logfile is at `pwd`/build.log build.err"
140        exit -1
141    fi
142    cd ..
143    result_lib=$lib/lib${lib}.a
144    result_lib=`find . -name "*${lib}*.a"`
145    test -s "$result_lib" || result_lib="$lib/${lib}.a"
146    if [ ! -s "$result_lib"  ] ; then
147        echo "${RED}!!!!!! ERROR compiling $lib no Resulting '$result_lib'${NORMAL}"
148        exit -1
149    fi
150    cp "$result_lib" "../utils/${lib_path}" || exit -1
151done
152cd ../utils/
153
154# Perl-libs
155for lib in Geo-OSM-MapFeatures ; do 
156    echo "${BLUE}----------> applications/lib/$lib${NORMAL} (Compile only)"
157    cd ../lib/$lib
158
159    # for a in *.cpp ; do perl -p -i -e 's,libshp/shapefil.h,shapefil.h,g' $a; done
160    make clean >build.log 2>build.err
161
162    if [ -s "Makefile.PL" ] ; then
163        perl Makefile.PL >>build.log 2>>build.err
164        if [ "$?" -ne "0" ] ; then
165            echo "${RED}!!!!!! ERROR compiling $lib ${NORMAL}"
166            echo "Logfile is at `pwd`/build.log build.err"
167            exit -1
168        fi
169
170    fi
171
172    make >>build.log 2>>build.err
173    if [ "$?" -ne "0" ] ; then
174        echo "${RED}!!!!!! ERROR compiling $lib ${NORMAL}"
175        echo "Logfile is at `pwd`/build.log build.err"
176        exit -1
177    fi
178
179    cd ..
180
181    #!!!!!!!!!!!!!!!!
182    # TODO: Copy resulting *.pm and ManPages
183    #
184done
185cd ../utils/
186
187
188# ------------------------------------------------------------------
189# Importer
190for import in `ls import/*/Makefile| sed 's,/Makefile,,;s,import/,,'` ; do 
191    allow_error=false
192    if echo $import | grep -q  and_import ; then
193        allow_error=true
194    fi
195
196    echo "${BLUE}----------> applications/utils/import/$import${NORMAL}"
197    cd import/$import/
198    make clean >build.log 2>build.err
199    make >>build.log 2>>build.err
200    if [ "$?" -ne "0" ] ; then
201        if $allow_error ; then
202            echo "Ignored 'applications/import/$import' because it does not compile on my debian machine"
203            cd ../..
204            continue
205        fi
206        echo "${RED}!!!!!! ERROR compiling  import/${import} ${NORMAL}"
207        exit -1
208    fi
209    cd ../..
210    cp import/$import/2AND  ${bin_path}/osm2AND
211done
212
213# ------------------------------------------------------------------
214# Filter
215# As soon it compiles here on my debian machine
216# i will remove the excludes
217for filter in `ls filter/*/Makefile| sed 's,/Makefile,,;s,filter/,,'` ; do 
218    allow_error=false
219    if echo $filter | grep -q wayclean ; then
220        allow_error=true
221    fi
222
223    echo "${BLUE}----------> applications/utils/filter/${filter}${NORMAL}"
224    cd filter/${filter}  || exit -1
225    make clean >build.log 2>build.err
226    make >>build.log 2>>build.err
227    if [ "$?" -ne "0" ] ; then
228        if $allow_error ; then
229            echo "Ignored 'applications/filter/$filter' because it does not compile on my debian machine"
230            cd ../..
231            continue
232        fi
233        echo "${RED}!!!!!! ERROR compiling  filter/${filter} ${NORMAL}"
234        exit -1
235    fi
236    cd ../..
237    cp filter/${filter}/${filter} ${bin_path}
238done
239
240# ------------------------------------------------------------------
241# Export
242# As soon it compiles here on my debian machine
243# i will remove the excludes
244for export in `ls export/*/Makefile| sed 's,/Makefile,,;s,export/,,'` ; do 
245    allow_error=false
246    if echo $export | grep -q -e osmgarminmap -e osm2shp -e osmgoogleearth; then
247        allow_error=true
248    fi
249
250    echo "${BLUE}----------> applications/utils/export/${export}${NORMAL}"
251    cd export/${export}  || exit -1
252
253    if [ -s "Makefile.$export" ] ;then
254        custom_makefile=" -f Makefile.$export"
255    else
256        custom_makefile=''
257    fi
258
259    make $custom_makefile clean >build.log 2>build.err
260    make $custom_makefile >>build.log 2>>build.err
261    if [ "$?" -ne "0" ] ; then
262        if $allow_error ; then
263            echo "Ignored 'applications/export/$export' because it does not compile on my debian machine"
264            cd ../..
265            continue
266        fi
267        echo "${RED}!!!!!! ERROR compiling  export/${export} ${NORMAL}"
268        exit -1
269    fi
270    cd ../..
271    cp export/${export}/${export} ${bin_path}
272
273    case ${export} in
274        osm2pgsql) 
275            cp export/osm2pgsql/default.style ${share_path}/default.style
276            if [ "$?" -ne "0" ] ; then
277                echo "${RED}!!!!!! ERROR osm2pgsql/default.style no copied ${NORMAL}"
278                exit -1
279            fi
280            ;;
281    esac
282done
283
284# ------------------------------------------------------------------
285if true ; then
286    echo "${BLUE}----------> applications/utils/color255${NORMAL}"
287    cd color255 || exit -1
288    make clean >build.log 2>build.err
289    make >>build.log 2>>build.err
290    if [ "$?" -ne "0" ] ; then
291        echo "${RED}!!!!!! ERROR compiling color255 ${NORMAL}"
292        exit -1
293    fi
294    cd ..
295    cp color255/color255 ${bin_path}
296fi
297
298
299# ------------------------------------------------------------------
300if true; then
301    echo "${BLUE}----------> applications/planet.osm/C/UTF8Sanitizer${NORMAL}${NORMAL}"
302    cd planet.osm/C/  || exit -1
303    make clean >build.log 2>build.err
304    make >>build.log 2>>build.err
305    if [ "$?" -ne "0" ] ; then
306        echo "${RED}!!!!!! ERROR compiling color255 ${NORMAL}"
307        exit -1
308    fi
309    cd ../..
310    cp planet.osm/C/UTF8Sanitizer ${bin_path} || exit -1
311fi
312
313# ------------------------------------------------------------------
314echo "${BLUE}----------> applications/utils/perl_lib Copy Perl libraries${NORMAL}${NORMAL}"
315find perl_lib/ -name "*.pm" | while read src_fn ; do 
316    dst_fn="$perl_path/${src_fn#perl_lib/}"
317    dst_dir=`dirname "$dst_fn"`
318    test -d "$dst_dir" || mkdir -p "$dst_dir"
319    cp "$src_fn" "$dst_fn"
320done
321
322echo "${BLUE}----------> applications/utils Copy Perl Binaries${NORMAL}${NORMAL}"
323find ./ -name "*.pl" | while read src_fn ; do 
324    dst_fn="$bin_path/${src_fn##*/}"
325    filename="`basename $src_fn`"
326    dst_fn="${dst_fn/.pl}"
327    if ! echo $dst_fn | grep -e osm ; then
328        dst_fn="`dirname ${dst_fn}`/osm-`basename ${dst_fn}`"
329    fi
330    man1_fn="$man1_path/${filename%.pl}.1"
331    if head -1 "$src_fn" | grep -q -e '^#! */usr/bin/perl' ; then
332        cp "$src_fn" "$dst_fn"
333    else
334        echo "${RED}WARNING!!! Perl Hash Bang is missing at File '$src_fn'${NORMAL}"
335        echo "           I'm not adding this File to the debian Package"
336        echo "First Line: `head -1 $src_fn`"
337    fi
338
339    # ----- Try to create man Pages
340    if perldoc "$src_fn" >/dev/null 2>&1 ; then
341        echo "Create Man Page from pod '$man1_fn'"
342        pod2man $src_fn >"$man1_fn"
343    else
344        if grep -q -e "--man" "$src_fn"; then
345            echo "Create Man Page '$man1_fn'"
346            perl $src_fn --man >"$man1_fn"
347        else
348            if grep -q -e "--help" "$src_fn"; then
349                echo "Create Man Page from Help '$man1_fn'"
350                perl $src_fn --help >"$man1_fn"
351            else
352                echo "!!!! No idea how to create Man Page for $src_fn"
353            fi
354        fi
355    fi
356done
357
358# --------------------------------------------
359echo "${BLUE}----------> applications/utils Copy Python Binaries${NORMAL}"
360find ./ -name "*.py" | while read src_fn ; do 
361    dst_fn="$bin_path/${src_fn##*/}"
362    dst_fn="${dst_fn/.py}"
363    if head -1 "$src_fn" | grep -q -e '^#! */usr/bin/python' -e '^#!/opt/python-2_5/bin/python' -e '^#!/usr/bin/env python'; then
364        cp "$src_fn" "$dst_fn"
365    else
366        if head -1 "$src_fn" | grep -q -e '^#!/opt/python-2_5/bin/python' -e '^#!/usr/bin/env python'; then
367            (echo '#!/usr/bin/python2.5'; cat "$src_fn") >"$dst_fn"
368        else
369            echo "${RED}WARNING!!! Python Hash Bang is missing at File '$src_fn'${NORMAL}"
370            echo "           I'm not adding this File to the debian Package"
371            echo "           First Line: `head -1 $src_fn`"
372        fi
373    fi
374done
375
376
377#########################################################
378# Mapnik installation tool
379#########################################################
380echo "${BLUE}----------> Mapnik${NORMAL}"
381cp export/osm2pgsql/mapnik-osm-updater.sh "$bin_path"
382cp export/osm2pgsql/900913.sql "$bin_path"
383cp export/osm2pgsql/default.style  "$bin_path"
384
385
386##################################################################
387# XXX
388# For later:
389# 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.