third-party: download: retry (#10599)

This is meant to handle the common case of failing to download
libtermkey:

    FAILED: cd /home/travis/build/neovim/neovim/deps-downloads/libtermkey && /usr/local/cmake-3.12.4/bin/cmake -DPREFIX=/home/travis/nvim-deps/build -DDOWNLOAD_DIR=/home/travis/build/neovim/neovim/deps-downloads/libtermkey -DURL=http://www.leonerd.org.uk/code/libtermkey/libtermkey-0.21.1.tar.gz -DEXPECTED_SHA256=cecbf737f35d18f433c8d7864f63c0f878af41f8bd0255a3ebb16010dc044d5f -DTARGET=libtermkey -DUSE_EXISTING_SRC_DIR=OFF -P /home/travis/build/neovim/neovim/third-party/cmake/DownloadAndExtractFile.cmake && /usr/local/cmake-3.12.4/bin/cmake -E touch /home/travis/nvim-deps/build/src/libtermkey-stamp/libtermkey-download
    -- file: /home/travis/build/neovim/neovim/deps-downloads/libtermkey/libtermkey-0.21.1.tar.gz
    -- downloading...
         src='http://www.leonerd.org.uk/code/libtermkey/libtermkey-0.21.1.tar.gz'
         dst='/home/travis/build/neovim/neovim/deps-downloads/libtermkey/libtermkey-0.21.1.tar.gz'
         timeout='none'
    CMake Error at /home/travis/build/neovim/neovim/third-party/cmake/DownloadAndExtractFile.cmake:77 (message):
      error: downloading
      'http://www.leonerd.org.uk/code/libtermkey/libtermkey-0.21.1.tar.gz' failed
        status_code: 6
        status_string: "Couldn't resolve host name"
        log: Curl_ipv4_resolve_r failed for www.leonerd.org.uk
      Couldn't resolve host 'www.leonerd.org.uk'
      Closing connection 0

Co-Authored-By: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
Daniel Hahler 2019-07-24 19:11:27 +02:00 committed by GitHub
parent 431cf56e2f
commit 8404e8df20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -74,11 +74,26 @@ list(GET status 0 status_code)
list(GET status 1 status_string)
if(NOT status_code EQUAL 0)
message(FATAL_ERROR "error: downloading '${URL}' failed
# Retry on certain errors, e.g. CURLE_COULDNT_RESOLVE_HOST, which is often
# seen with libtermkey (www.leonerd.org.uk).
if(status_code EQUAL 6) # "Couldn't resolve host name"
message(STATUS "warning: retrying '${URL}' (${status_string}, status ${status_code})")
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 10)
file(DOWNLOAD ${URL} ${file}
${timeout_args}
${hash_args}
STATUS status
LOG log)
list(GET status 0 status_code)
list(GET status 1 status_string)
endif()
if(NOT status_code EQUAL 0)
message(FATAL_ERROR "error: downloading '${URL}' failed
status_code: ${status_code}
status_string: ${status_string}
log: ${log}
")
endif()
endif()
set(NULL_SHA256 "0000000000000000000000000000000000000000000000000000000000000000")