#!/bin/bash name=$1 [ "$name" ] || { echo "Usage: $0 " 1>&2 exit 1 } get_field() { grep -v '^#' ../real_control | awk -F ' ' '$3 == "'$1'" { print $'$2'; }' } type=$(get_field "$name" 2) [ "$type" ] || { echo "Unknown tree: $name" 1>&2 exit 1 } echo $name: $type [ "$type" = "git" ] && { git fetch "$name" exit 0 } [ "$type" = "quilt" ] || { echo "Unknow tree type: $type" 1>&2 exit 1 } url=$(get_field "$name" 4) case "$url" in http://kernel.org/*|http://www.kernel.org/*) use_rsync=true rurl=$(echo "$url" | sed -r 's,^http://(www\.)?kernel\.org,master.kernel.org:,') ;; http://ozlabs.org/~*) use_rsync=true rurl=$(echo "$url" | sed -r 's,^http://ozlabs\.org/([^/]*),ozlabs.org:\1/public_html,') ;; *) use_rsync=false ;; esac cd ../quilt || { echo "Cannot chdir to ../quilt" 1>&2 exit 1 } [ -d "$name" ] || mkdir "$name" || { echo "Cannot create quilt directory for $name" 1>&2 exit 1 } cd "$name" || { echo "Cannot chdir to quilt directory for $name" 1>&2 exit 1 } if $use_rsync; then rsync -avz "$rurl/series" series || { echo "rsync of $name series file failed" 1>&2 cd .. rm -rf "$name" git checkout "$name" exit 1 } else wget -N -nv --no-cache "$url/series" || { echo "Wget of $name series file failed" 1>&2 cd .. rm -rf "$name" git checkout "$name" exit 1 } fi find * -type f | grep -v '^series$' | sort >.series.old do_echo=echo grep -q NEXT_PATCHES series && do_echo=: while read line; do case "$line" in *NEXT_PATCHES_START*) do_echo=echo ;; *NEXT_PATCHES_END*) do_echo=: ;; ''|\#*) : ;; *) $do_echo $line ;; esac done .series.next if $use_rsync; then rsync -avz --files-from .series.next "$rurl" . || { echo "rsync of series '$name' failed" 1>&2 cd .. rm -rf "$name" git checkout "$name" exit 1 } else wget -N -nv --no-cache -B "$url" -i .series.next || { echo "Wget of series '$name' failed" 1>&2 cd .. rm -rf "$name" git checkout "$name" exit 1 } fi comm -23 .series.old .series.next | xargs -r git rm -f rm -f .series.old .series.next git add . #git commit -v -a -m "$(date '+%F-%H:%M')" -e exit 0