xenofarm.sh 8.27 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
1 2 3 4 5 6 7 8
#! /bin/sh

# Driver the xenofarm test compilation. Used together with
# lsh-server.pike, source-transform.sh and result-parser.pike in
# the lsh xenofarm project.

# Loosely based on the xenofarm.sh script in lyskom-server.

9
# Copyright 2002, 2003 Niels Möller, Lysator Academic Computer Association 
Niels Möller's avatar
Niels Möller committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

cfgargs=
makeargs=
27 28
MAKE=make

Niels Möller's avatar
Niels Möller committed
29 30 31 32 33
while [ $# -gt 0 ]
do
  case "$1" in
      --cfg)    shift; cfgargs="$1"; shift;;
      --make)   shift; makeargs="$1"; shift;;
34
      --make-program)   shift; MAKE="$1"; shift;;
Niels Möller's avatar
Niels Möller committed
35 36 37 38
      *)        echo $0: unsupported argument $1 >&2; exit 1;;
  esac
done

39 40
pfx=`pwd`/pfx

41
# Disable the liboop shared libraries, to avoid libtool-related
42 43 44 45
# problems on AIX. And disable all extra adapters, to workaround the
# broken --disable-shared handling in liboop-1.0.

oopcfgargs="-C --prefix=$pfx --disable-shared --without-adns --without-readline --without-glib --without-tcl --without-www $cfgargs"
46

47
gmpcfgargs="-C --prefix=$pfx --disable-shared $cfgargs"
48

49
cfgargs="-C --with-include-path=$pfx/include:/usr/local/include --with-lib-path=$pfx/lib:/usr/local/lib --prefix=$pfx $cfgargs"
50

51 52 53 54 55 56 57 58 59
# Fix PATH for system where the default environment is broken

# We may need /usr/ccs/bin for ar
if type ar >/dev/null ; then : ; else
    if [ -x /usr/ccs/bin/ar ] ; then
	PATH="$PATH:/usr/ccs/bin"
    fi
fi

60 61 62
# Export new value
export PATH

63 64 65 66 67 68 69
# Are we using GNU make? If so, nettle's dependency tracking won't work.
cfgdepargs=''

if make --version 2>/dev/null | grep GNU >/dev/null ; then : ; else
    cfgdepargs='--disable-dependency-tracking'
fi

Niels Möller's avatar
Niels Möller committed
70 71 72 73 74 75 76
rm -rf r
mkdir r
exec > r/shlog.txt 2>&1

BASE=`echo lsh-*.tar.gz | sed 's/.tar.gz$//'`
VERS=`echo "$BASE" | sed 's/^lsh-//'`

77
LIBOOPDIST=`echo liboop-*.tar.gz`
Niels Möller's avatar
Niels Möller committed
78
LIBGMPDIST=`echo gmp-*.tar.gz`
79

80
timeecho () {
Niels Möller's avatar
Niels Möller committed
81
    # FIXME: Don't depend on GNU date
82
    echo `LC_ALL=C TZ=UTC date '+%Y-%m-%d %H:%M:%S'`: "$@"
83 84 85 86 87 88 89
}

log () {
    echo "$@" >> r/mainlog.txt
    date >> r/mainlog.txt
}

90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
logstart () {
    log "BEGIN $1"
}

logpass () {
    log "PASS"
}

logfail () {
    log "FAIL"
}

logwarn () {
    log "WARN $1"
}

106 107 108
dotask() {
    important="$1"
    task="$2"
109 110
    warnfunc="$3"
    cmd="$4"
111
    var=${5:-status}
112 113
    var_value=`eval echo '${'$var'}'`
    if test $var_value = good
114
    then
115
	logstart $task
116 117 118
        timeecho Begin $task
        if sh -c "$cmd" > r/${task}log.txt 2>&1
        then
119 120 121 122 123 124
	    if [ -z "$warnfunc" ]
	    then
	        logpass
	    else
	        $warnfunc
	    fi
125 126 127 128
        else
	    timeecho FAIL: $task
	    if [ $important = 1 ]
	    then
129
	        eval $var=${task}-failed
130
	    fi
131 132
	    logfail
	fi
133
    else
134
	echo status $var_value makes it impossible/unnecessary to perform this step \
135 136 137 138
	    > r/${task}log.txt
    fi
}

139
cfgwarn () {
140 141 142
    logfile="r/${task}log.txt"
    warnfile="r/${task}warn.txt"
    egrep -i 'warning|\(w\)' "$logfile" \
143
    | sed -e '/configure: WARNING: No scheme implementation found/d' \
144 145
    > "$warnfile"
    warnings=`wc -l < $warnfile`
146
    if test $warnings -gt 0
147
    then
148 149
	logwarn $warnings
    else
150
	rm "$warnfile"
151
	logpass
152
    fi
153
}
154

155
makewarn () {
156 157
    logfile="r/${task}log.txt"
    warnfile="r/${task}warn.txt"
158
    # Use sed -e /RX/d to get rid of selected warnings.
159 160 161
    egrep -i 'warning|\(w\)' "$logfile" \
    > "$warnfile"
    warnings=`wc -l < $warnfile`
162
    if test $warnings -gt 0
163
    then
164
	logwarn $warnings
165
    else
166
	rm "$warnfile"
167
	logpass
168
    fi
169
}
170

171
ckprgwarn () {
172 173 174
    logfile="r/${task}log.txt"
    warnfile="r/${task}warn.txt"
    failfile="r/${task}fail.txt"
175

176 177 178
    egrep -i 'warning|\(w\)|error' "$logfile" \
    > "$warnfile"
    warnings=`wc -l < $warnfile`
179
    if test $warnings -gt 0
180
    then
181 182 183
	egrep -i 'error' "$warnfile" \
	> "$failfile"
	if test `wc -l < $failfile` -gt 0
184
	then
185
	    logfail
186
	else
187
	    rm "$failfile"
188
	    logwarn $warnings
189 190
	fi
    else
191
	rm "$warnfile"
192
	logpass
193
    fi
194 195 196 197 198 199 200
}


status=good

echo 'FORMAT 2' > r/mainlog.txt

201 202 203 204 205 206 207 208
if [ -f $LIBOOPDIST ] ; then
  # Install liboop in $pfx, before trying lsh
  LIBOOPBASE=`echo $LIBOOPDIST | sed 's/.tar.gz$//'`
  liboopstatus=good
else
  liboopstatus=skip
fi

209
if [ -f $LIBGMPDIST ] ; then
210
  LIBGMPBASE=`echo $LIBGMPDIST | sed 's/.tar.gz$//'`
211 212 213 214 215 216 217 218 219
  # Crude check if gmp-3.1 or later is installed. If not, install i $pfx.
  libgmpstatus=good
  for d in /usr/local/include /usr/include/ ; do
    if [ -f $d/gmp.h ] ; then
      echo gmp.h location: $d/gmp.h
      if grep mpz_getlimbn $d/gmp.h ; then
        libgmpstatus=skip
      fi
      break
220
    fi
221
  done
222 223 224 225
else
  libgmpstatus=skip
fi

226
dotask 1 "oopunzip" "" "gzip -d $LIBOOPBASE.tar.gz" liboopstatus
227
dotask 1 "oopunpack" "" "tar xf $LIBOOPBASE.tar" liboopstatus
228
dotask 1 "oopcfg" "cfgwarn" "cd $LIBOOPBASE && ./configure $oopcfgargs" liboopstatus
229 230 231
dotask 1 "oopmake" "makewarn" "cd $LIBOOPBASE && $MAKE" liboopstatus
dotask 0 "oopcheck" "makewarn" "cd $LIBOOPBASE && $MAKE check" liboopstatus
dotask 1 "oopinstall" "makewarn" "cd $LIBOOPBASE && $MAKE install" liboopstatus
232

233 234 235 236 237 238 239
dotask 1 "gmpunzip" "" "gzip -d $LIBGMPBASE.tar.gz" libgmpstatus
dotask 1 "gmpunpack" "" "tar xf $LIBGMPBASE.tar" libgmpstatus
dotask 1 "gmpcfg" "cfgwarn" "cd $LIBGMPBASE && ./configure $gmpcfgargs" libgmpstatus
dotask 1 "gmpmake" "makewarn" "cd $LIBGMPBASE && $MAKE" libgmpstatus
dotask 0 "gmpcheck" "makewarn" "cd $LIBGMPBASE && $MAKE check" libgmpstatus
dotask 1 "gmpinstall" "makewarn" "cd $LIBGMPBASE && $MAKE install" libgmpstatus

240 241
dotask 1 "unzip" "" "gzip -d $BASE.tar.gz"
dotask 1 "unpack" "" "tar xf $BASE.tar"
242
dotask 1 "cfg" "cfgwarn" \
243
    "cd $BASE && ./configure $cfgargs $cfgdepargs"
244
dotask 1 "make" "makewarn" "cd $BASE && $MAKE $makeargs"
245 246 247 248 249

#
# "make check" requirements
#

250
dotask 1 "ckprg" "" "cd $BASE && $MAKE check"
251 252 253 254 255

# FIXME: run distcheck.
# A problem is that make distcheck leaves some write-protected directories that
# can't be deleted with rm -rf

256 257
# dotask 0 "ckdist" "" "cd $BASE && $MAKE distcheck"
dotask 1 "install" "" "cd $BASE && $MAKE install"
258

259 260 261 262 263 264 265 266 267
if test $status = cfg-failed
then
    argpstatus=good
    nettlestatus=good
else
    argpstatus=skip
    nettlestatus=skip
fi

268 269 270
dotask 1 "argpcfg" "cfgwarn" "cd $BASE/argp && ./configure $cfgargs" argpstatus
dotask 1 "argpmake" "makewarn" "cd $BASE/argp && $MAKE $makeargs" argpstatus
dotask 1 "ckargp" "" "cd $BASE/argp && $MAKE check" argpstatus
271

272 273 274
dotask 1 "nettlecfg" "cfgwarn" "cd $BASE/nettle && ./configure $cfgargs $cfgdepargs" nettlestatus
dotask 1 "nettlemake" "makewarn" "cd $BASE/nettle && $MAKE $makeargs" nettlestatus
dotask 1 "cknettle" "" "cd $BASE/nettle && $MAKE check" nettlestatus
275

276 277 278 279
find pfx -type f -print | sort > r/installedfiles.txt
if test `wc -l < r/installedfiles.txt` -eq 0
then
    rm r/installedfiles.txt
280 281 282 283
fi

# Collect stuff.

284 285
timeecho Collecting results

286 287
cp $BASE/config.cache r/configcache.txt
cp $BASE/config.log r/configlog.txt
288 289 290 291
cp $BASE/argp/config.log r/argpconfiglog.txt
cp $BASE/argp/config.h r/argpconfig-h.txt
cp $BASE/nettle/config.log r/nettleconfiglog.txt
cp $BASE/nettle/config.h r/nettleconfig-h.txt
292 293
cp $BASE/src/sftp/config.log r/sftpconfiglog.txt
cp $BASE/src/sftp/config.h r/sftpconfig-h.txt
294 295
cp $BASE/spki/config.log r/spkiconfiglog.txt
cp $BASE/spki/config.h r/spkiconfig-h.txt
296
cp $BASE/config.h r/config-h.txt
297

298 299 300
cp $LIBOOPBASE/config.cache r/oopconfigcache.txt
cp $LIBOOPBASE/config.log r/oopconfiglog.txt

301 302 303
cp $LIBGMPBASE/config.cache r/gmpconfigcache.txt
cp $LIBGMPBASE/config.log r/gmpconfiglog.txt

304 305 306 307 308 309
find $BASE -name core -print > r/corefiles.txt
if test `wc -l < r/corefiles.txt` -eq 0
then
    rm r/corefiles.txt
fi

310 311 312 313 314
env > r/environ.txt
echo $PATH > r/path.txt
makeinfo --version > r/makeinfo.txt
type makeinfo >> r/makeinfo.txt 2>&1

315 316
$MAKE --version > r/makeversion.txt 2>&1 
type $MAKE >> r/makeversion.txt
317

318 319
ls -lR $pfx > r/pfxcontents.txt

320
cp buildid.txt r/buildid.txt
321 322 323 324 325

(cd r && tar cf - *) > xenofarm_result.tar
gzip -1 xenofarm_result.tar

exit 0