aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-11-03 14:34:08 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-11-03 15:02:53 -0700
commit8bbd043beac822c20c54e6f2ee686777c9a20ac9 (patch)
tree0f2b68157226a36eebb8fd5e3e509c3e7c729714 /scripts
parent76d4666f12cbce4a52123cc41d489dfa4ce4bbba (diff)
downloadvcpkg-8bbd043beac822c20c54e6f2ee686777c9a20ac9.tar.gz
vcpkg-8bbd043beac822c20c54e6f2ee686777c9a20ac9.zip
vcpkg_from_github] Use vcpkg_download_distfile()
Diffstat (limited to 'scripts')
-rw-r--r--scripts/cmake/vcpkg_download_distfile.cmake4
-rw-r--r--scripts/cmake/vcpkg_from_github.cmake33
2 files changed, 17 insertions, 20 deletions
diff --git a/scripts/cmake/vcpkg_download_distfile.cmake b/scripts/cmake/vcpkg_download_distfile.cmake
index 0141e9811..b22d82a16 100644
--- a/scripts/cmake/vcpkg_download_distfile.cmake
+++ b/scripts/cmake/vcpkg_download_distfile.cmake
@@ -46,6 +46,10 @@ function(vcpkg_download_distfile VAR)
file(MAKE_DIRECTORY "${DOWNLOADS}/temp")
function(test_hash FILE_KIND CUSTOM_ERROR_ADVICE)
+ if (_VCPKG_INTERNAL_NO_HASH_CHECK)
+ return()
+ endif()
+
message(STATUS "Testing integrity of ${FILE_KIND}...")
file(SHA512 ${downloaded_file_path} FILE_HASH)
if(NOT "${FILE_HASH}" STREQUAL "${vcpkg_download_distfile_SHA512}")
diff --git a/scripts/cmake/vcpkg_from_github.cmake b/scripts/cmake/vcpkg_from_github.cmake
index d14077410..1ede43fd8 100644
--- a/scripts/cmake/vcpkg_from_github.cmake
+++ b/scripts/cmake/vcpkg_from_github.cmake
@@ -113,7 +113,8 @@ function(vcpkg_from_github)
# The following is for --head scenarios
set(URL "https://github.com/${ORG_NAME}/${REPO_NAME}/archive/${_vdud_HEAD_REF}.tar.gz")
- set(downloaded_file_path "${DOWNLOADS}/${ORG_NAME}-${REPO_NAME}-${_vdud_HEAD_REF}.tar.gz")
+ set(downloaded_file_name "${ORG_NAME}-${REPO_NAME}-${_vdud_HEAD_REF}.tar.gz")
+ set(downloaded_file_path "${DOWNLOADS}/${downloaded_file_name}")
if(_VCPKG_NO_DOWNLOADS)
if(NOT EXISTS ${downloaded_file_path} OR NOT EXISTS ${downloaded_file_path}.version)
@@ -133,35 +134,27 @@ function(vcpkg_from_github)
endif()
# Try to download the file and version information from github.
- message(STATUS "Downloading ${URL}...")
- file(DOWNLOAD "https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/git/refs/heads/${_vdud_HEAD_REF}"
- ${downloaded_file_path}.version
- STATUS download_status
+ set(_VCPKG_INTERNAL_NO_HASH_CHECK "TRUE")
+ vcpkg_download_distfile(ARCHIVE_VERSION
+ URLS "https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/git/refs/heads/${_vdud_HEAD_REF}"
+ FILENAME ${downloaded_file_name}.version
)
- list(GET download_status 0 status_code)
- if (NOT "${status_code}" STREQUAL "0")
- file(REMOVE ${downloaded_file_path}.version)
- message(FATAL_ERROR "Downloading version info for ${URL}... Failed. Status: ${download_status}")
- endif()
- file(DOWNLOAD ${URL} ${downloaded_file_path} STATUS download_status)
- list(GET download_status 0 status_code)
- if (NOT "${status_code}" STREQUAL "0")
- file(REMOVE ${downloaded_file_path})
- message(FATAL_ERROR "Downloading ${URL}... Failed. Status: ${download_status}")
- else()
- message(STATUS "Downloading ${URL}... OK")
- endif()
+ vcpkg_download_distfile(ARCHIVE
+ URLS ${URL}
+ FILENAME ${downloaded_file_name}
+ )
+ set(_VCPKG_INTERNAL_NO_HASH_CHECK "FALSE")
endif()
vcpkg_extract_source_archive_ex(
- ARCHIVE "${downloaded_file_path}"
+ ARCHIVE "${ARCHIVE}"
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/src/head"
)
# Parse the github refs response with regex.
# TODO: use some JSON swiss-army-knife utility instead.
- file(READ "${downloaded_file_path}.version" _contents)
+ file(READ "${ARCHIVE_VERSION}" _contents)
string(REGEX MATCH "\"sha\": \"[a-f0-9]+\"" x "${_contents}")
string(REGEX REPLACE "\"sha\": \"([a-f0-9]+)\"" "\\1" _version ${x})