]> git.ozlabs.org Git - next-scripts/blob - merge_akpm
various updates
[next-scripts] / merge_akpm
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
8 today="$(date '+%Y%m%d')"
9
10 no_build=false
11 [ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
12 [ "$NEXT_BUILD_DIR" ] && build_host="$NEXT_BUILD_DIR"
13
14 [ "$1" = "-n" ] && {
15         shift
16         no_build=true
17 }
18 [ -n "$1" ] && {
19         build_host="$1"
20         shift
21 }
22 [ -n "$1" ] && {
23         build_dir="$1"
24         shift
25 }
26
27 log()
28 {
29         echo "$@" | tee -a $LOG_FILE
30 }
31
32 execute()
33 {
34         log "$" $@
35         $@ 2>&1 | tee -a $LOG_FILE
36         return ${PIPESTATUS[0]}
37 }
38
39 cpwd=../next
40
41 git update-ref "refs/next/$today/akpm-current" akpm/current
42 git branch -f akpm-current/current akpm/current
43
44 git branch -f akpm/base HEAD
45
46 hlog=$(git log -1 --oneline akpm-current/current) 2>/dev/null
47 log Merging akpm-current/current "($hlog)"
48 execute git merge akpm-current/current || {
49         echo Merge failed 1>&2
50         echo $h >>../merge.debug
51         git diff >>../merge.debug 2>&1
52         git diff 2>&1 | egrep -q '<<<<<|^\*' && {
53                 bash -i || exit
54         }
55         GIT_EDITOR=: execute git commit -v -a
56         execute git diff -M --stat --summary 'HEAD^..'
57 }
58
59 execute git clone -s -l -n -q . ../rebase-tmp || {
60         echo Clone failed 1>&2
61         bash -i || exit
62 }
63 log '$' cd ../rebase-tmp
64 cd ../rebase-tmp
65 execute git fetch --no-tags $cpwd refs/heads/akpm/master:akpm || {
66         echo Fetch of akpm/master failed 1>&2
67         bash -i || exit
68 }
69 execute git fetch --no-tags $cpwd refs/heads/akpm/master-base:akpm-base || {
70         echo Fetch of akpm/master-base failed 1>&2
71         bash -i || exit
72 }
73 execute git checkout akpm || {
74         echo Checkout of top failed 1>&2
75         bash -i || exit
76 }
77 execute git rebase --onto master akpm-base || {
78         echo Rebase failed 1>&2
79         bash -i || exit
80 }
81 echo "fix up?"
82 bash -i
83 log '$' cd $cpwd
84 cd $cpwd
85 execute git fetch -f ../rebase-tmp akpm:akpm/master || {
86         echo Pull failed 1>&2
87         bash -i || exit
88 }
89 execute rm -rf ../rebase-tmp
90
91 git update-ref "refs/next/$today/akpm" akpm/master
92
93 git branch -f akpm/master-base HEAD
94
95 log Merging akpm/master '('$(git log -1 --oneline akpm/master)')'
96 execute git merge --no-ff akpm/master || {
97         echo Merge failed 1>&2
98         bash -i || exit
99 }
100
101 [ -f "../merge-fixes/akpm" ] && {
102         for p in $(cat "../merge-fixes/akpm"); do
103                 ../tools/merge_fix -n "$p" || {
104                         bash -i || exit
105                 }
106         done
107 }
108 [ -x "../pre-build/akpm" ] && {
109         "../pre-build/akpm" || bash -i || exit
110 }
111
112 $no_build && exit 0
113
114 git push -f "$build_host":"$build_dir" master:refs/heads/next || {
115         echo git push failed 1>&2
116         bash -i || exit
117 }
118 ssh "$build_host" "$build_cmd" || {
119         echo Build failed 1>&2
120         bash -i || exit
121 }
122
123 exit 0