X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=import-akpm;h=235ab70386eb5eeb90b2e71226e10f708f5b0c63;hb=HEAD;hp=d206e7a60e7d6634e3d35669254d3c4a2e0e7838;hpb=e182717c8e468a4bbf811bd7a5c253151ad85cae;p=next-scripts diff --git a/import-akpm b/import-akpm index d206e7a..235ab70 100755 --- a/import-akpm +++ b/import-akpm @@ -1,24 +1,33 @@ #!/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/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") git rev-parse --verify "$base" >/dev/null || { log "Unknown origin BASE $base" @@ -32,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 +} + +execute git worktree add -b tmp-akpm/master ../tmp-akpm "$db" || + $SHELL -i || exit -log '$' cd ../quilt-tmp -cd ../quilt-tmp -execute git checkout -b akpm/master "$db" -git branch akpm/current-base +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.*$/*) - 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 akpm +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