diff options
author | Brad King <brad.king@kitware.com> | 2012-09-19 15:28:00 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-09-19 15:31:36 (GMT) |
commit | 95a00116044ed52d92c20a467b9266476eb56632 (patch) | |
tree | d2770725839951940c45e21fed4cf4c76e4fcc79 /Source | |
parent | d407dcdbc824688510837ec85bb2e3c85cf096bd (diff) | |
download | CMake-95a00116044ed52d92c20a467b9266476eb56632.zip CMake-95a00116044ed52d92c20a467b9266476eb56632.tar.gz CMake-95a00116044ed52d92c20a467b9266476eb56632.tar.bz2 |
file(DOWNLOAD): Change EXPECTED_HASH to take ALGO=value
Make the EXPECTED_HASH option take only a single value instead of two to
avoid handling sub-keyword arguments. This is also consistent with
URL_HASH in ExternalProject.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFileCommand.cxx | 35 | ||||
-rw-r--r-- | Source/cmFileCommand.h | 12 |
2 files changed, 24 insertions, 23 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 4d9eb79..1a66d82 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2767,30 +2767,31 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) else if(*i == "EXPECTED_HASH") { ++i; - if(i != args.end()) + if(i == args.end()) { - hash = cmsys::auto_ptr<cmCryptoHash>(cmCryptoHash::New(i->c_str())); - if(!hash.get()) - { - std::string err = "DOWNLOAD bad SHA type: "; - err += *i; - this->SetError(err.c_str()); - return false; - } - hashMatchMSG = *i; - hashMatchMSG += " hash"; - - ++i; + this->SetError("DOWNLOAD missing ALGO=value for EXPECTED_HASH."); + return false; } - if(i != args.end()) + std::string::size_type pos = i->find("="); + if(pos == std::string::npos) { - expectedHash = cmSystemTools::LowerCase(*i); + std::string err = + "DOWNLOAD EXPECTED_HASH expects ALGO=value but got: "; + err += *i; + this->SetError(err.c_str()); + return false; } - else + std::string algo = i->substr(0, pos); + expectedHash = cmSystemTools::LowerCase(i->substr(pos+1)); + hash = cmsys::auto_ptr<cmCryptoHash>(cmCryptoHash::New(algo.c_str())); + if(!hash.get()) { - this->SetError("DOWNLOAD missing time for EXPECTED_HASH."); + std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: "; + err += algo; + this->SetError(err.c_str()); return false; } + hashMatchMSG = algo + " hash"; } ++i; } diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index bd6f612..b4aa903 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -83,8 +83,7 @@ public: " file(TO_NATIVE_PATH path result)\n" " file(DOWNLOAD url file [INACTIVITY_TIMEOUT timeout]\n" " [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS]\n" - " [EXPECTED_HASH MD5|SHA1|SHA224|SHA256|SHA384|SHA512 hash]\n" - " [EXPECTED_MD5 sum]\n" + " [EXPECTED_HASH ALGO=value] [EXPECTED_MD5 sum]\n" " [TLS_VERIFY on|off] [TLS_CAINFO file])\n" " file(UPLOAD filename url [INACTIVITY_TIMEOUT timeout]\n" " [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS])\n" @@ -170,10 +169,11 @@ public: "timeout after time seconds, time should be specified as an integer. " "The INACTIVITY_TIMEOUT specifies an integer number of seconds of " "inactivity after which the operation should terminate. " - "If EXPECTED_HASH is specified, the operation will verify that the " - "downloaded file's actual hash matches the expected value. If it " - "does not match, the operation fails with an error. " - "(EXPECTED_MD5 is short-hand for EXPECTED_HASH MD5.) " + "If EXPECTED_HASH ALGO=value is specified, the operation will verify " + "that the downloaded file's actual hash matches the expected value, " + "where ALGO is one of MD5, SHA1, SHA224, SHA256, SHA384, or SHA512. " + "If it does not match, the operation fails with an error. " + "(\"EXPECTED_MD5 sum\" is short-hand for \"EXPECTED_HASH MD5=sum\".) " "If SHOW_PROGRESS is specified, progress information will be printed " "as status messages until the operation is complete. " "For https URLs CMake must be built with OpenSSL. " |