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.

129 lines
3.0KB

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