]> git.ozlabs.org Git - next-scripts/blob - merge_akpm
new files
[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 execute git clone -s -l -n -q . ../rebase-tmp || {
42         echo Clone failed 1>&2
43         bash -i || exit
44 }
45 log '$' cd ../rebase-tmp
46 cd ../rebase-tmp
47 execute git fetch --no-tags $cpwd refs/heads/quilt/akpm:akpm || {
48         echo Fetch of top failed 1>&2
49         bash -i || exit
50 }
51 execute git fetch --no-tags $cpwd refs/heads/quilt/akpm-base:akpm-base || {
52         echo Fetch of base failed 1>&2
53         bash -i || exit
54 }
55 execute git checkout akpm || {
56         echo Checkout of top failed 1>&2
57         bash -i || exit
58 }
59 execute git rebase --onto master akpm-base || {
60         echo Rebase failed 1>&2
61         bash -i || exit
62 }
63 echo "fix up? use git rebase -i --onto master akpm-base"
64 bash -i
65 log '$' cd $cpwd
66 cd $cpwd
67 execute git fetch -f ../rebase-tmp akpm:akpm || {
68         echo Pull failed 1>&2
69         bash -i || exit
70 }
71 execute rm -rf ../rebase-tmp
72
73 git update-ref "refs/next/$today/akpm" akpm
74 git update-ref refs/heads/akpm-end HEAD
75 git update-ref refs/heads/quilt/akpm refs/heads/akpm
76 git update-ref refs/heads/quilt/akpm-base refs/heads/akpm-end
77
78 log Merging akpm '('$(git log -1 --oneline akpm)')'
79 execute git merge --no-ff akpm || {
80         echo Merge failed 1>&2
81         bash -i || exit
82 }
83
84 [ -f "../merge-fixes/akpm" ] && {
85         for p in $(cat "../merge-fixes/akpm"); do
86                 ../tools/merge_fix -n "$p" || {
87                         bash -i || exit
88                 }
89         done
90 }
91 [ -x "../pre-build/akpm" ] && {
92         "../pre-build/akpm" || bash -i || exit
93 }
94
95 $no_build && exit 0
96
97 git push -f "$build_host":"$build_dir" master:refs/heads/next || {
98         echo git push failed 1>&2
99         bash -i || exit
100 }
101 ssh "$build_host" "$build_cmd" || {
102         echo Build failed 1>&2
103         bash -i || exit
104 }
105
106 exit 0
107