]> git.ozlabs.org Git - next-scripts/blob - merge_akpm
use the local do_build script
[next-scripts] / merge_akpm
1 #!/bin/bash
2
3 bin_dir="$(dirname $0)"
4
5 LOG_FILE="../merge.log"
6 SHA1_FILE="../SHA1s"
7 build_host="ka2"
8 build_dir="/scratch/sfr/next"
9 [ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
10 [ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
11
12 today="$(date '+%Y%m%d')"
13
14 no_build=false
15
16 [ "$1" = "-n" ] && {
17         shift
18         no_build=true
19 }
20 [ -n "$1" ] && {
21         build_host="$1"
22         shift
23 }
24 [ -n "$1" ] && {
25         build_dir="$1"
26         shift
27 }
28
29 export NEXT_BUILD_HOST="$build_host"
30 export NEXT_BUILD_DIR="$build_dir"
31
32 log()
33 {
34         echo "$@" | tee -a $LOG_FILE
35 }
36
37 execute()
38 {
39         log "$" $@
40         $@ 2>&1 | tee -a $LOG_FILE
41         return ${PIPESTATUS[0]}
42 }
43
44 cpwd=../next
45
46 git branch -f akpm-current/current akpm/current
47
48 git branch -f akpm/base HEAD
49
50 old_head=$(git rev-parse HEAD)
51 hlog=$(git log -1 --oneline akpm-current/current) 2>/dev/null
52 log Merging akpm-current/current "($hlog)"
53 execute git merge akpm-current/current || {
54         echo Merge failed 1>&2
55         echo $h >>../merge.debug
56         git diff >>../merge.debug 2>&1
57         git diff 2>&1 | egrep -q '<<<<<|^\*' && {
58                 bash -i || exit
59         }
60         GIT_EDITOR=: execute git commit -v -a
61         execute git diff -M --stat --summary 'HEAD^..'
62 }
63 printf "%s\t%s\n" akpm-current $(git show-ref --hash akpm-current/current) >> $SHA1_FILE
64
65 [ -f "../merge-fixes/akpm-current" ] && {
66         for p in $(cat "../merge-fixes/akpm-current"); do
67                 $(dirname $0)/merge_fix -n "$p" || {
68                         bash -i || exit
69                 }
70         done
71 }
72 [ -x "../pre-build/akpm-current" ] && {
73         "../pre-build/akpm-current" || bash -i || exit
74 }
75
76 new_head=$(git rev-parse HEAD)
77
78 $no_build ||
79         [ "$old_head" = "$new_head" ] ||
80         [ "$(git diff ${old_head}.. | wc -c)" -eq 0 ] || {
81
82         git push -f "$build_host":"$build_dir" master:refs/heads/next || {
83                 echo git push failed 1>&2
84                 bash -i || exit
85         }
86         "$bin_dir/do_build" || {
87                 echo Build failed 1>&2
88                 bash -i || exit
89         }
90 }
91
92 execute git clone -s -l -n -q . ../rebase-tmp || {
93         echo Clone failed 1>&2
94         bash -i || exit
95 }
96 log '$' cd ../rebase-tmp
97 cd ../rebase-tmp
98 execute git checkout -b akpm remotes/origin/akpm/master || {
99         echo Checkout of remotes/origin/akpm/master failed 1>&2
100         bash -i || exit
101 }
102 execute git rebase --onto master remotes/origin/akpm/master-base || {
103         echo Rebase failed 1>&2
104         bash -i || exit
105 }
106 echo "fix up?"
107 bash -i
108 log '$' cd $cpwd
109 cd $cpwd
110 execute git fetch -f ../rebase-tmp akpm:akpm/master || {
111         echo Fetch of akpm/master failed 1>&2
112         bash -i || exit
113 }
114 execute rm -rf ../rebase-tmp
115
116 git branch -f akpm/master-base HEAD
117
118 old_head=$(git rev-parse HEAD)
119 log Merging akpm/master '('$(git log -1 --oneline akpm/master)')'
120 execute git merge --no-ff akpm/master || {
121         echo Merge failed 1>&2
122         bash -i || exit
123 }
124 printf "%s\t\t%s\n" akpm $(git show-ref --hash akpm/master) >> $SHA1_FILE
125
126 [ -f "../merge-fixes/akpm" ] && {
127         for p in $(cat "../merge-fixes/akpm"); do
128                 $(dirname $0)/merge_fix -n "$p" || {
129                         bash -i || exit
130                 }
131         done
132 }
133 [ -x "../pre-build/akpm" ] && {
134         "../pre-build/akpm" || bash -i || exit
135 }
136
137 new_head=$(git rev-parse HEAD)
138
139 $no_build ||
140         [ "$old_head" = "$new_head" ] ||
141         [ "$(git diff ${old_head}.. | wc -c)" -eq 0 ] || {
142
143         git push -f "$build_host":"$build_dir" master:refs/heads/next || {
144                 echo git push failed 1>&2
145                 bash -i || exit
146         }
147         "$bin_dir/do_build" || {
148                 echo Build failed 1>&2
149                 bash -i || exit
150         }
151 }
152
153 exit 0