]> git.ozlabs.org Git - next-scripts/blob - import-akpm
fetch_trees: explicitly stop wget from storing the URL in an xattr
[next-scripts] / import-akpm
1 #!/bin/bash
2
3 export 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         return ${PIPESTATUS[0]}
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 "../tmp-akpm" ] && {
42         log "akpm import directory already exists"
43         exit 1
44 }
45
46 execute git worktree add -b tmp-akpm/master ../tmp-akpm "$db" ||
47         $SHELL -i || exit
48
49 log '$' cd ../tmp-akpm
50 cd ../tmp-akpm
51 execute git branch tmp-akpm/current-base ||
52         $SHELL -i || exit
53
54 sed_exp='
55 /NEXT_PATCHES_START/,/NEXT_PATCHES_END/{
56         s/[ \t]*#.*$//
57         /^[ \t]*$/!p
58 }
59 /^linux-next.patch/p'
60 patches=$(sed -n "$sed_exp" "$sfile")
61
62 for f in $patches; do
63         case "$f" in
64         origin.patch)
65                 ;;
66         linux-next.patch)
67                 execute git branch tmp-akpm/current ||
68                         $SHELL -i || exit
69                 execute git merge --no-edit --no-stat "$dnb" || {
70                         umf=$(git diff 2>&1 | sed -n 's/^\* Unmerged path //p')
71                         [ "$umf" ] && [ -f "../merge-files/akpm-current" ] && {
72                                 rmf=$(grep -F "$umf" "../merge-files/akpm-current")
73                                 [ "$rmf" ] &&
74                                         "$bin_dir/do_rm" $rmf
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