You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.9KB

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