#!/bin/bash log_file=../akpm-import.log log() { echo "$@" | tee -a $log_file } execute() { log "$" $@ "$@" 2>&1 | tee -a $log_file [ ${PIPESTATUS[0]} -eq 0 ] || $SHELL -i || exit 1 } name="akpm" mmotm="../../mmotm/text" sfile="$mmotm/series" cpwd=$(pwd) base=$(sed -n '1s/^GIT *\([^ ]*\).*$/\1/p' "$mmotm/broken-out/origin.patch") 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" exit 1 } git rev-parse --verify "$nbase" >/dev/null || { log "Unknown linux-next BASE" 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 branch current-base sed_exp='/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 [ "$f" = "origin.patch" ] && continue [ "$f" = "linux-next.patch" ] && { git branch current execute git merge --no-edit --no-stat "$nbase" git branch master-base continue } execute git am --patch-format=mbox "$mmotm/broken-out/$f" done log '$' cd $cpwd cd $cpwd execute git fetch -f ../quilt-tmp current:"$name/current" execute git fetch -f ../quilt-tmp current-base:"$name/current-base" execute git fetch -f ../quilt-tmp master:"$name/master" execute git fetch -f ../quilt-tmp master-base:"$name/master-base" rm -rf ../quilt-tmp exit 0