]> git.ozlabs.org Git - next-scripts/blob - import-akpm
various updates
[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 name="akpm"
18 mmotm="../../mmotm/text"
19 sfile="$mmotm/series"
20 cpwd=$(pwd)
21
22 base=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/origin.patch")
23 nbase=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/linux-next.patch")
24 log "Importing $name based on $base/$nbase"
25 git rev-parse --verify "$base" >/dev/null || {
26         log "Unknown origin BASE"
27         exit 1
28 }
29 git rev-parse --verify "$nbase" >/dev/null || {
30         log "Unknown linux-next BASE"
31         exit 1
32 }
33
34 [ -d "../quilt-tmp" ] ||
35         execute git clone -s -l -n -q . ../quilt-tmp
36
37 log '$' cd ../quilt-tmp
38 cd ../quilt-tmp
39 execute git reset --hard "$base"
40 git branch current-base
41
42 sed_exp='/NEXT_PATCHES_START/,/NEXT_PATCHES_END/{s/[ \t]*#.*$//;/^[ \t]*$/!p;};/^linux-next.patch/p'
43 patches=$(sed -n "$sed_exp" "$sfile")
44
45 for f in $patches; do
46         [ "$f" = "origin.patch" ] && continue
47         [ "$f" = "linux-next.patch" ] && {
48                 git branch current
49                 execute git merge --no-edit --no-stat "$nbase"
50                 git branch master-base
51                 continue
52         }
53         execute git am --patch-format=mbox "$mmotm/broken-out/$f"
54 done
55
56 log '$' cd $cpwd
57 cd $cpwd
58
59 execute git fetch -f ../quilt-tmp current:"$name/current"
60 execute git fetch -f ../quilt-tmp current-base:"$name/current-base"
61 execute git fetch -f ../quilt-tmp master:"$name/master"
62 execute git fetch -f ../quilt-tmp master-base:"$name/master-base"
63
64 rm -rf ../quilt-tmp
65
66 exit 0