]> git.ozlabs.org Git - next-scripts/blobdiff - import-akpm
update to_build_host a bit
[next-scripts] / import-akpm
index 7416311d7449ff9aef4b54fc65baa295055775c9..235ab70386eb5eeb90b2e71226e10f708f5b0c63 100755 (executable)
@@ -1,17 +1,20 @@
 #!/bin/bash
 
-log_file=../akpm-import.log
+export LOG_FILE=../akpm-import.log
+
+# shellcheck source=./common.sh
+. "$(dirname "$0")/common.sh" ''
 
 log()
 {
-       echo "$@" | tee -a $log_file
+       echo "$@" | tee -a $LOG_FILE
 }
 
 execute()
 {
-       log "$" $@
-       "$@" 2>&1 | tee -a $log_file
-       [ ${PIPESTATUS[0]} -eq 0 ] || $SHELL -i || exit 1
+       log '$' "$@"
+       "$@" 2>&1 | tee -a $LOG_FILE
+       return ${PIPESTATUS[0]}
 }
 
 mmotm="../mmotm"
@@ -38,18 +41,22 @@ db=$(git describe "$base")
 dnb=$(git describe --contains "$nbase")
 log "Importing akpm based on $db/$dnb"
 
-[ -d "../quilt-tmp" ] ||
-       execute git clone -s -l -n -q . ../quilt-tmp
+[ -d "../tmp-akpm" ] && {
+       log "akpm import directory already exists"
+       exit 1
+}
 
-log '$' cd ../quilt-tmp
-cd ../quilt-tmp
-execute git checkout -b akpm/master "$db"
-git branch akpm/current-base
+execute git worktree add -b tmp-akpm/master ../tmp-akpm "$db" ||
+       $SHELL -i || exit
+
+log '$' cd ../tmp-akpm
+cd ../tmp-akpm
+execute git branch tmp-akpm/current-base ||
+       $SHELL -i || exit
 
 sed_exp='
+s/\r$//
 /NEXT_PATCHES_START/,/NEXT_PATCHES_END/{
-       s/[ \t]*#.*NEXT_PATCHES_START[ \t]*\([^ \t]*\).*$/>\1/
-       s/[ \t]*#.*NEXT_PATCHES_END.*$/</
        s/[ \t]*#.*$//
        /^[ \t]*$/!p
 }
@@ -61,41 +68,41 @@ for f in $patches; do
        origin.patch)
                ;;
        linux-next.patch)
-               git branch akpm/current
-               execute git merge --no-edit --no-stat "$dnb"
-               git branch akpm/master-base
-               ;;
-       \>*)
-               cbranch="${f#>}"
-               [ "$cbranch" ] &&
-                       cref="$(git rev-parse --verify HEAD)"
-               ;;
-       \<)
-               [ "$cbranch" ] && {
-                       [ "$cref" != "$(git rev-parse --verify HEAD)" ] &&
-                               git branch -f "akpm/$cbranch"
-                       cbranch=""
+               execute git branch tmp-akpm/current ||
+                       $SHELL -i || exit
+               execute git merge --no-edit --no-stat "$dnb" || {
+                       check_unmerged_files akpm-current
+
+                       git diff 2>&1 | grep -E -q '<<<<<|^\*' && {
+                               $SHELL -i || exit
+                       }
+                       GIT_EDITOR=: execute git commit -v -a
+               }
+               [ -f "../merge-fixes/akpm-current" ] && {
+                       for p in $(cat "../merge-fixes/akpm-current"); do
+                               $(dirname $0)/merge_fix -n "$p" ||
+                                       $SHELL -i || exit
+                       done
                }
+               execute git branch tmp-akpm/master-base ||
+                       $SHELL -i || exit
                ;;
        *)
-               execute git am --patch-format=mbox "$mmotm/broken-out/$f"
+               execute git am -s --patch-format=mbox "$mmotm/broken-out/$f" ||
+                       $SHELL -i || exit
                ;;
        esac
 done
 
-[ "$cbranch" ] &&
-       [ "$cref" != "$(git rev-parse --verify HEAD)" ] &&
-               git branch -f "akpm/$cbranch"
-
 log '$' cd $cpwd
 cd $cpwd
 
-execute git fetch --force --no-tags ../quilt-tmp \
-       refs/heads/akpm/master:refs/heads/akpm/master \
-       refs/heads/akpm/master-base:refs/heads/akpm/master-base \
-       refs/heads/akpm/current:refs/heads/akpm/current \
-       refs/heads/akpm/current-base:refs/heads/akpm/current-base
+execute rm -rf ../tmp-akpm
+execute git worktree prune
 
-rm -rf ../quilt-tmp
+for i in akpm/current akpm/current-base akpm/master akpm/master-base; do
+       execute git branch -f $i tmp-$i
+       execute git branch -D tmp-$i
+done
 
 exit 0