2
0

build_patch.sh 971 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. set -e -o pipefail
  3. usage () {
  4. printf "usage: %s [-u <remote>] [-r <ref>] [<patch-urls> ...]\n" "$0" >&2
  5. }
  6. err () {
  7. printf "error: %s\n" "$1" >&2
  8. exit 1
  9. }
  10. remote=origin
  11. ref=origin/master
  12. dopull=true
  13. while getopts "hnr:u:" o; do
  14. case "$o" in
  15. h) usage; exit 0 ;;
  16. n) dopull=false ;;
  17. r) ref="$OPTARG" ;;
  18. u) remote="$OPTARG" ;;
  19. esac
  20. done
  21. shift $(($OPTIND-1))
  22. if ! which git >/dev/null; then
  23. printf "error: please install git\n">&2
  24. exit 1; fi
  25. if ! which wget >/dev/null; then
  26. printf "error: please install wget\n">&2
  27. exit 1; fi
  28. now=$(date -u +%Y%m%dT%H%M%SZ)
  29. git clean -fdx || err "failed"
  30. git reset --hard "$ref" \
  31. || err "reset failed"
  32. $dopull && (git pull "$remote" || err "failed to pull")
  33. for patch in "$@"; do
  34. wget -O - "$patch" | git am
  35. done
  36. printf '# Building FreeSWITCH %s\n' "$(git describe HEAD)" \
  37. > ${now}-fsbuild.log
  38. (./bootstrap.sh && ./configure -C && make VERBOSE=1) 2>&1 \
  39. | tee -a ${now}-fsbuild.log