]> git.ozlabs.org Git - next-scripts/blobdiff - import-akpm
update to_build_host a bit
[next-scripts] / import-akpm
index ee8ada4a319be25bec63280a36c7be20d063cbd6..235ab70386eb5eeb90b2e71226e10f708f5b0c63 100755 (executable)
 #!/bin/bash
 
+export LOG_FILE=../akpm-import.log
+
+# shellcheck source=./common.sh
+. "$(dirname "$0")/common.sh" ''
+
 log()
 {
-       echo "$@" | tee -a ../akpm-import.log
+       echo "$@" | tee -a $LOG_FILE
 }
 
 execute()
 {
-       log "$" $@
-       "$@" 2>&1 | tee -a ../akpm-import.log
-       [ ${PIPESTATUS[0]} -eq 0 ] || $SHELL -i || {
-               [ -f "$sfile.orig" ] &&
-                       mv -f "$sfile.orig" "$sfile"
-               exit 1
-       }
+       log '$' "$@"
+       "$@" 2>&1 | tee -a $LOG_FILE
+       return ${PIPESTATUS[0]}
 }
 
-name="akpm"
-mmotm="../../mmotm/text"
+mmotm="../mmotm"
 sfile="$mmotm/series"
 cpwd=$(pwd)
 
-base=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/origin.patch")
+[ -f "$mmotm/broken-out/origin.patch" ] &&
+       base=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/origin.patch")
+[ "$base" ] || {
+       base=$(tail -n 1 "$mmotm/.DATE")
+       base=${base#v}
+       base="v${base}"
+}
 nbase=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/linux-next.patch")
-log "Importing $name based on $base/$nbase"
 git rev-parse --verify "$base" >/dev/null || {
-       log "Unknown origin BASE"
+       log "Unknown origin BASE $base"
        exit 1
 }
 git rev-parse --verify "$nbase" >/dev/null || {
-       log "Unknown linux-next BASE"
+       log "Unknown linux-next BASE $nbase"
        exit 1
 }
+db=$(git describe "$base")
+dnb=$(git describe --contains "$nbase")
+log "Importing akpm based on $db/$dnb"
 
-mv -f "$sfile" "$sfile.orig"
-do_echo=echo
-grep -q NEXT_PATCHES "$sfile.orig" && do_echo=:
-while read line; do
-       case $line in
-       *NEXT_PATCHES_START*)   do_echo=echo
-                               ;;
-       *NEXT_PATCHES_END*)     do_echo=:
-                               ;;
-       esac
-       $do_echo $line
-done <"$sfile.orig" |
-       sed -e 's/[     ]*#.*$//' -e '/^[       ]*$/d' >"$sfile"
-
-git show-ref --quiet --verify "refs/heads/quilt/$name" ||
-       execute git branch "quilt/$name" "$base"
-
-[ -s "$sfile" ] || {
-       log "   quilt series is empty"
-       mv -f "$sfile.orig" "$sfile"
-       execute git update-ref "refs/heads/quilt/$name" "$nbase"
-       exit 0
+[ -d "../tmp-akpm" ] && {
+       log "akpm import directory already exists"
+       exit 1
 }
 
-[ -d "../quilt-tmp" ] ||
-       execute git clone -s -l -n -q . ../quilt-tmp
-
-log '$' cd ../quilt-tmp
-cd ../quilt-tmp
-execute git reset --hard "$base"
-GIT_EDITOR=: execute git merge "$nbase" || bash -i || exit 1
-git branch base
-
-for f in $(cat "$mmotm/series"); do
-       [ "$f" = "origin.patch" ] && continue
-       [ "$f" = "linux-next.patch" ] && continue
-       execute git am "$mmotm/broken-out/$f" ||
-               bash -i ||
-               break
+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]*#.*$//
+       /^[ \t]*$/!p
+}
+/^linux-next.patch/p'
+patches=$(sed -n "$sed_exp" "$sfile")
+
+for f in $patches; do
+       case "$f" in
+       origin.patch)
+               ;;
+       linux-next.patch)
+               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 -s --patch-format=mbox "$mmotm/broken-out/$f" ||
+                       $SHELL -i || exit
+               ;;
+       esac
 done
 
 log '$' cd $cpwd
 cd $cpwd
 
-execute git fetch -f ../quilt-tmp master:"quilt/$name"
-execute git fetch -f ../quilt-tmp base:"quilt/${name}-base"
-
-mv -f "$sfile.orig" "$sfile"
+execute rm -rf ../tmp-akpm
+execute git worktree prune
 
-[ -d "../quilt-tmp" ] &&
-       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