From 863d70391046dbccfa6ba9004549934601de2059 Mon Sep 17 00:00:00 2001
From: gnzlbg <gonzalobg88@gmail.com>
Date: Wed, 20 Feb 2019 13:01:00 +0100
Subject: [PATCH] Retry downloading artifacts to prevent spurious failures due
 to network issues

---
 .travis.yml |  4 ++--
 ci/build.sh | 18 ++++++++++--------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 115a516a..2467c990 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -49,8 +49,8 @@ matrix:
       stage: tools-and-build-and-tier1
       rust: nightly
       install:
-        - rustup component add rust-src
-        - cargo install xargo
+        - travis_retry rustup component add rust-src
+        - travis_retry cargo install xargo
     - name: "Build Stable Rust"
       script: sh ci/build.sh
       stage: tools-and-build-and-tier1
diff --git a/ci/build.sh b/ci/build.sh
index a97af20a..78c65be9 100644
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -26,7 +26,16 @@ test_target() {
 
     # If there is a std component, fetch it:
     if [ "${NO_STD}" != "1" ]; then
-        rustup target add "${TARGET}" --toolchain "${RUST}"
+        # FIXME: rustup often fails to download some artifacts due to network
+        # issues, so we retry this N times.
+        N=5
+        n=0
+        until [ $n -ge $N ]
+        do
+            rustup target add "${TARGET}" --toolchain "${RUST}" && break
+            n=$((n+1))
+            sleep 1
+        done
     fi
 
     # Test that libc builds without any default features (no libstd)
@@ -110,13 +119,6 @@ x86_64-pc-windows-gnu \
 x86_64-unknown-linux-gnux32 \
 x86_64-unknown-redox \
 "
-# FIXME: these do not have a rust-std component available
-# aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf
-# i686-unknown-cloudabi powerpc-unknown-linux-gnuspe
-# sparc-unknown-linux-gnu mips-unknown-linux-uclib
-# i686-unknown-haiku mipsel-unknown-unknown-linux-uclib
-# sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku
-# x86_64-unknown-openbsd i686-unknown-netbsd
 
 RUST_OSX_TARGETS="\
 aarch64-apple-ios \
-- 
GitLab