]> git.ozlabs.org Git - next-scripts/blob - merge_akpm
do a build after mergeing akpm-current
[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 old_head=$(git rev-parse HEAD)
50 hlog=$(git log -1 --oneline akpm-current/current) 2>/dev/null
51 log Merging akpm-current/current "($hlog)"
52 execute git merge akpm-current/current || {
53         echo Merge failed 1>&2
54         echo $h >>../merge.debug
55         git diff >>../merge.debug 2>&1
56         git diff 2>&1 | egrep -q '<<<<<|^\*' && {
57                 bash -i || exit
58         }
59         GIT_EDITOR=: execute git commit -v -a
60         execute git diff -M --stat --summary 'HEAD^..'
61 }
62 printf "%s\t%s\n" akpm-current $(git show-ref --hash akpm-current/current) >> $SHA1_FILE
63
64 [ -f "../merge-fixes/akpm-current" ] && {
65         for p in $(cat "../merge-fixes/akpm-current"); do
66                 $(dirname $0)/merge_fix -n "$p" || {
67                         bash -i || exit
68                 }
69         done
70 }
71 [ -x "../pre-build/akpm-current" ] && {
72         "../pre-build/akpm-current" || bash -i || exit
73 }
74
75 new_head=$(git rev-parse HEAD)
76
77 $no_build ||
78         [ "$old_head" = "$new_head" ] ||
79         [ "$(git diff ${old_head}.. | wc -c)" -eq 0 ] || {
80
81         git push -f "$build_host":"$build_dir" master:refs/heads/next || {
82                 echo git push failed 1>&2
83                 bash -i || exit
84         }
85         ssh "$build_host" "$build_cmd" || {
86                 echo Build failed 1>&2
87                 bash -i || exit
88         }
89 }
90
91 execute git clone -s -l -n -q . ../rebase-tmp || {
92         echo Clone failed 1>&2
93         bash -i || exit
94 }
95 log '$' cd ../rebase-tmp
96 cd ../rebase-tmp
97 execute git checkout -b akpm remotes/origin/akpm/master || {
98         echo Checkout of remotes/origin/akpm/master failed 1>&2
99         bash -i || exit
100 }
101 execute git rebase --onto master remotes/origin/akpm/master-base || {
102         echo Rebase failed 1>&2
103         bash -i || exit
104 }
105 echo "fix up?"
106 bash -i
107 log '$' cd $cpwd
108 cd $cpwd
109 execute git fetch -f ../rebase-tmp akpm:akpm/master || {
110         echo Fetch of akpm/master failed 1>&2
111         bash -i || exit
112 }
113 execute rm -rf ../rebase-tmp
114
115 git branch -f akpm/master-base HEAD
116
117 old_head=$(git rev-parse HEAD)
118 log Merging akpm/master '('$(git log -1 --oneline akpm/master)')'
119 execute git merge --no-ff akpm/master || {
120         echo Merge failed 1>&2
121         bash -i || exit
122 }
123 printf "%s\t\t%s\n" akpm $(git show-ref --hash akpm/master) >> $SHA1_FILE
124
125 [ -f "../merge-fixes/akpm" ] && {
126         for p in $(cat "../merge-fixes/akpm"); do
127                 $(dirname $0)/merge_fix -n "$p" || {
128                         bash -i || exit
129                 }
130         done
131 }
132 [ -x "../pre-build/akpm" ] && {
133         "../pre-build/akpm" || bash -i || exit
134 }
135
136 new_head=$(git rev-parse HEAD)
137
138 $no_build ||
139         [ "$old_head" = "$new_head" ] ||
140         [ "$(git diff ${old_head}.. | wc -c)" -eq 0 ] || {
141
142         git push -f "$build_host":"$build_dir" master:refs/heads/next || {
143                 echo git push failed 1>&2
144                 bash -i || exit
145         }
146         ssh "$build_host" "$build_cmd" || {
147                 echo Build failed 1>&2
148                 bash -i || exit
149         }
150 }
151
152 exit 0