xenofarm.sh 5.35 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
# Fix PATH for system where the default environment is broken

# We may need /usr/local/bin to get GNU make
Niels Möller's avatar
Niels Möller committed
39
if make --version 2>/dev/null | grep GNU >/dev/null ; then : ; else
40 41 42 43 44 45 46 47 48 49 50 51
    if /usr/local/bin/make | grep GNU >/dev/null ; then
	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
52 53 54
# Export new value
export PATH

Niels Möller's avatar
Niels Möller committed
55 56 57 58 59 60 61
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-//'`

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

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

72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
logstart () {
    log "BEGIN $1"
}

logpass () {
    log "PASS"
}

logfail () {
    log "FAIL"
}

logwarn () {
    log "WARN $1"
}

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

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

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

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


pfx=`pwd`/pfx

status=good

echo 'FORMAT 2' > r/mainlog.txt

dotask 1 "unzip" "" "gzip -d $BASE.tar.gz"
dotask 1 "unpack" "" "tar xf $BASE.tar"
177 178
dotask 1 "cfg" "cfgwarn" \
    "cd $BASE && ./configure -C --with-include-path=/usr/local/include --with-lib-path=/usr/local/lib --prefix=$pfx $cfgargs"
Niels Möller's avatar
Niels Möller committed
179
dotask 1 "make" "makewarn" "cd $BASE && make -k $makeargs"
180 181 182 183 184

#
# "make check" requirements
#

185
dotask 0 "ckprg" "" "cd $BASE && make check"
186 187 188 189 190 191 192 193

# FIXME: run distcheck.
# FIXME: compare the contents of the distcheck-generated tar file
# with the one we distributed.
# 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"
194 195 196 197 198 199
dotask 1 "install" "" "cd $BASE && make install"

find pfx -type f -print | sort > r/installedfiles.txt
if test `wc -l < r/installedfiles.txt` -eq 0
then
    rm r/installedfiles.txt
200 201 202 203
fi

# Collect stuff.

204 205 206 207
timeecho Collecting results

mv $BASE/config.cache r/configcache.txt
mv $BASE/config.log r/configlog.txt
208
mv $BASE/src/argp/config.log r/argpconfiglog.txt
209
mv $BASE/src/argp/config.h r/argpconfig-h.txt
210
mv $BASE/src/nettle/config.log r/nettleconfiglog.txt
211
mv $BASE/src/nettle/config.h r/nettleconfig-h.txt
212
mv $BASE/src/sftp/config.log r/sftpconfiglog.txt
213
mv $BASE/src/sftp/config.h r/sftpconfig-h.txt
214
mv $BASE/src/spki/config.log r/spkiconfiglog.txt
215
mv $BASE/src/spki/config.h r/spkiconfig-h.txt
216 217 218 219 220 221 222 223
mv $BASE/config.h r/config-h.txt

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

224 225 226 227 228 229

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
230
make --version > r/makeversion.txt 2>&1 
231 232
type make >> r/makeversion.txt

233
mv buildid.txt r/buildid.txt
234 235 236 237 238

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

exit 0