xenofarm.sh 6.97 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#! /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.

# Copyright 2002, 2003 Niels Mller, Lysator Academic Computer Association 
# 
# 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=
while [ $# -gt 0 ]
do
  case "$1" in
      --cfg)    shift; cfgargs="$1"; shift;;
      --make)   shift; makeargs="$1"; shift;;
      *)        echo $0: unsupported argument $1 >&2; exit 1;;
  esac
done

36 37
pfx=`pwd`/pfx

38 39
oopcfgargs="-C --prefix=$pfx $cfgargs"
cfgargs="-C --with-include-path=/usr/local/include:$pfx/include --with-lib-path=/usr/local/lib:$pfx/lib --prefix=$pfx $cfgargs"
40

41 42
# Fix PATH for system where the default environment is broken

43
# FIXME: Should we really insist on using GNU make?
44
# We may need /usr/local/bin to get GNU make
Niels Möller's avatar
Niels Möller committed
45
if make --version 2>/dev/null | grep GNU >/dev/null ; then : ; else
Niels Möller's avatar
Niels Möller committed
46
    if /usr/local/bin/make --version 2>/dev/null | grep GNU >/dev/null ; then
47 48 49 50 51 52 53 54 55 56 57
	PATH="/usr/local/bin:$PATH"
    fi
fi

# 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

Niels Möller's avatar
Niels Möller committed
58 59 60
# Export new value
export PATH

Niels Möller's avatar
Niels Möller committed
61 62 63 64 65 66 67
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-//'`

68 69
LIBOOPDIST=`echo liboop-*.tar.gz`

70
timeecho () {
Niels Möller's avatar
Niels Möller committed
71
    # FIXME: Don't depend on GNU date
72
    echo `LC_ALL=C TZ=UTC date '+%Y-%m-%d %H:%M:%S'`: "$@"
73 74 75 76 77 78 79
}

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

80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
logstart () {
    log "BEGIN $1"
}

logpass () {
    log "PASS"
}

logfail () {
    log "FAIL"
}

logwarn () {
    log "WARN $1"
}

96 97 98
dotask() {
    important="$1"
    task="$2"
99 100
    warnfunc="$3"
    cmd="$4"
101
    var=${5:-status}
102
    if test `eval echo '${'$var'}'` = good
103
    then
104
	logstart $task
105 106 107
        timeecho Begin $task
        if sh -c "$cmd" > r/${task}log.txt 2>&1
        then
108 109 110 111 112 113
	    if [ -z "$warnfunc" ]
	    then
	        logpass
	    else
	        $warnfunc
	    fi
114 115 116 117
        else
	    timeecho FAIL: $task
	    if [ $important = 1 ]
	    then
118
	        eval $var=${task}-failed
119
	    fi
120 121
	    logfail
	fi
122
    else
123
	echo status $status makes it impossible/unnecessary to perform this step \
124 125 126 127
	    > r/${task}log.txt
    fi
}

128
cfgwarn () {
129 130 131
    logfile="r/${task}log.txt"
    warnfile="r/${task}warn.txt"
    egrep -i 'warning|\(w\)' "$logfile" \
132
    | sed -e '/configure: WARNING:  Converted \. to /d' \
133 134
    > "$warnfile"
    warnings=`wc -l < $warnfile`
135
    if test $warnings -gt 0
136
    then
137 138
	logwarn $warnings
    else
139
	rm "$warnfile"
140
	logpass
141
    fi
142
}
143

144
makewarn () {
145 146
    logfile="r/${task}log.txt"
    warnfile="r/${task}warn.txt"
147
    # Use sed -e /RX/d to get rid of selected warnings.
148 149 150
    egrep -i 'warning|\(w\)' "$logfile" \
    > "$warnfile"
    warnings=`wc -l < $warnfile`
151
    if test $warnings -gt 0
152
    then
153
	logwarn $warnings
154
    else
155
	rm "$warnfile"
156
	logpass
157
    fi
158
}
159

160
ckprgwarn () {
161 162 163
    logfile="r/${task}log.txt"
    warnfile="r/${task}warn.txt"
    failfile="r/${task}fail.txt"
164

165 166 167
    egrep -i 'warning|\(w\)|error' "$logfile" \
    > "$warnfile"
    warnings=`wc -l < $warnfile`
168
    if test $warnings -gt 0
169
    then
170 171 172
	egrep -i 'error' "$warnfile" \
	> "$failfile"
	if test `wc -l < $failfile` -gt 0
173
	then
174
	    logfail
175
	else
176
	    rm "$failfile"
177
	    logwarn $warnings
178 179
	fi
    else
180
	rm "$warnfile"
181
	logpass
182
    fi
183 184 185 186 187 188 189
}


status=good

echo 'FORMAT 2' > r/mainlog.txt

190 191 192 193 194 195 196 197 198
if [ -f $LIBOOPDIST ] ; then
  # Install liboop in $pfx, before trying lsh
  LIBOOPBASE=`echo $LIBOOPDIST | sed 's/.tar.gz$//'`
  liboopstatus=good
else
  liboopstatus=skip
fi

dotask 1 "oopunzip" "" "gzip -d $LIBOOPBASE.tar.gz" liboopstatus
199
dotask 1 "oopunpack" "" "tar xf $LIBOOPBASE.tar" liboopstatus
200
dotask 1 "oopcfg" "cfgwarn" "cd $LIBOOPBASE && ./configure $oopcfgargs" liboopstatus
201 202 203
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
204

205 206
dotask 1 "unzip" "" "gzip -d $BASE.tar.gz"
dotask 1 "unpack" "" "tar xf $BASE.tar"
207
dotask 1 "cfg" "cfgwarn" \
208
    "cd $BASE && ./configure $cfgargs"
209
dotask 1 "make" "makewarn" "cd $BASE && make $makeargs"
210 211 212 213 214

#
# "make check" requirements
#

215
dotask 1 "ckprg" "" "cd $BASE && make check"
216 217 218 219 220 221

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

# dotask 0 "ckdist" "" "cd $BASE && make distcheck"
222 223
dotask 1 "install" "" "cd $BASE && make install"

224 225 226 227 228 229 230 231 232 233
if test $status = cfg-failed
then
    argpstatus=good
    nettlestatus=good
else
    argpstatus=skip
    nettlestatus=skip
fi

dotask 1 "argpcfg" "cfgwarn" "cd $BASE/src/argp && ./configure $cfgargs" argpstatus
234 235
dotask 1 "argpmake" "makewarn" "cd $BASE/src/argp && make $makeargs" argpstatus
dotask 1 "ckargp" "" "cd $BASE/src/argp && make check" argpstatus
236 237

dotask 1 "nettlecfg" "cfgwarn" "cd $BASE/src/nettle && ./configure $cfgargs" nettlestatus
238 239
dotask 1 "nettlemake" "makewarn" "cd $BASE/src/nettle && make $makeargs" nettlestatus
dotask 1 "cknettle" "" "cd $BASE/src/nettle && make check" nettlestatus
240

241 242 243 244
find pfx -type f -print | sort > r/installedfiles.txt
if test `wc -l < r/installedfiles.txt` -eq 0
then
    rm r/installedfiles.txt
245 246 247 248
fi

# Collect stuff.

249 250
timeecho Collecting results

251 252 253 254 255 256 257 258 259 260 261
cp $BASE/config.cache r/configcache.txt
cp $BASE/config.log r/configlog.txt
cp $BASE/src/argp/config.log r/argpconfiglog.txt
cp $BASE/src/argp/config.h r/argpconfig-h.txt
cp $BASE/src/nettle/config.log r/nettleconfiglog.txt
cp $BASE/src/nettle/config.h r/nettleconfig-h.txt
cp $BASE/src/sftp/config.log r/sftpconfiglog.txt
cp $BASE/src/sftp/config.h r/sftpconfig-h.txt
cp $BASE/src/spki/config.log r/spkiconfiglog.txt
cp $BASE/src/spki/config.h r/spkiconfig-h.txt
cp $BASE/config.h r/config-h.txt
262

263 264 265 266
cp $LIBOOPBASE/config.cache r/oopconfigcache.txt
cp $LIBOOPBASE/config.h r/oopconfig-h.txt
cp $LIBOOPBASE/config.log r/oopconfiglog.txt

267 268 269 270 271 272
find $BASE -name core -print > r/corefiles.txt
if test `wc -l < r/corefiles.txt` -eq 0
then
    rm r/corefiles.txt
fi

273 274 275 276 277
env > r/environ.txt
echo $PATH > r/path.txt
makeinfo --version > r/makeinfo.txt
type makeinfo >> r/makeinfo.txt 2>&1

Niels Möller's avatar
Niels Möller committed
278
make --version > r/makeversion.txt 2>&1 
279 280
type make >> r/makeversion.txt

281
cp buildid.txt r/buildid.txt
282 283 284 285 286

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

exit 0