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.

118 lines
3.3KB

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