xenofarm.sh 5.98 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 38 39
pfx=`pwd`/pfx

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

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

42
# FIXME: Should we really insist on using GNU make?
43
# We may need /usr/local/bin to get GNU make
Niels Möller's avatar
Niels Möller committed
44
if make --version 2>/dev/null | grep GNU >/dev/null ; then : ; else
Niels Möller's avatar
Niels Möller committed
45
    if /usr/local/bin/make --version 2>/dev/null | grep GNU >/dev/null ; then
46 47 48 49 50 51 52 53 54 55 56
	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
57 58 59
# Export new value
export PATH

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

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

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

77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
logstart () {
    log "BEGIN $1"
}

logpass () {
    log "PASS"
}

logfail () {
    log "FAIL"
}

logwarn () {
    log "WARN $1"
}

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

125
cfgwarn () {
126
    egrep -i 'warning|\(w\)' r/cfglog.txt \
127
    | sed -e '/configure: WARNING:  Converted \. to /d' \
128
    > r/cfgwarn.txt
129 130
    warnings=`wc -l < r/cfgwarn.txt`
    if test $warnings -gt 0
131
    then
132 133 134 135
	logwarn $warnings
    else
	rm r/cfgwarn.txt
	logpass
136
    fi
137
}
138

139 140
makewarn () {
    # Use sed -e /RX/d to get rid of selected warnings.
141 142
    egrep -i 'warning|\(w\)' r/makelog.txt \
    > r/makewarn.txt
143 144
    warnings=`wc -l < r/makewarn.txt`
    if test $warnings -gt 0
145
    then
146
	logwarn $warnings
147 148
    else
	rm r/makewarn.txt
149
	logpass
150
    fi
151
}
152

153
ckprgwarn () {
154 155
    egrep -i 'warning|\(w\)|error' r/ckprglog.txt \
    > r/ckprgwarn.txt
156 157
    warnings=`wc -l < r/ckprgwarn.txt`
    if test $warnings -gt 0
158 159 160 161 162
    then
	egrep -i 'error' r/ckprgwarn.txt \
	> r/ckprgfail.txt
	if test `wc -l < r/ckprgfail.txt` -gt 0
	then
163
	    logfail
164 165
	else
	    rm r/ckprgfail.txt
166
	    logwarn $warnings
167 168 169
	fi
    else
	rm r/ckprgwarn.txt
170
	logpass
171
    fi
172 173 174 175 176 177 178 179 180
}


status=good

echo 'FORMAT 2' > r/mainlog.txt

dotask 1 "unzip" "" "gzip -d $BASE.tar.gz"
dotask 1 "unpack" "" "tar xf $BASE.tar"
181
dotask 1 "cfg" "cfgwarn" \
182
    "cd $BASE && ./configure $cfgargs"
183
dotask 1 "make" "makewarn" "cd $BASE && make $makeargs"
184 185 186 187 188

#
# "make check" requirements
#

189
dotask 1 "ckprg" "" "cd $BASE && make check"
190 191 192 193 194 195

# 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"
196 197
dotask 1 "install" "" "cd $BASE && make install"

198 199 200 201 202 203 204 205 206 207
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
208 209
dotask 1 "argpmake" "makewarn" "cd $BASE/src/argp && make $makeargs" argpstatus
dotask 1 "ckargp" "" "cd $BASE/src/argp && make check" argpstatus
210 211

dotask 1 "nettlecfg" "cfgwarn" "cd $BASE/src/nettle && ./configure $cfgargs" nettlestatus
212 213
dotask 1 "nettlemake" "makewarn" "cd $BASE/src/nettle && make $makeargs" nettlestatus
dotask 1 "cknettle" "" "cd $BASE/src/nettle && make check" nettlestatus
214

215 216 217 218
find pfx -type f -print | sort > r/installedfiles.txt
if test `wc -l < r/installedfiles.txt` -eq 0
then
    rm r/installedfiles.txt
219 220 221 222
fi

# Collect stuff.

223 224
timeecho Collecting results

225 226 227 228 229 230 231 232 233 234 235
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
236 237 238 239 240 241 242

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

243 244 245 246 247 248

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
249
make --version > r/makeversion.txt 2>&1 
250 251
type make >> r/makeversion.txt

252
cp buildid.txt r/buildid.txt
253 254 255 256 257

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

exit 0