mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 02:33:07 +08:00
[vcpkg_download_distfile] Fix the parameter mismatch issues of some internal functions and fix the recursive call (step 3) (#20585)
* [vcpkg_download_distfile] Fix incorrect arguments in z_vcpkg_download_distfile_test_hash * Add parameter DISABLE_AIRA2 to avoid recursive calls * Pass SKIP_SHA512 * Update doc * typo * Use downloaded aria2, fix download for multiple url * typo * Update vcpkg min release version 2021-11-02 Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
This commit is contained in:
parent
f35e0e3291
commit
520b5c4851
@ -107,49 +107,63 @@ function(z_vcpkg_download_distfile_show_proxy_and_fail error_code)
|
|||||||
" Otherwise, please submit an issue at https://github.com/Microsoft/vcpkg/issues\n")
|
" Otherwise, please submit an issue at https://github.com/Microsoft/vcpkg/issues\n")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(z_vcpkg_download_distfile_via_aria filename urls headers sha512 skip_sha512)
|
function(z_vcpkg_download_distfile_via_aria)
|
||||||
vcpkg_find_acquire_program(ARIA2)
|
cmake_parse_arguments(PARSE_ARGV 1 arg
|
||||||
message(STATUS "Downloading ${filename}...")
|
"SKIP_SHA512"
|
||||||
|
"FILENAME;SHA512"
|
||||||
|
"URLS;HEADERS"
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS "Downloading ${arg_FILENAME}...")
|
||||||
|
|
||||||
vcpkg_list(SET headers_param)
|
vcpkg_list(SET headers_param)
|
||||||
foreach(header IN LISTS headers)
|
foreach(header IN LISTS arg_HEADERS)
|
||||||
vcpkg_list(APPEND headers_param "--header=${header}")
|
vcpkg_list(APPEND headers_param "--header=${header}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
vcpkg_execute_in_download_mode(
|
foreach(URL IN LISTS arg_URLS)
|
||||||
COMMAND ${ARIA2} ${urls}
|
debug_message("Download Command: ${ARIA2} ${URL} -o temp/${filename} -l download-${filename}-detailed.log ${headers_param}")
|
||||||
-o temp/${filename}
|
vcpkg_execute_in_download_mode(
|
||||||
-l download-${filename}-detailed.log
|
COMMAND ${ARIA2} ${URL}
|
||||||
${headers_param}
|
-o temp/${arg_FILENAME}
|
||||||
OUTPUT_FILE download-${filename}-out.log
|
-l download-${arg_FILENAME}-detailed.log
|
||||||
ERROR_FILE download-${filename}-err.log
|
${headers_param}
|
||||||
RESULT_VARIABLE error_code
|
OUTPUT_FILE download-${arg_FILENAME}-out.log
|
||||||
WORKING_DIRECTORY "${DOWNLOADS}"
|
ERROR_FILE download-${arg_FILENAME}-err.log
|
||||||
)
|
RESULT_VARIABLE error_code
|
||||||
|
WORKING_DIRECTORY "${DOWNLOADS}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if ("${error_code}" STREQUAL "0")
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
if (NOT "${error_code}" STREQUAL "0")
|
if (NOT "${error_code}" STREQUAL "0")
|
||||||
message(STATUS
|
message(STATUS
|
||||||
"Downloading ${filename}... Failed.\n"
|
"Downloading ${arg_FILENAME}... Failed.\n"
|
||||||
" Exit Code: ${error_code}\n"
|
" Exit Code: ${error_code}\n"
|
||||||
" See logs for more information:\n"
|
" See logs for more information:\n"
|
||||||
" ${DOWNLOADS}/download-${filename}-out.log\n"
|
" ${DOWNLOADS}/download-${arg_FILENAME}-out.log\n"
|
||||||
" ${DOWNLOADS}/download-${filename}-err.log\n"
|
" ${DOWNLOADS}/download-${arg_FILENAME}-err.log\n"
|
||||||
" ${DOWNLOADS}/download-${filename}-detailed.log\n"
|
" ${DOWNLOADS}/download-${arg_FILENAME}-detailed.log\n"
|
||||||
)
|
)
|
||||||
z_vcpkg_download_distfile_show_proxy_and_fail()
|
z_vcpkg_download_distfile_show_proxy_and_fail("${error_code}")
|
||||||
else()
|
else()
|
||||||
z_vcpkg_download_distfile_test_hash(
|
z_vcpkg_download_distfile_test_hash(
|
||||||
"${DOWNLOADS}/temp/${filename}"
|
"${DOWNLOADS}/temp/${arg_FILENAME}"
|
||||||
"downloaded file"
|
"downloaded file"
|
||||||
"The file may have been corrupted in transit."
|
"The file may have been corrupted in transit."
|
||||||
|
"${arg_SHA512}"
|
||||||
|
${arg_SKIP_SHA512}
|
||||||
)
|
)
|
||||||
file(REMOVE
|
file(REMOVE
|
||||||
${DOWNLOADS}/download-${filename}-out.log
|
${DOWNLOADS}/download-${arg_FILENAME}-out.log
|
||||||
${DOWNLOADS}/download-${filename}-err.log
|
${DOWNLOADS}/download-${arg_FILENAME}-err.log
|
||||||
${DOWNLOADS}/download-${filename}-detailed.log
|
${DOWNLOADS}/download-${arg_FILENAME}-detailed.log
|
||||||
)
|
)
|
||||||
get_filename_component(downloaded_file_dir "${downloaded_file_path}" DIRECTORY)
|
get_filename_component(downloaded_file_dir "${downloaded_file_path}" DIRECTORY)
|
||||||
file(MAKE_DIRECTORY "${downloaded_file_dir}")
|
file(MAKE_DIRECTORY "${downloaded_file_dir}")
|
||||||
file(RENAME "${DOWNLOADS}/temp/${filename}" "${downloaded_file_path}")
|
file(RENAME "${DOWNLOADS}/temp/${arg_FILENAME}" "${downloaded_file_path}")
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
@ -241,13 +255,16 @@ If you do not know the SHA512, add it as 'SHA512 0' and re-run this command.")
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(_VCPKG_DOWNLOAD_TOOL STREQUAL "ARIA2" AND NOT EXISTS "${downloaded_file_path}")
|
if(NOT arg_DISABLE_ARIA2 AND _VCPKG_DOWNLOAD_TOOL STREQUAL "ARIA2" AND NOT EXISTS "${downloaded_file_path}")
|
||||||
|
if (arg_SKIP_SHA512)
|
||||||
|
set(OPTION_SKIP_SHA512 "SKIP_SHA512")
|
||||||
|
endif()
|
||||||
z_vcpkg_download_distfile_via_aria(
|
z_vcpkg_download_distfile_via_aria(
|
||||||
"${arg_FILENAME}"
|
"${OPTION_SKIP_SHA512}"
|
||||||
"${arg_URLS}"
|
FILENAME "${arg_FILENAME}"
|
||||||
"${arg_HEADERS}"
|
SHA512 "${arg_SHA512}"
|
||||||
"${arg_SHA512}"
|
URLS "${arg_URLS}"
|
||||||
"${arg_skip_sha512}"
|
HEADERS "${arg_HEADERS}"
|
||||||
)
|
)
|
||||||
set("${out_var}" "${downloaded_file_path}" PARENT_SCOPE)
|
set("${out_var}" "${downloaded_file_path}" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
|
@ -82,7 +82,7 @@ else()
|
|||||||
set(Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL "WARNING")
|
set(Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL "WARNING")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
vcpkg_minimum_required(VERSION 2021-08-03)
|
vcpkg_minimum_required(VERSION 2021-11-02)
|
||||||
|
|
||||||
file(TO_CMAKE_PATH "${BUILDTREES_DIR}" BUILDTREES_DIR)
|
file(TO_CMAKE_PATH "${BUILDTREES_DIR}" BUILDTREES_DIR)
|
||||||
file(TO_CMAKE_PATH "${PACKAGES_DIR}" PACKAGES_DIR)
|
file(TO_CMAKE_PATH "${PACKAGES_DIR}" PACKAGES_DIR)
|
||||||
|
Loading…
Reference in New Issue
Block a user