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

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

Ignored 'planet.osm/C/' because it does not compile on my debian machine
do not copy test.py it would collide with system core utils

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