fate.sh 3.0 KB

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