root/middleware-offline/trunk/_src/eidmw/build_eidmw_sdk_linux.sh @ 5

Revision 5, 6.0 KB (checked in by vsilva, 9 years ago)

Initial comit

Line 
1#!/bin/bash
2#-----------------------------------------
3# this script will build the eID MW SDK project on linux
4# it will call all necessary scripts to build and will log
5# the build process to a file build_eidmw_<distro>_<buildnr>.log
6#
7# To do a local build, use parameter 'local'
8#-----------------------------------------
9DISTRO=none
10TARBALLDISTRO=none
11DIR_CURR=`pwd`
12PROJ_NAME=eidmw
13DIR_PROJ=~${DIR_CURR}
14TARGETDIR="~/.gvfs/eidmwbuilds\ on\ 10.2.250.42"
15PROCESSOR=`uname -p`
16TESTFILE=test.txt
17
18TESTBUILD=0     # it is a full build
19COPYTGZ=1       # copy the TGZ to the network
20SDKTARBALL=1    # generate SDK taball
21BUILDMW=1       # build the middleware
22LOCALBUILD=0    # do a local build (same as TESTBUILD=1, COPYTGZ=0, SDKTARBALL=1)
23
24until [ -z "$1" ]
25do
26        if [ $1 == "local" ]
27        then
28                TESTBUILD=1
29                COPYTGZ=0
30                SDKTARBALL=1
31                LOCALBUILD=$1
32        else if [ $1 == "test" ]
33        then
34                TESTBUILD=1
35                echo "[Info] Test build, do not checkin in SVN the wrapper so file."
36        else if [ $1 == "nocopy" ]
37        then
38                COPYTGZ=0
39                echo "[Info] Don't copy TGZ to network."
40        else if [ $1 == "notarball" ]
41        then
42                SDKTARBALL=0
43                echo "[Info] Don't generate sdk tarball."
44        else if [ $1 == "nobuildmw" ]
45        then
46                BUILDMW=0
47                echo "[Info] Don't build the middleware."
48        else if [ $1 == "help" ]
49        then
50                echo "$0 [local,test,nocopy,notarball,nobuildmw] "
51                echo "local: same as test build + nocopy"
52                echo "test: Test build, do not checkin in SVN the wrapper so file."
53                echo "nocopy: Don't copy TGZ to network."
54                echo "notarball: Don't generate sdk tarball."
55                echo "nobuildmw: Don't build the middleware."
56                exit -1
57        fi
58        fi
59        fi
60        fi
61        fi
62        fi
63        shift
64done
65
66
67if [ ! -d "../ThirdParty/pteid_sdk/3.5/Java" ]
68then
69        echo "[Error] Checkout 'ThirdParty/pteid_sdk/3.5/Java' before continuing"
70        exit -1
71fi
72
73if [ -e "/etc/fedora-release" ]
74then
75        DISTRO=fedora
76        TARBALLDISTRO=fedora
77else
78if [ -e "/etc/SuSE-release" ]
79then
80        DISTRO=suse
81        TARBALLDISTRO=opensuse
82else
83if [ -e "/etc/debian_version" ]
84then
85        DISTRO=debian
86        TARBALLDISTRO=debian
87        PROCESSOR=`uname -m`
88        TARGETDIR=/mnt/eidmwbuilds
89else
90        echo "[Error] Unsupported Linux distribution."
91        echo "[Error] Done..."
92        exit -1
93fi
94fi
95fi
96
97#-----------------------------------------
98# test if the target directory is accessible
99# this is done by touching a file since testing the existance
100# of the directory does not work due to the spaces in the directory
101# name on fedora and suse.
102#-----------------------------------------
103if [ ${LOCALBUILD} != "local" ]
104then
105        eval touch $TARGETDIR/$TESTFILE &> /dev/null
106        NRFILES=`eval ls $TARGETDIR 2> /dev/null | wc -l`
107
108        if [ $NRFILES == 0 ]
109        then
110                echo "[Error] SMB not mounted to store build results."
111                echo "[Error] Expected mount point: $TARGETDIR"
112                if [ -e "/etc/debian_version" ]
113                then
114                        echo "[Error] Please mount as follows as 'root':"
115                        cat howtomount.sh
116                fi
117                exit -1
118        fi
119
120        eval rm $TARGETDIR/$TESTFILE
121fi
122
123#echo "[Info ] Checking ../pteid-2.6"
124#if [ ! -d ../pteid-2.6 ]
125#then
126#       echo "[Error] Directory ../pteid-2.6 does not exist"
127#fi
128#-----------------------------------------
129# first build the 2.6 version
130#-----------------------------------------
131#cd ../pteid-2.6
132#./build_eidmw_linux.sh
133#cd ${DIR_CURR}
134
135#-----------------------------------------
136# check if we're doing a local build
137#-----------------------------------------
138if [ ${LOCALBUILD} != "local" ]
139then
140        ./getsvnrevision.pl
141fi
142
143#-----------------------------------------
144# make sure we get the SVN revision nr for this build
145#-----------------------------------------
146if [ ! -e "svn_revision" ]
147then
148        echo "[Error] File svn_revision not found"
149        exit -1
150fi
151
152BUILD_NR=`cat svn_revision`
153LOGFILE=build_${PROJ_NAME}_${DISTRO}_${BUILD_NR}.log
154
155#-----------------------------------------
156# perform all steps to do a complete build
157#-----------------------------------------
158# set the environment variables
159# run the configure script
160# start the make process
161#-----------------------------------------
162if [ $BUILDMW == 1 ]
163then
164        source ${DIR_CURR}/build_${PROJ_NAME}_${DISTRO}.source
165        chmod +x configure_${DISTRO}.sh
166        configure_${DISTRO}.sh
167        make 2>&1 | tee ${LOGFILE} 
168fi
169
170#-----------------------------------------
171# this looks odd, but the $PIPESTATUS holds the return
172# value of make
173#-----------------------------------------
174if [[ $PIPESTATUS != 0 && $BUILDMW == 1 ]] 
175then
176        echo "[Error] Make failed. See logfile '${LOGFILE}'"
177        exit -1
178fi
179
180#-----------------------------------------
181# build process successful, then put the file libpteidlibJava_Wrapper.so
182# to SVN to include it later in the SDK package. We use the fedora library to put
183# in the SDK, which will be picked up by the script to create the SDK
184# tarball.
185#-----------------------------------------
186if [ $DISTRO=="fedora" ]
187then
188        if [[ $TESTBUILD == 0 && ${LOCALBUILD} != "local" ]]
189        then
190                echo "[Info ] Checking in wrapper in SVN"
191                cp lib/libpteidlibJava_Wrapper.so ../ThirdParty/pteid_sdk/3.5/Java
192                svn commit ../ThirdParty/pteid_sdk/3.5/Java/libpteidlibJava_Wrapper.so -m "build nr: ${BUILD_NR}"
193        fi
194fi
195
196#-----------------------------------------
197# build the documentation
198#-----------------------------------------
199cd _DocsInternal/API
200echo "[Info] Generating documentation"
201#./doxygen_sdk_c.sh >> ${LOGFILE}
202./doxygen_sdk.sh >> ${LOGFILE}
203cd ${DIR_CURR} 
204
205#-----------------------------------------
206# generate the SDK tarball
207#-----------------------------------------
208if [[ $SDKTARBALL == 1 || $LOCALBUILD == "local" ]]
209then
210        echo "[Info] Generating sdk tarball"
211        cd misc
212        ./prepareSdkTarball.pl >> ${LOGFILE}
213        cd ${DIR_CURR} 
214        if [ $? != 0 ]
215        then
216                echo "[Error] Error generating SDK tarball "
217                exit -1
218        fi
219fi
220cd install
221BINTARBALL=`ls pteid-sdk-3.?.*-${TARBALLDISTRO}-*-${PROCESSOR}-${BUILD_NR}.tgz 2> /dev/null`
222cd ${DIR_CURR} 
223
224echo [Info ] Tarball generated: ${BINTARBALL}
225
226#-----------------------------------------
227# copy the tarball to the machine such everybody can access it
228#-----------------------------------------
229if [[ $COPYTGZ == 1 && ${LOCALBUILD} != "local" ]]
230then
231        echo "[Info] Copy ${BINTARBALL} to ${TARGETDIR}"
232        cd install
233        eval cp ${BINTARBALL} ${TARGETDIR}
234        cd ${DIR_CURR} 
235fi
236echo "[Info] Done"
Note: See TracBrowser for help on using the browser.