diff options
author | Brad King <brad.king@kitware.com> | 2020-08-19 15:47:26 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-08-19 15:47:34 (GMT) |
commit | fed08ce4cf167c442bb65e562ff8b8de80f55c44 (patch) | |
tree | 65997991dbd8609ca5f0e1c6fedf8231fe5903c8 /Modules | |
parent | f1ec88708d87eba533e7b4dcb852753afa27ab0b (diff) | |
parent | 116b06870d1645df63a4df91bb29d03bdafc5c50 (diff) | |
download | CMake-fed08ce4cf167c442bb65e562ff8b8de80f55c44.zip CMake-fed08ce4cf167c442bb65e562ff8b8de80f55c44.tar.gz CMake-fed08ce4cf167c442bb65e562ff8b8de80f55c44.tar.bz2 |
Merge topic 'ExternalProject-retry-only-recoverable'
116b06870d ExternalProject: add INACTIVITY_TIMEOUT argument
f24e34975a ExternalProject: retry download on recoverable errors
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5034
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/ExternalProject-download.cmake.in | 75 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 16 |
2 files changed, 57 insertions, 34 deletions
diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in index 99fb917..ff8c659 100644 --- a/Modules/ExternalProject-download.cmake.in +++ b/Modules/ExternalProject-download.cmake.in @@ -105,54 +105,65 @@ set(retry_number 5) message(STATUS "Downloading... dst='@LOCAL@' - timeout='@TIMEOUT_MSG@'" + timeout='@TIMEOUT_MSG@' + inactivity timeout='@INACTIVITY_TIMEOUT_MSG@'" ) - +set(download_retry_codes 7 6 8 15) +set(skip_url_list) +set(status_code) foreach(i RANGE ${retry_number}) - sleep_before_download(${i}) - + if(status_code IN_LIST download_retry_codes) + sleep_before_download(${i}) + endif() foreach(url @REMOTE@) - message(STATUS "Using src='${url}'") + if(NOT url IN_LIST skip_url_list) + message(STATUS "Using src='${url}'") - @TLS_VERIFY_CODE@ - @TLS_CAINFO_CODE@ - @NETRC_CODE@ - @NETRC_FILE_CODE@ + @TLS_VERIFY_CODE@ + @TLS_CAINFO_CODE@ + @NETRC_CODE@ + @NETRC_FILE_CODE@ - file( + file( DOWNLOAD "${url}" "@LOCAL@" @SHOW_PROGRESS@ @TIMEOUT_ARGS@ + @INACTIVITY_TIMEOUT_ARGS@ STATUS status LOG log @USERPWD_ARGS@ @HTTP_HEADERS_ARGS@ - ) - - list(GET status 0 status_code) - list(GET status 1 status_string) - - if(status_code EQUAL 0) - check_file_hash(has_hash hash_is_good) - if(has_hash AND NOT hash_is_good) - message(STATUS "Hash mismatch, removing...") - file(REMOVE "@LOCAL@") + ) + + list(GET status 0 status_code) + list(GET status 1 status_string) + + if(status_code EQUAL 0) + check_file_hash(has_hash hash_is_good) + if(has_hash AND NOT hash_is_good) + message(STATUS "Hash mismatch, removing...") + file(REMOVE "@LOCAL@") + else() + message(STATUS "Downloading... done") + return() + endif() else() - message(STATUS "Downloading... done") - return() + string(APPEND logFailedURLs "error: downloading '${url}' failed + status_code: ${status_code} + status_string: ${status_string} + log: + --- LOG BEGIN --- + ${log} + --- LOG END --- + " + ) + if(NOT status_code IN_LIST download_retry_codes) + list(APPEND skip_url_list "${url}") + break() endif() - else() - string(APPEND logFailedURLs "error: downloading '${url}' failed - status_code: ${status_code} - status_string: ${status_string} - log: - --- LOG BEGIN --- - ${log} - --- LOG END --- - " - ) endif() + endif() endforeach() endforeach() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index fcff5dd..96edbef 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -179,6 +179,9 @@ External Project Definition ``TIMEOUT <seconds>`` Maximum time allowed for file download operations. + ``INACTIVITY_TIMEOUT <seconds>`` + Terminate the operation after a period of inactivity. + ``HTTP_USERNAME <username>`` Username for the download operation if authentication is required. @@ -1300,7 +1303,7 @@ function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_r ) endfunction() -function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file) +function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout inactivity_timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file) if(timeout) set(TIMEOUT_ARGS TIMEOUT ${timeout}) set(TIMEOUT_MSG "${timeout} seconds") @@ -1308,6 +1311,14 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p set(TIMEOUT_ARGS "# no TIMEOUT") set(TIMEOUT_MSG "none") endif() + if(inactivity_timeout) + set(INACTIVITY_TIMEOUT_ARGS INACTIVITY_TIMEOUT ${inactivity_timeout}) + set(INACTIVITY_TIMEOUT_MSG "${inactivity_timeout} seconds") + else() + set(INACTIVITY_TIMEOUT_ARGS "# no INACTIVITY_TIMEOUT") + set(INACTIVITY_TIMEOUT_MSG "none") + endif() + if(no_progress) set(SHOW_PROGRESS "") @@ -2512,6 +2523,7 @@ function(_ep_add_download_command name) string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) + get_property(inactivity_timeout TARGET ${name} PROPERTY _EP_INACTIVITY_TIMEOUT) get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) @@ -2521,7 +2533,7 @@ function(_ep_add_download_command name) get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD) get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER) set(download_script "${stamp_dir}/download-${name}.cmake") - _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${inactivity_timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}") set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) if (no_extract) |