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

Last change on this file since 28702 was 17618, checked in by joerg, 10 years ago

remove ../lib from creation

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