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