Mercurial > hg > vamp-build-and-test
annotate SCRIPTS/update.sh @ 133:4acb5d8d80b6 tip
Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author | Chris Cannam |
---|---|
date | Tue, 30 Jul 2019 12:25:44 +0100 |
parents | 622ddc1ace50 |
children |
rev | line source |
---|---|
Chris@0 | 1 #!/bin/bash |
Chris@6 | 2 |
Chris@126 | 3 # Run this from the top-level vamp-build-and-test directory |
Chris@126 | 4 # Optional argument for the single repo to checkout; default is all of them |
Chris@127 | 5 # Optional second argument for the revision to checkout; default is tip |
Chris@126 | 6 |
Chris@126 | 7 single="" |
Chris@126 | 8 if [ -n "$1" ]; then |
Chris@126 | 9 single="$1" |
Chris@126 | 10 fi |
Chris@126 | 11 |
Chris@127 | 12 rev="" |
Chris@127 | 13 revopt_hg="" |
Chris@127 | 14 revopt_git="" |
Chris@127 | 15 if [ -n "$2" ]; then |
Chris@127 | 16 rev="$2" |
Chris@127 | 17 revopt_hg="-r$rev" |
Chris@127 | 18 revopt_git="-b$rev" |
Chris@127 | 19 fi |
Chris@127 | 20 |
Chris@100 | 21 set -eu |
Chris@100 | 22 |
Chris@100 | 23 failed=/tmp/failed_$$ |
Chris@100 | 24 rm -f "$failed" |
Chris@100 | 25 trap "rm -f $failed" 0 |
Chris@100 | 26 |
Chris@100 | 27 cat METADATA/repos.txt | grep -v '^#' | awk -F= '{ print $1, $2 }' | |
Chris@100 | 28 while read name loc; do |
Chris@126 | 29 if [ -n "$single" ]; then |
Chris@126 | 30 if [ "$single" != "$name" ]; then |
Chris@126 | 31 continue |
Chris@126 | 32 fi |
Chris@126 | 33 fi |
Chris@100 | 34 if [ -d "$name"/.hg ]; then |
Chris@127 | 35 ( cd $name ; hg pull && hg update $revopt_hg ) || echo "$name" >> "$failed" |
Chris@100 | 36 elif [ -d "$name"/.git ]; then |
Chris@100 | 37 ( cd $name ; git pull ) || echo "$name" >> "$failed" |
Chris@127 | 38 if [ -n "$rev" ]; then |
Chris@127 | 39 ( cd $name ; git checkout "$rev" ) || echo "$name" >> "$failed" |
Chris@127 | 40 fi |
Chris@100 | 41 elif [ -d "$name" ]; then |
Chris@100 | 42 echo "ERROR: Directory \"$name\" exists, but is not a git or hg repo" 1>&2 |
Chris@100 | 43 exit 1 |
Chris@100 | 44 else |
Chris@100 | 45 case "$loc" in |
Chris@100 | 46 */hg/*) |
Chris@127 | 47 hg clone $revopt_hg "$loc" "$name" || echo "$name" >> "$failed";; |
Chris@100 | 48 *//git*) |
Chris@127 | 49 git clone $revopt_git "$loc" "$name" || echo "$name" >> "$failed";; |
Chris@100 | 50 *) |
Chris@100 | 51 echo "ERROR: Can't deduce repo type from URL \"$loc\"" 1>&2 |
Chris@100 | 52 exit 1;; |
Chris@100 | 53 esac |
Chris@100 | 54 fi |
Chris@100 | 55 done |
Chris@100 | 56 |
Chris@100 | 57 echo "Done" |
Chris@100 | 58 if [ -f "$failed" ]; then |
Chris@100 | 59 echo "Failed repos:" |
Chris@100 | 60 cat "$failed" |
Chris@100 | 61 fi |