]> git.ozlabs.org Git - next-scripts/blob - do_revert
propogate NEXT_BUILD_HOST/DIR everywhere
[next-scripts] / do_revert
1 #!/bin/bash
2
3 LOG_FILE="../merge.log"
4 build_host="ka2"
5 build_dir="/scratch/sfr/next"
6 build_cmd="bin/build_next"
7 [ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
8 [ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
9
10 no_build=false
11 [ "$1" = "-n" ] && {
12         shift
13         no_build=true
14 }
15
16 rev=$1
17 shift
18
19 [ -n "$1" ] && {
20         build_host="$1"
21         shift
22 }
23 [ -n "$1" ] && {
24         build_dir="$1"
25         shift
26 }
27
28 export NEXT_BUILD_HOST="$build_host"
29 export NEXT_BUILD_DIR="$build_dir"
30
31 log()
32 {
33         echo "$@" | tee -a $LOG_FILE
34 }
35
36 execute()
37 {
38         log "$" $@
39         $@ 2>&1 | tee -a $LOG_FILE
40         return ${PIPESTATUS[0]}
41 }
42
43 GIT_EDITOR=: execute git revert $rev || exit 1
44
45 $no_build && exit 0
46
47 git push -f "$build_host":"$build_dir" master:refs/heads/next || {
48         echo git push failed 1>&2
49         bash -i || exit
50 }
51 ssh "$build_host" "$build_cmd" || {
52         echo Build failed 1>&2
53         bash -i || exit
54 }
55
56 exit 0