|
@@ -79,77 +79,81 @@ if("@REMOTE@" STREQUAL "")
|
|
|
message(FATAL_ERROR "REMOTE can't be empty")
|
|
message(FATAL_ERROR "REMOTE can't be empty")
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
|
-if(EXISTS "@LOCAL@")
|
|
|
|
|
- check_file_hash(has_hash hash_is_good)
|
|
|
|
|
- if(has_hash)
|
|
|
|
|
- if(hash_is_good)
|
|
|
|
|
- message(STATUS "File already exists and hash match (skip download):
|
|
|
|
|
|
|
+function(download_and_verify)
|
|
|
|
|
+ if(EXISTS "@LOCAL@")
|
|
|
|
|
+ check_file_hash(has_hash hash_is_good)
|
|
|
|
|
+ if(has_hash)
|
|
|
|
|
+ if(hash_is_good)
|
|
|
|
|
+ message(STATUS
|
|
|
|
|
+"File already exists and hash match (skip download):
|
|
|
file='@LOCAL@'
|
|
file='@LOCAL@'
|
|
|
@ALGO@='@EXPECT_VALUE@'"
|
|
@ALGO@='@EXPECT_VALUE@'"
|
|
|
- )
|
|
|
|
|
- return()
|
|
|
|
|
|
|
+ )
|
|
|
|
|
+ return()
|
|
|
|
|
+ else()
|
|
|
|
|
+ message(STATUS "File already exists but hash mismatch. Removing...")
|
|
|
|
|
+ file(REMOVE "@LOCAL@")
|
|
|
|
|
+ endif()
|
|
|
else()
|
|
else()
|
|
|
- message(STATUS "File already exists but hash mismatch. Removing...")
|
|
|
|
|
- file(REMOVE "@LOCAL@")
|
|
|
|
|
- endif()
|
|
|
|
|
- else()
|
|
|
|
|
- message(STATUS "File already exists but no hash specified (use URL_HASH):
|
|
|
|
|
|
|
+ message(STATUS
|
|
|
|
|
+"File already exists but no hash specified (use URL_HASH):
|
|
|
file='@LOCAL@'
|
|
file='@LOCAL@'
|
|
|
Old file will be removed and new file downloaded from URL."
|
|
Old file will be removed and new file downloaded from URL."
|
|
|
- )
|
|
|
|
|
- file(REMOVE "@LOCAL@")
|
|
|
|
|
|
|
+ )
|
|
|
|
|
+ file(REMOVE "@LOCAL@")
|
|
|
|
|
+ endif()
|
|
|
endif()
|
|
endif()
|
|
|
-endif()
|
|
|
|
|
|
|
|
|
|
-set(retry_number 5)
|
|
|
|
|
|
|
+ set(retry_number 5)
|
|
|
|
|
|
|
|
-message(STATUS "Downloading...
|
|
|
|
|
|
|
+ message(STATUS "Downloading...
|
|
|
dst='@LOCAL@'
|
|
dst='@LOCAL@'
|
|
|
timeout='@TIMEOUT_MSG@'
|
|
timeout='@TIMEOUT_MSG@'
|
|
|
inactivity timeout='@INACTIVITY_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})
|
|
|
|
|
- if(status_code IN_LIST download_retry_codes)
|
|
|
|
|
- sleep_before_download(${i})
|
|
|
|
|
- endif()
|
|
|
|
|
- foreach(url @REMOTE@)
|
|
|
|
|
- if(NOT url IN_LIST skip_url_list)
|
|
|
|
|
- message(STATUS "Using src='${url}'")
|
|
|
|
|
-
|
|
|
|
|
- @TLS_VERIFY_CODE@
|
|
|
|
|
- @TLS_CAINFO_CODE@
|
|
|
|
|
- @NETRC_CODE@
|
|
|
|
|
- @NETRC_FILE_CODE@
|
|
|
|
|
-
|
|
|
|
|
- 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@")
|
|
|
|
|
|
|
+ )
|
|
|
|
|
+ set(download_retry_codes 7 6 8 15)
|
|
|
|
|
+ set(skip_url_list)
|
|
|
|
|
+ set(status_code)
|
|
|
|
|
+ foreach(i RANGE ${retry_number})
|
|
|
|
|
+ if(status_code IN_LIST download_retry_codes)
|
|
|
|
|
+ sleep_before_download(${i})
|
|
|
|
|
+ endif()
|
|
|
|
|
+ foreach(url @REMOTE@)
|
|
|
|
|
+ if(NOT url IN_LIST skip_url_list)
|
|
|
|
|
+ message(STATUS "Using src='${url}'")
|
|
|
|
|
+
|
|
|
|
|
+ @TLS_VERIFY_CODE@
|
|
|
|
|
+ @TLS_CAINFO_CODE@
|
|
|
|
|
+ @NETRC_CODE@
|
|
|
|
|
+ @NETRC_FILE_CODE@
|
|
|
|
|
+
|
|
|
|
|
+ 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@")
|
|
|
|
|
+ else()
|
|
|
|
|
+ message(STATUS "Downloading... done")
|
|
|
|
|
+ return()
|
|
|
|
|
+ endif()
|
|
|
else()
|
|
else()
|
|
|
- message(STATUS "Downloading... done")
|
|
|
|
|
- return()
|
|
|
|
|
- endif()
|
|
|
|
|
- else()
|
|
|
|
|
- string(APPEND logFailedURLs "error: downloading '${url}' failed
|
|
|
|
|
|
|
+ string(APPEND logFailedURLs
|
|
|
|
|
+"error: downloading '${url}' failed
|
|
|
status_code: ${status_code}
|
|
status_code: ${status_code}
|
|
|
status_string: ${status_string}
|
|
status_string: ${status_string}
|
|
|
log:
|
|
log:
|
|
@@ -157,17 +161,27 @@ foreach(i RANGE ${retry_number})
|
|
|
${log}
|
|
${log}
|
|
|
--- LOG END ---
|
|
--- LOG END ---
|
|
|
"
|
|
"
|
|
|
- )
|
|
|
|
|
- if(NOT status_code IN_LIST download_retry_codes)
|
|
|
|
|
- list(APPEND skip_url_list "${url}")
|
|
|
|
|
- break()
|
|
|
|
|
|
|
+ )
|
|
|
|
|
+ if(NOT status_code IN_LIST download_retry_codes)
|
|
|
|
|
+ list(APPEND skip_url_list "${url}")
|
|
|
|
|
+ break()
|
|
|
|
|
+ endif()
|
|
|
endif()
|
|
endif()
|
|
|
endif()
|
|
endif()
|
|
|
- endif()
|
|
|
|
|
|
|
+ endforeach()
|
|
|
endforeach()
|
|
endforeach()
|
|
|
-endforeach()
|
|
|
|
|
|
|
|
|
|
-message(FATAL_ERROR "Each download failed!
|
|
|
|
|
|
|
+ message(FATAL_ERROR
|
|
|
|
|
+"Each download failed!
|
|
|
${logFailedURLs}
|
|
${logFailedURLs}
|
|
|
"
|
|
"
|
|
|
-)
|
|
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+endfunction()
|
|
|
|
|
+
|
|
|
|
|
+download_and_verify()
|
|
|
|
|
+
|
|
|
|
|
+set(extract_script @extract_script_filename@)
|
|
|
|
|
+if(NOT "${extract_script}" STREQUAL "")
|
|
|
|
|
+ include(${extract_script})
|
|
|
|
|
+endif()
|