mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 08:37:54 +08:00
[vcpkg_from_sourceforge] Skip mirrors that are in 'disaster recovery' mode (#13176)
This commit is contained in:
parent
bf1d20cc8f
commit
68003004c0
@ -59,9 +59,6 @@ function(vcpkg_download_distfile VAR)
|
||||
message(FATAL_ERROR "vcpkg_download_distfile requires a FILENAME argument.")
|
||||
endif()
|
||||
if(NOT _VCPKG_INTERNAL_NO_HASH_CHECK)
|
||||
if(vcpkg_download_distfile_SKIP_SHA512 AND NOT VCPKG_USE_HEAD_VERSION)
|
||||
message(FATAL_ERROR "vcpkg_download_distfile only allows SKIP_SHA512 when building with --head")
|
||||
endif()
|
||||
if(NOT vcpkg_download_distfile_SKIP_SHA512 AND NOT DEFINED vcpkg_download_distfile_SHA512)
|
||||
message(FATAL_ERROR "vcpkg_download_distfile requires a SHA512 argument. If you do not know the SHA512, add it as 'SHA512 0' and re-run this command.")
|
||||
endif()
|
||||
|
@ -65,6 +65,34 @@
|
||||
## * [tinyfiledialogs](https://github.com/Microsoft/vcpkg/blob/master/ports/tinyfiledialogs/portfile.cmake)
|
||||
|
||||
function(vcpkg_from_sourceforge)
|
||||
macro(check_file_content)
|
||||
if (EXISTS ${ARCHIVE})
|
||||
file(SIZE ${ARCHIVE} DOWNLOAD_FILE_SIZE)
|
||||
if (DOWNLOAD_FILE_SIZE LESS_EQUAL 1024)
|
||||
file(READ ${ARCHIVE} _FILE_CONTENT_)
|
||||
string(FIND "${_FILE_CONTENT_}" "the Sourceforge site is currently in Disaster Recovery mode." OUT_CONTENT)
|
||||
message("OUT_CONTENT: ${OUT_CONTENT}")
|
||||
if (OUT_CONTENT EQUAL -1)
|
||||
set(download_success 1)
|
||||
else()
|
||||
file(REMOVE ${ARCHIVE})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(check_file_sha512)
|
||||
file(SHA512 ${ARCHIVE} FILE_HASH)
|
||||
if(NOT FILE_HASH STREQUAL _vdus_SHA512)
|
||||
message(FATAL_ERROR
|
||||
"\nFile does not have expected hash:\n"
|
||||
" File path: [ ${ARCHIVE} ]\n"
|
||||
" Expected hash: [ ${_vdus_SHA512} ]\n"
|
||||
" Actual hash: [ ${FILE_HASH} ]\n"
|
||||
"${CUSTOM_ERROR_ADVICE}\n")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
set(booleanValueArgs DISABLE_SSL NO_REMOVE_ONE_LEVEL)
|
||||
set(oneValueArgs OUT_SOURCE_PATH REPO REF SHA512 FILENAME WORKING_DIRECTORY)
|
||||
set(multipleValuesArgs PATCHES)
|
||||
@ -151,13 +179,15 @@ function(vcpkg_from_sourceforge)
|
||||
message(STATUS "Trying auto-select mirror...")
|
||||
vcpkg_download_distfile(ARCHIVE
|
||||
URLS "${DOWNLOAD_URL}"
|
||||
SHA512 "${_vdus_SHA512}"
|
||||
SKIP_SHA512
|
||||
FILENAME "${_vdus_FILENAME}"
|
||||
SILENT_EXIT
|
||||
)
|
||||
|
||||
if (EXISTS ${ARCHIVE})
|
||||
set(download_success 1)
|
||||
check_file_content()
|
||||
if (download_success)
|
||||
check_file_sha512()
|
||||
else()
|
||||
message(STATUS "The default mirror is in Disaster Recovery mode, trying other mirrors...")
|
||||
endif()
|
||||
|
||||
if (NOT download_success EQUAL 1)
|
||||
@ -166,13 +196,19 @@ function(vcpkg_from_sourceforge)
|
||||
message(STATUS "Trying mirror ${SOURCEFORGE_MIRROR}...")
|
||||
vcpkg_download_distfile(ARCHIVE
|
||||
URLS "${DOWNLOAD_URL}"
|
||||
SHA512 "${_vdus_SHA512}"
|
||||
SKIP_SHA512
|
||||
FILENAME "${_vdus_FILENAME}"
|
||||
SILENT_EXIT
|
||||
)
|
||||
|
||||
if (EXISTS ${ARCHIVE})
|
||||
set(download_success 1)
|
||||
check_file_content()
|
||||
if (download_success)
|
||||
check_file_sha512()
|
||||
else()
|
||||
message(STATUS "Mirror ${SOURCEFORGE_MIRROR} is in Disaster Recovery mode, trying other mirrors...")
|
||||
endif()
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
Loading…
Reference in New Issue
Block a user