From 09416daff2507de69768283b1565d009e4bf4dfd Mon Sep 17 00:00:00 2001 From: ilia-shipitsin <125650415+ilia-shipitsin@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:56:54 +0200 Subject: [PATCH] [macos] add retries to "brew install" (#8608) --- images/macos/provision/utils/utils.sh | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/images/macos/provision/utils/utils.sh b/images/macos/provision/utils/utils.sh index eb8dd76d..023701f2 100755 --- a/images/macos/provision/utils/utils.sh +++ b/images/macos/provision/utils/utils.sh @@ -173,6 +173,38 @@ brew_smart_install() { brew install --build-from-source $tool_name else echo "Downloading $tool_name..." + + # get deps & cache em + + failed=true + for i in {1..10}; do + brew deps $tool_name > /tmp/$tool_name && failed=false || sleep 60 + if [ "$failed" = false ]; then + break + fi + done + + if [ "$failed" = true ]; then + echo "Failed: brew deps $tool_name" + exit 1; + fi + + for dep in $(cat /tmp/$tool_name); do + + failed=true + for i in {1..10}; do + brew --cache $dep && failed=false || sleep 60 + if [ "$failed" = false ]; then + break + fi + done + + if [ "$failed" = true ]; then + echo "Failed: brew --cache $dep" + exit 1; + fi + done + brew install $tool_name fi }