fate.sh 3.4 KB

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