Chris@0: #!/bin/bash Chris@6: Chris@126: # Run this from the top-level vamp-build-and-test directory Chris@126: # Optional argument for the single repo to checkout; default is all of them Chris@127: # Optional second argument for the revision to checkout; default is tip Chris@126: Chris@126: single="" Chris@126: if [ -n "$1" ]; then Chris@126: single="$1" Chris@126: fi Chris@126: Chris@127: rev="" Chris@127: revopt_hg="" Chris@127: revopt_git="" Chris@127: if [ -n "$2" ]; then Chris@127: rev="$2" Chris@127: revopt_hg="-r$rev" Chris@127: revopt_git="-b$rev" Chris@127: fi Chris@127: Chris@100: set -eu Chris@100: Chris@100: failed=/tmp/failed_$$ Chris@100: rm -f "$failed" Chris@100: trap "rm -f $failed" 0 Chris@100: Chris@100: cat METADATA/repos.txt | grep -v '^#' | awk -F= '{ print $1, $2 }' | Chris@100: while read name loc; do Chris@126: if [ -n "$single" ]; then Chris@126: if [ "$single" != "$name" ]; then Chris@126: continue Chris@126: fi Chris@126: fi Chris@100: if [ -d "$name"/.hg ]; then Chris@127: ( cd $name ; hg pull && hg update $revopt_hg ) || echo "$name" >> "$failed" Chris@100: elif [ -d "$name"/.git ]; then Chris@100: ( cd $name ; git pull ) || echo "$name" >> "$failed" Chris@127: if [ -n "$rev" ]; then Chris@127: ( cd $name ; git checkout "$rev" ) || echo "$name" >> "$failed" Chris@127: fi Chris@100: elif [ -d "$name" ]; then Chris@100: echo "ERROR: Directory \"$name\" exists, but is not a git or hg repo" 1>&2 Chris@100: exit 1 Chris@100: else Chris@100: case "$loc" in Chris@100: */hg/*) Chris@127: hg clone $revopt_hg "$loc" "$name" || echo "$name" >> "$failed";; Chris@100: *//git*) Chris@127: git clone $revopt_git "$loc" "$name" || echo "$name" >> "$failed";; Chris@100: *) Chris@100: echo "ERROR: Can't deduce repo type from URL \"$loc\"" 1>&2 Chris@100: exit 1;; Chris@100: esac Chris@100: fi Chris@100: done Chris@100: Chris@100: echo "Done" Chris@100: if [ -f "$failed" ]; then Chris@100: echo "Failed repos:" Chris@100: cat "$failed" Chris@100: fi