]> git.ozlabs.org Git - next-scripts/blob - merge_akpm
propogate NEXT_BUILD_HOST/DIR everywhere
[next-scripts] / merge_akpm
1 #!/bin/bash
2
3 LOG_FILE="../merge.log"
4 SHA1_FILE="../SHA1s"
5 build_host="ka2"
6 build_dir="/scratch/sfr/next"
7 build_cmd="bin/build_next"
8 [ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
9 [ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
10
11 today="$(date '+%Y%m%d')"
12
13 no_build=false
14
15 [ "$1" = "-n" ] && {
16         shift
17         no_build=true
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 cpwd=../next
44
45 git branch -f akpm-current/current akpm/current
46
47 git branch -f akpm/base HEAD
48
49 hlog=$(git log -1 --oneline akpm-current/current) 2>/dev/null
50 log Merging akpm-current/current "($hlog)"
51 execute git merge akpm-current/current || {
52         echo Merge failed 1>&2
53         echo $h >>../merge.debug
54         git diff >>../merge.debug 2>&1
55         git diff 2>&1 | egrep -q '<<<<<|^\*' && {
56                 bash -i || exit
57         }
58         GIT_EDITOR=: execute git commit -v -a
59         execute git diff -M --stat --summary 'HEAD^..'
60 }
61 printf "%s\t%s\n" akpm-current $(git show-ref --hash akpm-current/current) >> $SHA1_FILE
62
63 execute git clone -s -l -n -q . ../rebase-tmp || {
64         echo Clone failed 1>&2
65         bash -i || exit
66 }
67 log '$' cd ../rebase-tmp
68 cd ../rebase-tmp
69 execute git checkout -b akpm remotes/origin/akpm/master || {
70         echo Checkout of remotes/origin/akpm/master failed 1>&2
71         bash -i || exit
72 }
73 execute git rebase --onto master remotes/origin/akpm/master-base || {
74         echo Rebase failed 1>&2
75         bash -i || exit
76 }
77 echo "fix up?"
78 bash -i
79 log '$' cd $cpwd
80 cd $cpwd
81 execute git fetch -f ../rebase-tmp akpm:akpm/master || {
82         echo Fetch of akpm/master failed 1>&2
83         bash -i || exit
84 }
85 execute rm -rf ../rebase-tmp
86
87 git branch -f akpm/master-base HEAD
88
89 log Merging akpm/master '('$(git log -1 --oneline akpm/master)')'
90 execute git merge --no-ff akpm/master || {
91         echo Merge failed 1>&2
92         bash -i || exit
93 }
94 printf "%s\t\t%s\n" akpm $(git show-ref --hash akpm/master) >> $SHA1_FILE
95
96 [ -f "../merge-fixes/akpm" ] && {
97         for p in $(cat "../merge-fixes/akpm"); do
98                 $(dirname $0)/merge_fix -n "$p" || {
99                         bash -i || exit
100                 }
101         done
102 }
103 [ -x "../pre-build/akpm" ] && {
104         "../pre-build/akpm" || bash -i || exit
105 }
106
107 $no_build && exit 0
108
109 git push -f "$build_host":"$build_dir" master:refs/heads/next || {
110         echo git push failed 1>&2
111         bash -i || exit
112 }
113 ssh "$build_host" "$build_cmd" || {
114         echo Build failed 1>&2
115         bash -i || exit
116 }
117
118 exit 0