From 4a79b17d3beee2b51dfb0f5ba6359563820b2898 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Wed, 3 Feb 2021 01:18:44 +0100 Subject: [PATCH] scripts: add support for multiple mmodule sources This adds support for providing a list of multiple sources a module can be obtained from. This way, modules can have a fallback to clone from in case the primary source is not available. --- scripts/update.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/update.sh b/scripts/update.sh index 0d33a8cc..adc5c5ac 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -19,10 +19,22 @@ for module in $GLUON_MODULES; do git init if ! git branch -f base "$commit" 2>/dev/null; then - git fetch "$repo" "$branch" - git branch -f base "$commit" || { - echo "unable to find commit \"$commit\" on branch \"$branch\" in repo \"$repo\"." >&2 - exit 1 - } + for repository in $repo; do + if git fetch "$repository" "$branch"; then + if ! git branch -f base "$commit"; then + echo "unable to find commit \"$commit\" on branch \"$branch\" in repo \"$repo\"." >&2 + break + fi + fetched=1 + break + else + echo "unable to fetch module \"$module\" from \"$repository\"" >&2 + fi + done + + if [ $fetched -ne 1 ]; then + echo "No suitable mirror for module \"$module\" found." >&2 + exit 1 + fi fi done