X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=fetch_trees;h=2db70cdb77e15bf0ba00ff54dda4a7bbf0447c24;hb=HEAD;hp=d22c6629263862ea88f5eb074c1fbf2f2d221c78;hpb=69ad6e13b3730e4e127ba17ea3c486989d751e44;p=next-scripts diff --git a/fetch_trees b/fetch_trees index d22c662..92accdd 100755 --- a/fetch_trees +++ b/fetch_trees @@ -1,83 +1,86 @@ #!/bin/bash -origwd=$(pwd) +tools_dir=$(dirname "$0") +. "$tools_dir/common.sh" '' -get_field() +if [ "$1" = '-n' ]; then + shift + last=$(tail -n1 "$SHA1_FILE" | cut -f1 -d"$_TAB") + start_from=$(get_branches | sed -n '/^'"$last"'$/{n;p;}') + if [ -z "$start_from" ]; then + exit 0 + fi +fi + +if [ "$1" = '-s' ]; then + shift + start_from="$1" + if [ -z "$start_from" ]; then + printf '-s requires a start tree\n' 1>&2 + exit 1 + fi + shift +fi + +# shellcheck disable=SC2317 +fetch_git() { - grep -v '^#' ../real_control | - awk -F ' ' '$3 == "'$1'" { print $'$2'; }' + local name="$1" branch="$2" old_sha="$3" new_sha + + if ! new_sha=$(git ls-remote "$name" "refs/heads/$branch") || + [ -z "$new_sha" ]; then + printf '%s: Could not fetch %s branch %s\n' 'fetch_git' "$name" "$branch" >&2 + printf '%s\n' "$old_sha" + return + fi + new_sha="${new_sha%%"${_TAB}"*}" + if [ "$new_sha" = "$old_sha" ]; then + printf '%s\n' "$old_sha" + return + fi + if git fetch "$name"; then + git rev-parse --verify "$name/$branch" + else + printf '%s\n' "$old_sha" + fi } -trees="$@" -[ "$trees" ] || - trees=$(grep -v '^#' ../real_control | awk -F ' ' '{ print $3 }') +trees="$*" +if ! [ "$trees" ]; then + trees=$(get_branches) +fi for name in $trees; do - type=$(get_field "$name" 2) + if [ -n "$start_from" ]; then + if [ "$name" = "$start_from" ]; then + start_from='' + else + continue + fi + fi - echo $name: $type - if [ "$type" = "git" ]; then - git fetch "$name" + type=$(get_type "$name") + if ! [ "$type" ]; then + printf '%s: unknown tree\n' "$name" 1>&2 continue fi - if [ "$type" = "quilt" ]; then - url=$(get_field "$name" 4) - url=${url%/} # strip trailing / if necessary + if [ "$(get_url "$name")" = 'linux-next' ]; then + continue + fi - cd ../quilt || { - echo "Cannot chdir to ../quilt" 1>&2 - continue - } - [ -d "$name" ] || mkdir "$name" || { - echo "Cannot create quilt directory for $name" 1>&2 - cd "$origwd" - continue - } - cd "$name" || { - echo "Cannot chdir to quilt directory for $name" 1>&2 - cd "$origwd" - continue - } - wget -N -nv --no-cache "$url/series" || { - echo "Wget of $name series file failed" 1>&2 - cd .. - rm -rf "$name" - git checkout "$name" - cd "$origwd" - continue - } - 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 - sed "s|^|$url/|" .series.next | - wget -N -nv --no-cache -i - || { - echo "Wget of series '$name' failed" 1>&2 - cd .. - rm -rf "$name" - git checkout "$name" - cd "$origwd" - continue - } - comm -23 .series.old .series.next | xargs -r rm -f - rm -f .series.old .series.next - cd "$origwd" + printf '%s: %s\n' "$name" "$type" + fun="fetch_$type" + tfun=$(type -t "$fun") + if [ "$tfun" = 'function' ]; then + branch=$(get_remote_branch "$name") + old_sha=$(git rev-parse --quiet --verify "$name/$branch") + new_sha=$("$fun" "$name" "$branch" "$old_sha") + check_dups "$name" origin/master "$new_sha" + if ! [ "$new_sha" = "$old_sha" ]; then + "$tools_dir"/check_commits ^origin/master "$old_sha..$new_sha" + fi fi done -cd ../quilt -git add -A . -git commit -v -a -m "$(date '+%F-%H:%M')" -e - exit 0