2 # Fetches, builds and store the result of a heimdal build
3 # Version: $Id: heimdal-build.sh 21653 2007-07-18 20:15:59Z lha $
5 fetchmethod=wget #options are: wget, curl, ftp, afs
7 email=heimdal-build-log@it.su.se
8 baseurl=ftp://ftp.pdc.kth.se/pub/heimdal/src
9 afsdir=/afs/pdc.kth.se/public/ftp/pub/heimdal/src
17 # Add some bonus paths, to find sendmail and other tools
18 # on interesting platforms.
19 PATH="${PATH}:/usr/sbin:/usr/bin:/usr/libexec:/usr/lib"
20 PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
22 # no more user configurabled part below (hopefully)
24 usage="[--current] [--svn SourceRepository] [--cvs-flags] [--result-directory dir] [--fetch-method wget|ftp|curl|cvs|fetch|afs] --keep-tree] [--autotools] [--passhrase string] [--no-email] [--build-dir dir] [--cputime] [--distcheck] [--test-environment env] [--configure-flags flags]"
27 if [ "$?" != 0 ]; then
28 echo "have no sane date, punting"
33 if [ "$?" != 0 ]; then
34 echo "have no sane hostname, punting"
38 version=`grep "^# Version: " "$0" | cut -f2- -d:`
39 if [ "X${version}" = X ]; then
40 echo "Can not figure out what version I am"
66 hversion="heimdal-${date}"
82 hversion="heimdal-svn-${date}"
93 if [ ! -d "$resultdir" ]; then
94 echo "$resultdir doesn't exists"
97 resultdir="`pwd`/${resultdir}"
125 confflags="${confflags} $2"
129 echo "Version: $version"
133 echo "unknown option: $1"
141 if test $# -gt 0; then
146 if [ "X${hversion}" = X ]; then
147 echo "no version given"
151 hfile="${hversion}.tar.gz"
152 url="${baseurl}/${dir}${hfile}"
153 afsfile="${afsdir}/${dir}${hfile}"
156 # extra paths for the user
157 if [ "X${prependpath}" != X ]; then
158 PATH="${prependpath}:${PATH}"
161 # Limit cpu seconds this all can take
162 ulimit -t "$cputimelimit" > /dev/null 2>&1
164 if [ "X${builddir}" != X ]; then
165 echo "Changing build dir to ${builddir}"
169 echo "Removing old source"
172 echo "Fetching ${hversion} using $fetchmethod"
173 case "$fetchmethod" in
175 ${fetchmethod} $url > /dev/null
179 ${fetchmethod} -o ${hfile} ${url} > /dev/null
183 cp ${afsfile} ${hfile}
187 svn co $svnroot ${hversion}
193 echo "unknown fetch method"
197 if [ "X$res" != X0 ]; then
198 echo "Failed to download the tar-ball"
202 if [ X"$unpack" = Xyes ]; then
203 echo Unpacking source
204 (gzip -dc ${hfile} | tar xf -) || exit 1
207 if [ X"$autotools" = Xyes ]; then
209 (cd ${hversion} && sh ./autogen.sh) || exit 1
212 if [ X"$ccachedir" != X ]; then
213 CCACHE_DIR="${ccachedir}"
217 cd ${hversion} || exit 1
220 if [ X"${testenvironment}" != X ] ; then
221 makecheckenv="${makecheckenv} TESTS_ENVIRONMENT=\"${testenvironment}\""
224 mkdir socket_wrapper_dir
225 SOCKET_WRAPPER_DIR=`pwd`/socket_wrapper_dir
226 export SOCKET_WRAPPER_DIR
228 echo "Configuring and building ($hversion)"
229 echo "./configure --enable-socket-wrapper ${confflags}" > ab.txt
230 ./configure --enable-socket-wrapper ${confflags} >> ab.txt 2>&1
231 if [ $? != 0 ] ; then
232 echo Configure failed
233 status=${status:-configure}
235 echo make all >> ab.txt
236 make all >> ab.txt 2>&1
237 if [ $? != 0 ] ; then
239 status=${status:-make all}
241 echo make check >> ab.txt
242 eval env $makecheckenv make check >> ab.txt 2>&1
243 if [ $? != 0 ] ; then
244 echo Make check failed
245 status=${status:-make check}
248 if [ "$distcheck" = yes ] ; then
249 echo make distcheck >> ab.txt
250 if [ $? != 0 ] ; then
251 echo Make check failed
252 status=${status:-make distcheck}
258 echo "done: ${status}"
260 if [ "X${resultdir}" != X ] ; then
261 cp ab.txt "${resultdir}/ab-${hversion}-${hostname}-${date}.txt"
264 if [ "X${noemail}" = X ] ; then
265 cat > email-header <<EOF
266 From: ${USER:-unknown-user}@${hostname}
267 To: <heimdal-build-log@it.su.se>
268 Subject: heimdal-build-log SPAM COOKIE
269 X-heimdal-build: kaka-till-love
271 Script-version: ${version}
272 Heimdal-version: ${hversion}
277 if [ "X$passhrase" != X ] ; then
278 cat >> email-header <<EOF
279 autobuild-passphrase: ${passhrase}
282 cat >> email-header <<EOF
283 ------L-O-G------------------------------------
286 cat email-header ab.txt | sendmail "${email}"
290 if [ X"$keeptree" != Xyes ] ; then