fate.sh 3.5 KB

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