]> git.ozlabs.org Git - next-scripts/blob - import-akpm
move mmotm to here as well
[next-scripts] / import-akpm
1 #!/bin/bash
2
3 log_file=../akpm-import.log
4
5 log()
6 {
7         echo "$@" | tee -a $log_file
8 }
9
10 execute()
11 {
12         log "$" $@
13         "$@" 2>&1 | tee -a $log_file
14         [ ${PIPESTATUS[0]} -eq 0 ] || $SHELL -i || exit 1
15 }
16
17 mmotm="../mmotm"
18 sfile="$mmotm/series"
19 cpwd=$(pwd)
20
21 [ -f "$mmotm/broken-out/origin.patch" ] &&
22         base=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/origin.patch")
23 [ "$base" ] || {
24         base=$(tail -n 1 "$mmotm/.DATE")
25         base=${base#v}
26         base="v${base}"
27 }
28 nbase=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/linux-next.patch")
29 git rev-parse --verify "$base" >/dev/null || {
30         log "Unknown origin BASE $base"
31         exit 1
32 }
33 git rev-parse --verify "$nbase" >/dev/null || {
34         log "Unknown linux-next BASE $nbase"
35         exit 1
36 }
37 db=$(git describe "$base")
38 dnb=$(git describe --contains "$nbase")
39 log "Importing akpm based on $db/$dnb"
40
41 [ -d "../quilt-tmp" ] ||
42         execute git clone -s -l -n -q . ../quilt-tmp
43
44 log '$' cd ../quilt-tmp
45 cd ../quilt-tmp
46 execute git checkout -b akpm/master "$db"
47 git branch akpm/current-base
48
49 sed_exp='
50 /NEXT_PATCHES_START/,/NEXT_PATCHES_END/{
51         s/[ \t]*#.*NEXT_PATCHES_START[ \t]*\([^ \t]*\).*$/>\1/
52         s/[ \t]*#.*NEXT_PATCHES_END.*$/</
53         s/[ \t]*#.*$//
54         /^[ \t]*$/!p
55 }
56 /^linux-next.patch/p'
57 patches=$(sed -n "$sed_exp" "$sfile")
58
59 for f in $patches; do
60         case "$f" in
61         origin.patch)
62                 ;;
63         linux-next.patch)
64                 git branch akpm/current
65                 execute git merge --no-edit --no-stat "$dnb"
66                 git branch akpm/master-base
67                 ;;
68         \>*)
69                 cbranch="${f#>}"
70                 [ "$cbranch" ] &&
71                         cref="$(git rev-parse --verify HEAD)"
72                 ;;
73         \<)
74                 [ "$cbranch" ] && {
75                         [ "$cref" != "$(git rev-parse --verify HEAD)" ] &&
76                                 git branch -f "akpm/$cbranch"
77                         cbranch=""
78                 }
79                 ;;
80         *)
81                 execute git am --patch-format=mbox "$mmotm/broken-out/$f"
82                 ;;
83         esac
84 done
85
86 [ "$cbranch" ] &&
87         [ "$cref" != "$(git rev-parse --verify HEAD)" ] &&
88                 git branch -f "akpm/$cbranch"
89
90 log '$' cd $cpwd
91 cd $cpwd
92
93 execute git fetch --force --no-tags ../quilt-tmp \
94         refs/heads/akpm/master:refs/heads/akpm/master \
95         refs/heads/akpm/master-base:refs/heads/akpm/master-base \
96         refs/heads/akpm/current:refs/heads/akpm/current \
97         refs/heads/akpm/current-base:refs/heads/akpm/current-base
98
99 rm -rf ../quilt-tmp
100
101 exit 0