1#! /bin/sh 2 3config=$1 4 5die(){ 6 echo "$@" 7 exit 1 8} 9 10test -r "$config" || die "usage: fate.sh <config>" 11 12workdir=$(cd $(dirname $config) && pwd) 13make=make 14tar='tar c' 15 16. "$config" 17 18test -n "$slot" || die "slot not specified" 19test -n "$repo" || die "repo not specified" 20test -d "$samples" || die "samples location not specified" 21 22: ${branch:=master} 23 24lock(){ 25 lock=$1/fate.lock 26 (set -C; exec >$lock) 2>/dev/null || return 27 trap 'rm $lock' EXIT 28} 29 30checkout(){ 31 case "$repo" in 32 file:*|/*) src="${repo#file:}" ;; 33 git:*) git clone --quiet --branch "$branch" "$repo" "$src" ;; 34 esac 35} 36 37update()( 38 cd ${src} || return 39 case "$repo" in 40 git:*) git fetch --quiet --force && git reset --quiet --hard "origin/$branch" ;; 41 esac 42) 43 44configure()( 45 cd ${build} || return 46 ${shell} ${src}/configure \ 47 --prefix="${inst}" \ 48 --samples="${samples}" \ 49 --enable-gpl \ 50 --enable-memory-poisoning \ 51 ${ignore_tests:+--ignore-tests="$ignore_tests"} \ 52 ${arch:+--arch=$arch} \ 53 ${cpu:+--cpu="$cpu"} \ 54 ${toolchain:+--toolchain="$toolchain"} \ 55 ${cross_prefix:+--cross-prefix="$cross_prefix"} \ 56 ${as:+--as="$as"} \ 57 ${cc:+--cc="$cc"} \ 58 ${ld:+--ld="$ld"} \ 59 ${target_os:+--target-os="$target_os"} \ 60 ${sysroot:+--sysroot="$sysroot"} \ 61 ${target_exec:+--target-exec="$target_exec"} \ 62 ${target_path:+--target-path="$target_path"} \ 63 ${target_samples:+--target-samples="$target_samples"} \ 64 ${extra_cflags:+--extra-cflags="$extra_cflags"} \ 65 ${extra_ldflags:+--extra-ldflags="$extra_ldflags"} \ 66 ${extra_libs:+--extra-libs="$extra_libs"} \ 67 ${extra_conf} 68) 69 70compile()( 71 cd ${build} || return 72 ${make} ${makeopts} && ${make} install 73) 74 75fate()( 76 test "$build_only" = "yes" && return 77 cd ${build} || return 78 ${make} ${makeopts_fate-${makeopts}} -k fate 79) 80 81clean(){ 82 rm -rf ${build} ${inst} 83} 84 85report(){ 86 date=$(date -u +%Y%m%d%H%M%S) 87 echo "fate:1:${date}:${slot}:${version}:$1:$2:${branch}:${comment}" >report 88 cat ${build}/ffbuild/config.fate >>report 89 cat ${build}/tests/data/fate/*.rep >>report 2>/dev/null || for i in ${build}/tests/data/fate/*.rep ; do cat "$i" >>report 2>/dev/null; done 90 test -n "$fate_recv" && $tar report *.log | gzip | $fate_recv 91} 92 93fail(){ 94 report "$@" 95 clean 96 exit 97} 98 99mkdir -p ${workdir} || die "Error creating ${workdir}" 100lock ${workdir} || die "${workdir} locked" 101cd ${workdir} || die "cd ${workdir} failed" 102 103src=${workdir}/src 104: ${build:=${workdir}/build} 105: ${inst:=${workdir}/install} 106 107test -d "$src" && update || checkout || die "Error fetching source" 108 109cd ${workdir} 110 111version=$(${src}/ffbuild/version.sh ${src}) 112test "$version" = "$(cat version-$slot 2>/dev/null)" && exit 0 113echo ${version} >version-$slot 114 115rm -rf "${build}" *.log 116mkdir -p ${build} 117 118configure >configure.log 2>&1 || fail 3 "error configuring" 119compile >compile.log 2>&1 || fail 2 "error compiling" 120fate >test.log 2>&1 || fail 1 "error testing" 121report 0 success 122clean 123