#!/bin/bash quilt_dir="../quilt" name="$1" sfile="$quilt_dir/$name/series" base=$(sed -n 's/^[# ]*NEXT_BASE[ ]*\(.*\)[ ]*$/\1/p' "$sfile") if [ -n "$base" ]; then base=$(grep -v '^#' ../real_control | awk -F ' ' '$3=="'"$base"'" { if ($2=="quilt") printf("quilt/%s", "'"$base"'"); else printf("%s/%s", "'"$base"'", $5); }') else base=$(sed -n 's/^[# ]*BASE[ ]*\(.*\)[ ]*$/\1/p' "$sfile") fi rbase="$base" case "$base" in *-git[0-9]*) rbase=$(wget -q -O - "http://www.kernel.org/pub/linux/kernel/v2.6/snapshots/patch-${base}.id") ;; commit*) rbase=$(expr "$base" : "commit[ ]*\(.*\)") ;; [0-9]*.*) rbase="v$base" ;; esac #log "Importing $name based on $base" git rev-list -n 1 "$rbase" -- >/dev/null 2>&1 || { # log "Unknown BASE" continue } grep -q NEXT_PATCHES "$sfile" && { mv -f "$sfile" "$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" >"$sfile" } #execute git branch -D "next-quilt-$name" git branch -D "next-quilt-$name" #execute git checkout -b "next-quilt-$name" "$rbase" || sh -i || { git checkout -b "next-quilt-$name" "$rbase" || sh -i || { [ -f "$sfile.orig" ] && mv -f $sfile.orig $sfile exit 1 } author=$(grep -v '^#' ../real_control | awk -F ' ' '$3=="'"$name"'" { printf("%s", $1); }' | sed 's/,.*$//') #execute git quiltimport --author "$author" --patches "$quilt_dir/$name" || sh -i || { git quiltimport --author "$author" --patches "$quilt_dir/$name" || sh -i || { [ -f "$sfile.orig" ] && mv -f $sfile.orig $sfile exit 1 } [ -f "$sfile.orig" ] && mv -f $sfile.orig $sfile