fate.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 --quiet --force && git reset --quiet --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. ${ignore_tests:+--ignore-tests="$ignore_tests"} \
  42. ${arch:+--arch=$arch} \
  43. ${cpu:+--cpu="$cpu"} \
  44. ${toolchain:+--toolchain="$toolchain"} \
  45. ${cross_prefix:+--cross-prefix="$cross_prefix"} \
  46. ${as:+--as="$as"} \
  47. ${cc:+--cc="$cc"} \
  48. ${ld:+--ld="$ld"} \
  49. ${target_os:+--target-os="$target_os"} \
  50. ${sysroot:+--sysroot="$sysroot"} \
  51. ${target_exec:+--target-exec="$target_exec"} \
  52. ${target_path:+--target-path="$target_path"} \
  53. ${target_samples:+--target-samples="$target_samples"} \
  54. ${extra_cflags:+--extra-cflags="$extra_cflags"} \
  55. ${extra_ldflags:+--extra-ldflags="$extra_ldflags"} \
  56. ${extra_libs:+--extra-libs="$extra_libs"} \
  57. ${extra_conf}
  58. )
  59. compile()(
  60. cd ${build} || return
  61. ${make} ${makeopts} && ${make} install
  62. )
  63. fate()(
  64. test "$build_only" = "yes" && return
  65. cd ${build} || return
  66. ${make} ${makeopts_fate-${makeopts}} -k fate
  67. )
  68. clean(){
  69. rm -rf ${build} ${inst}
  70. }
  71. report(){
  72. date=$(date -u +%Y%m%d%H%M%S)
  73. echo "fate:1:${date}:${slot}:${version}:$1:$2:${branch}:${comment}" >report
  74. cat ${build}/ffbuild/config.fate >>report
  75. 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
  76. test -n "$fate_recv" && $tar report *.log | gzip | $fate_recv
  77. }
  78. fail(){
  79. report "$@"
  80. clean
  81. exit
  82. }
  83. mkdir -p ${workdir} || die "Error creating ${workdir}"
  84. lock ${workdir} || die "${workdir} locked"
  85. cd ${workdir} || die "cd ${workdir} failed"
  86. src=${workdir}/src
  87. : ${build:=${workdir}/build}
  88. : ${inst:=${workdir}/install}
  89. test -d "$src" && update || checkout || die "Error fetching source"
  90. cd ${workdir}
  91. version=$(${src}/ffbuild/version.sh ${src})
  92. test "$version" = "$(cat version-$slot 2>/dev/null)" && exit 0
  93. echo ${version} >version-$slot
  94. rm -rf "${build}" *.log
  95. mkdir -p ${build}
  96. configure >configure.log 2>&1 || fail 3 "error configuring"
  97. compile >compile.log 2>&1 || fail 2 "error compiling"
  98. fate >test.log 2>&1 || fail 1 "error testing"
  99. report 0 success
  100. clean