]> git.ozlabs.org Git - next-scripts/blob - merge_fix
Add more tools
[next-scripts] / merge_fix
1 #!/bin/bash
2
3 LOG_FILE="../merge.log"
4 build_host="sprygo"
5 build_dir="/scratch/sfr/next"
6 build_cmd="bin/build_next"
7
8 no_build=false
9 [ "$1" = "-n" ] && {
10         shift
11         no_build=true
12 }
13 patch="$1"
14 [ -f "$patch" ] || {
15         echo "patch does not exist" 1>&2
16         exit 1
17 }
18 [ -n "$2" ] && build_host="$2"
19
20 log()
21 {
22         echo "$@" | tee -a $LOG_FILE
23 }
24
25 execute()
26 {
27         log "$" $@
28         $@ 2>&1 | tee -a $LOG_FILE
29         return ${PIPESTATUS[0]}
30 }
31
32 execute git am -3 "$patch" || {
33         echo "git am failed" 1>&2
34         bash -i || exit
35 }
36 GIT_EDITOR=: execute git reset 'HEAD^' || {
37         echo "git reset failed" 1>&2
38         bash -i || exit
39 }
40 GIT_EDITOR=: execute git commit -v -a --amend || {
41         echo "git commit failed" 1>&2
42         bash -i || exit
43 }
44
45 $no_build && exit 0
46
47 rsync -avH --exclude .git --delete . "$build_host":"$build_dir"/. || {
48         echo Rsync failed 1>&2
49         bash -i || exit
50 }
51
52 echo "Building using $build_cmd on $build_host"
53 ssh "$build_host" "$build_cmd" || {
54         echo Build failed 1>&2
55         bash -i || exit
56 }
57
58 exit 0