diff options
author | John Szakmeister <john@szakmeister.net> | 2015-02-06 17:30:02 -0500 |
---|---|---|
committer | John Szakmeister <john@szakmeister.net> | 2015-02-09 06:30:17 -0500 |
commit | 2019380bfae3cd8609c7f8b57d27a934370a5e8e (patch) | |
tree | 69d7757ef9878fcc648516328898b64928a619fd /third-party/cmake/DownloadAndExtractFile.cmake | |
parent | 28dcfcf325d222ae311bf972997c92bc1efd3e8f (diff) | |
download | rneovim-2019380bfae3cd8609c7f8b57d27a934370a5e8e.tar.gz rneovim-2019380bfae3cd8609c7f8b57d27a934370a5e8e.tar.bz2 rneovim-2019380bfae3cd8609c7f8b57d27a934370a5e8e.zip |
build: split hash checking from the download step
It turns out that `file(DOWNLOAD ...)` is not very user friendly with
it's error message, and only supports MD5 on v2.8.10 of CMake (the
default for Ubuntu 12.04). If CMake is built without SSL support,
users are left hanging with a message that the hashes don't match.
It turns out that `file(SHA1 ...)` exists in v2.8.10, and we
can use that to compute the hash ourselves. So this splits the hash
checking into a separate step, where we can provide some additional
advice if the SHA1 is the hash for an empty file. Additionally, it also
allows us to drop the MD5 hashes and maintain only SHA1 hashes for our
dependencies.
Diffstat (limited to 'third-party/cmake/DownloadAndExtractFile.cmake')
-rw-r--r-- | third-party/cmake/DownloadAndExtractFile.cmake | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/third-party/cmake/DownloadAndExtractFile.cmake b/third-party/cmake/DownloadAndExtractFile.cmake index b0d28355cb..bdf8742af1 100644 --- a/third-party/cmake/DownloadAndExtractFile.cmake +++ b/third-party/cmake/DownloadAndExtractFile.cmake @@ -10,8 +10,8 @@ if(NOT DEFINED DOWNLOAD_DIR) message(FATAL_ERROR "DOWNLOAD_DIR must be defined.") endif() -if((NOT DEFINED EXPECTED_SHA1) OR (NOT DEFINED EXPECTED_MD5)) - message(FATAL_ERROR "EXPECTED_SHA1 or EXPECTED_MD5 must be defined.") +if(NOT DEFINED EXPECTED_SHA1) + message(FATAL_ERROR "EXPECTED_SHA1 must be defined.") endif() if(NOT DEFINED TARGET) @@ -58,16 +58,6 @@ message(STATUS "downloading... dst='${file}' timeout='${timeout_msg}'") -if((DEFINED EXPECTED_SHA1) AND (${CMAKE_VERSION} VERSION_GREATER 2.8.10)) - if(NOT (EXPECTED_SHA1 STREQUAL "0000000000000000000000000000000000000000")) - set(hash_args EXPECTED_HASH SHA1=${EXPECTED_SHA1}) - endif() -else() - if(NOT (EXPECTED_MD5 STREQUAL "00000000000000000000000000000000")) - set(hash_args EXPECTED_MD5 ${EXPECTED_MD5}) - endif() -endif() - file(DOWNLOAD ${URL} ${file} ${timeout_args} ${hash_args} @@ -85,6 +75,27 @@ if(NOT status_code EQUAL 0) ") endif() +set(NULL_SHA1 "0000000000000000000000000000000000000000") + +# We could avoid computing the SHA1 entirely if a NULL_SHA1 was given, +# but we want to warn users of an empty file. +file(SHA1 ${file} ACTUAL_SHA1) +if(ACTUAL_SHA1 STREQUAL "da39a3ee5e6b4b0d3255bfef95601890afd80709") + # File was empty. It's likely due to lack of SSL support. + message(FATAL_ERROR + "Failed to download ${URL}. The file is empty and likely means CMake " + "was built without SSL support. Please use a version of CMake with " + "proper SSL support. See " + "https://github.com/neovim/neovim/wiki/Building-Neovim#build-prerequisites " + "for more information.") +elseif((NOT EXPECTED_SHA1 STREQUAL NULL_SHA1) AND + (NOT EXPECTED_SHA1 STREQUAL ACTUAL_SHA1)) + # Wasn't a NULL SHA1 and we didn't match, so we fail. + message(FATAL_ERROR + "Failed to download ${URL}. Expected a SHA1 of " + "${EXPECTED_SHA1} but got ${ACTUAL_SHA1} instead.") +endif() + message(STATUS "downloading... done") # Slurped from a generated extract-TARGET.cmake file. @@ -140,4 +151,3 @@ message(STATUS "extracting... [clean up]") file(REMOVE_RECURSE "${ut_dir}") message(STATUS "extracting... done") - |