]> git.ozlabs.org Git - next-scripts/blob - import-akpm
update to_build_host a bit
[next-scripts] / import-akpm
1 #!/bin/bash
2
3 export LOG_FILE=../akpm-import.log
4
5 # shellcheck source=./common.sh
6 . "$(dirname "$0")/common.sh" ''
7
8 log()
9 {
10         echo "$@" | tee -a $LOG_FILE
11 }
12
13 execute()
14 {
15         log '$' "$@"
16         "$@" 2>&1 | tee -a $LOG_FILE
17         return ${PIPESTATUS[0]}
18 }
19
20 mmotm="../mmotm"
21 sfile="$mmotm/series"
22 cpwd=$(pwd)
23
24 [ -f "$mmotm/broken-out/origin.patch" ] &&
25         base=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/origin.patch")
26 [ "$base" ] || {
27         base=$(tail -n 1 "$mmotm/.DATE")
28         base=${base#v}
29         base="v${base}"
30 }
31 nbase=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/linux-next.patch")
32 git rev-parse --verify "$base" >/dev/null || {
33         log "Unknown origin BASE $base"
34         exit 1
35 }
36 git rev-parse --verify "$nbase" >/dev/null || {
37         log "Unknown linux-next BASE $nbase"
38         exit 1
39 }
40 db=$(git describe "$base")
41 dnb=$(git describe --contains "$nbase")
42 log "Importing akpm based on $db/$dnb"
43
44 [ -d "../tmp-akpm" ] && {
45         log "akpm import directory already exists"
46         exit 1
47 }
48
49 execute git worktree add -b tmp-akpm/master ../tmp-akpm "$db" ||
50         $SHELL -i || exit
51
52 log '$' cd ../tmp-akpm
53 cd ../tmp-akpm
54 execute git branch tmp-akpm/current-base ||
55         $SHELL -i || exit
56
57 sed_exp='
58 s/\r$//
59 /NEXT_PATCHES_START/,/NEXT_PATCHES_END/{
60         s/[ \t]*#.*$//
61         /^[ \t]*$/!p
62 }
63 /^linux-next.patch/p'
64 patches=$(sed -n "$sed_exp" "$sfile")
65
66 for f in $patches; do
67         case "$f" in
68         origin.patch)
69                 ;;
70         linux-next.patch)
71                 execute git branch tmp-akpm/current ||
72                         $SHELL -i || exit
73                 execute git merge --no-edit --no-stat "$dnb" || {
74                         check_unmerged_files akpm-current
75
76                         git diff 2>&1 | grep -E -q '<<<<<|^\*' && {
77                                 $SHELL -i || exit
78                         }
79                         GIT_EDITOR=: execute git commit -v -a
80                 }
81                 [ -f "../merge-fixes/akpm-current" ] && {
82                         for p in $(cat "../merge-fixes/akpm-current"); do
83                                 $(dirname $0)/merge_fix -n "$p" ||
84                                         $SHELL -i || exit
85                         done
86                 }
87                 execute git branch tmp-akpm/master-base ||
88                         $SHELL -i || exit
89                 ;;
90         *)
91                 execute git am -s --patch-format=mbox "$mmotm/broken-out/$f" ||
92                         $SHELL -i || exit
93                 ;;
94         esac
95 done
96
97 log '$' cd $cpwd
98 cd $cpwd
99
100 execute rm -rf ../tmp-akpm
101 execute git worktree prune
102
103 for i in akpm/current akpm/current-base akpm/master akpm/master-base; do
104         execute git branch -f $i tmp-$i
105         execute git branch -D tmp-$i
106 done
107
108 exit 0