From 5d67e9025d1c7f1259477450831135667b6f1eeb Mon Sep 17 00:00:00 2001 From: Shane Parris Date: Wed, 18 Oct 2017 10:26:55 -0400 Subject: file(DOWNLOAD|UPLOAD): Add 'NETRC' and 'NETRC_FILE' suboption --- Auxiliary/vim/syntax/cmake.vim | 2 +- Help/command/file.rst | 25 ++++++++++++++++ Help/manual/cmake-variables.7.rst | 2 ++ Help/variable/CMAKE_NETRC.rst | 9 ++++++ Help/variable/CMAKE_NETRC_FILE.rst | 9 ++++++ Source/cmCurl.cxx | 38 +++++++++++++++++++++++++ Source/cmCurl.h | 2 ++ Source/cmFileCommand.cxx | 58 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 Help/variable/CMAKE_NETRC.rst create mode 100644 Help/variable/CMAKE_NETRC_FILE.rst diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 5f9af05..d30c86e 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -149,7 +149,7 @@ syn keyword cmakeKWexport_library_dependencies contained \ APPEND EXPORT INCLUDE LINK_INTERFACE_LIBRARIES SET syn keyword cmakeKWfile contained - \ ALGO APPEND ASCII CMAKE_TLS_CAINFO CMAKE_TLS_VERIFY CONDITION CONFIG CONTENT COPY CR DESTINATION DIRECTORY_PERMISSIONS DOWNLOAD ENCODING EXCLUDE EXPECTED_HASH FILES_MATCHING FILE_PERMISSIONS FOLLOW_SYMLINKS FUNCTION GENERATE GLOB GLOB_RECURSE GUARD HASH HEX HTTPHEADER INACTIVITY_TIMEOUT INSTALL LENGTH_MAXIMUM LENGTH_MINIMUM LF LIMIT LIMIT_COUNT LIMIT_INPUT LIMIT_OUTPUT LIST_DIRECTORIES LOCK LOG MAKE_DIRECTORY NEWLINE_CONSUME NO_HEX_CONVERSION NO_SOURCE_PERMISSIONS OFFSET OLD PATTERN PROCESS READ REGEX RELATIVE RELATIVE_PATH RELEASE REMOVE REMOVE_RECURSE RENAME RESULT_VARIABLE SHOW_PROGRESS SSL STATUS STRINGS TIMESTAMP TLS_CAINFO TLS_VERIFY TO_CMAKE_PATH TO_NATIVE_PATH UPLOAD USERPWD USE_SOURCE_PERMISSIONS UTC UTF WRITE + \ ALGO APPEND ASCII CMAKE_TLS_CAINFO CMAKE_TLS_VERIFY CONDITION CONFIG CONTENT COPY CR DESTINATION DIRECTORY_PERMISSIONS DOWNLOAD ENCODING EXCLUDE EXPECTED_HASH FILES_MATCHING FILE_PERMISSIONS FOLLOW_SYMLINKS FUNCTION GENERATE GLOB GLOB_RECURSE GUARD HASH HEX HTTPHEADER INACTIVITY_TIMEOUT INSTALL LENGTH_MAXIMUM LENGTH_MINIMUM LF LIMIT LIMIT_COUNT LIMIT_INPUT LIMIT_OUTPUT LIST_DIRECTORIES LOCK LOG MAKE_DIRECTORY NETRC NETRC_FILE NEWLINE_CONSUME NO_HEX_CONVERSION NO_SOURCE_PERMISSIONS OFFSET OLD PATTERN PROCESS READ REGEX RELATIVE RELATIVE_PATH RELEASE REMOVE REMOVE_RECURSE RENAME RESULT_VARIABLE SHOW_PROGRESS SSL STATUS STRINGS TIMESTAMP TLS_CAINFO TLS_VERIFY TO_CMAKE_PATH TO_NATIVE_PATH UPLOAD USERPWD USE_SOURCE_PERMISSIONS UTC UTF WRITE syn keyword cmakeKWfind_file contained \ CMAKE_FIND_ROOT_PATH_BOTH DOC DVAR HINTS INCLUDE NAMES NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OS PATHS PATH_SUFFIXES VAR diff --git a/Help/command/file.rst b/Help/command/file.rst index edccac5..4d4ebb4 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -232,6 +232,31 @@ Options to both ``DOWNLOAD`` and ``UPLOAD`` are: ``HTTPHEADER `` HTTP header for operation. Suboption can be repeated several times. +``NETRC `` + Specify whether the .netrc file is to be used for operation. If this + option is not specified, the value of the ``CMAKE_NETRC`` variable + will be used instead. + Valid levels are: + + ``IGNORED`` + The .netrc file is ignored. + This is the default. + ``OPTIONAL`` + The .netrc file is optional, and information in the URL is preferred. + The file will be scanned to find which ever information is not specified + in the URL. + ``REQUIRED`` + The .netrc file is required, and information in the URL is ignored. + +``NETRC_FILE `` + Specify an alternative .netrc file to the one in your home directory, + if the ``NETRC`` level is ``OPTIONAL`` or ``REQUIRED``. If this option + is not specified, the value of the ``CMAKE_NETRC_FILE`` variable will + be used instead. + +If neither ``NETRC`` option is given CMake will check variables +``CMAKE_NETRC`` and ``CMAKE_NETRC_FILE``, respectively. + Additional options to ``DOWNLOAD`` are: ``EXPECTED_HASH ALGO=`` diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 2e369e3..3880bcf 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -60,6 +60,8 @@ Variables that Provide Information /variable/CMAKE_MATCH_n /variable/CMAKE_MINIMUM_REQUIRED_VERSION /variable/CMAKE_MINOR_VERSION + /variable/CMAKE_NETRC + /variable/CMAKE_NETRC_FILE /variable/CMAKE_PARENT_LIST_FILE /variable/CMAKE_PATCH_VERSION /variable/CMAKE_PROJECT_DESCRIPTION diff --git a/Help/variable/CMAKE_NETRC.rst b/Help/variable/CMAKE_NETRC.rst new file mode 100644 index 0000000..52f857e --- /dev/null +++ b/Help/variable/CMAKE_NETRC.rst @@ -0,0 +1,9 @@ +CMAKE_NETRC +----------- + +This variable is used to initialize the ``NETRC`` option for +:command:`file(DOWNLOAD)` and :command:`file(DOWNLOAD)` commands and the +module :module:`ExternalProject`. See those commands for additional +information. + +The local option takes precedence over this variable. diff --git a/Help/variable/CMAKE_NETRC_FILE.rst b/Help/variable/CMAKE_NETRC_FILE.rst new file mode 100644 index 0000000..1508f1e --- /dev/null +++ b/Help/variable/CMAKE_NETRC_FILE.rst @@ -0,0 +1,9 @@ +CMAKE_NETRC_FILE +---------------- + +This variable is used to initialize the ``NETRC_FILE`` option for +:command:`file(DOWNLOAD)` and :command:`file(DOWNLOAD)` commands and the +module :module:`ExternalProject`. See those commands for additional +information. + +The local option takes precedence over this variable. diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx index 341b8c0..8ef8bff 100644 --- a/Source/cmCurl.cxx +++ b/Source/cmCurl.cxx @@ -56,3 +56,41 @@ std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile) #endif return e; } + +std::string cmCurlSetNETRCOption(::CURL* curl, const std::string& netrc_level, + const std::string& netrc_file) +{ + std::string e; + CURL_NETRC_OPTION curl_netrc_level = CURL_NETRC_LAST; + ::CURLcode res; + + if (!netrc_level.empty()) { + if (netrc_level == "OPTIONAL") { + curl_netrc_level = CURL_NETRC_OPTIONAL; + } else if (netrc_level == "REQUIRED") { + curl_netrc_level = CURL_NETRC_REQUIRED; + } else if (netrc_level == "IGNORED") { + curl_netrc_level = CURL_NETRC_IGNORED; + } else { + e = "NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: "; + e += netrc_level; + return e; + } + } + + if (curl_netrc_level != CURL_NETRC_LAST && + curl_netrc_level != CURL_NETRC_IGNORED) { + res = ::curl_easy_setopt(curl, CURLOPT_NETRC, curl_netrc_level); + check_curl_result(res, "Unable to set netrc level: "); + if (!e.empty()) { + return e; + } + + // check to see if a .netrc file has been specified + if (!netrc_file.empty()) { + res = ::curl_easy_setopt(curl, CURLOPT_NETRC_FILE, netrc_file.c_str()); + check_curl_result(res, "Unable to set .netrc file path : "); + } + } + return e; +} diff --git a/Source/cmCurl.h b/Source/cmCurl.h index 0688bb2..fe7eb80 100644 --- a/Source/cmCurl.h +++ b/Source/cmCurl.h @@ -9,5 +9,7 @@ #include std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile = nullptr); +std::string cmCurlSetNETRCOption(::CURL* curl, const std::string& netrc_level, + const std::string& netrc_file); #endif diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index fdd5f0c..191a666 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2626,6 +2626,9 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) std::string statusVar; bool tls_verify = this->Makefile->IsOn("CMAKE_TLS_VERIFY"); const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO"); + std::string netrc_level = this->Makefile->GetSafeDefinition("CMAKE_NETRC"); + std::string netrc_file = + this->Makefile->GetSafeDefinition("CMAKE_NETRC_FILE"); std::string expectedHash; std::string hashMatchMSG; std::unique_ptr hash; @@ -2681,6 +2684,22 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) this->SetError("TLS_CAFILE missing file value."); return false; } + } else if (*i == "NETRC_FILE") { + ++i; + if (i != args.end()) { + netrc_file = *i; + } else { + this->SetError("DOWNLOAD missing file value for NETRC_FILE."); + return false; + } + } else if (*i == "NETRC") { + ++i; + if (i != args.end()) { + netrc_level = *i; + } else { + this->SetError("DOWNLOAD missing level value for NETRC."); + return false; + } } else if (*i == "EXPECTED_MD5") { ++i; if (i == args.end()) { @@ -2822,6 +2841,16 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) return false; } + // check to see if netrc parameters have been specified + // local command args takes precedence over CMAKE_NETRC* + netrc_level = cmSystemTools::UpperCase(netrc_level); + std::string const& netrc_option_err = + cmCurlSetNETRCOption(curl, netrc_level, netrc_file); + if (!netrc_option_err.empty()) { + this->SetError(netrc_option_err); + return false; + } + cmFileCommandVectorOfChar chunkDebug; res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, &fout); @@ -2964,6 +2993,9 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) std::string statusVar; bool showProgress = false; std::string userpwd; + std::string netrc_level = this->Makefile->GetSafeDefinition("CMAKE_NETRC"); + std::string netrc_file = + this->Makefile->GetSafeDefinition("CMAKE_NETRC_FILE"); std::vector curl_headers; @@ -3000,6 +3032,22 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) statusVar = *i; } else if (*i == "SHOW_PROGRESS") { showProgress = true; + } else if (*i == "NETRC_FILE") { + ++i; + if (i != args.end()) { + netrc_file = *i; + } else { + this->SetError("UPLOAD missing file value for NETRC_FILE."); + return false; + } + } else if (*i == "NETRC") { + ++i; + if (i != args.end()) { + netrc_level = *i; + } else { + this->SetError("UPLOAD missing level value for NETRC."); + return false; + } } else if (*i == "USERPWD") { ++i; if (i == args.end()) { @@ -3132,6 +3180,16 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) check_curl_result(res, "UPLOAD cannot set user password: "); } + // check to see if netrc parameters have been specified + // local command args takes precedence over CMAKE_NETRC* + netrc_level = cmSystemTools::UpperCase(netrc_level); + std::string const& netrc_option_err = + cmCurlSetNETRCOption(curl, netrc_level, netrc_file); + if (!netrc_option_err.empty()) { + this->SetError(netrc_option_err); + return false; + } + struct curl_slist* headers = nullptr; for (std::string const& h : curl_headers) { headers = ::curl_slist_append(headers, h.c_str()); -- cgit v0.12 From 754e39dd36cdeea4a15fca9ef9fa29f0fa8006d4 Mon Sep 17 00:00:00 2001 From: Shane Parris Date: Wed, 18 Oct 2017 10:27:55 -0400 Subject: Add testcases for file(DOWNLOAD|UPLOAD) netrc options --- Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt | 1 + Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt | 19 +++++++++++++++++++ Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake | 15 +++++++++++++++ Tests/RunCMake/file/DOWNLOAD-netrc-bad.txt | 0 Tests/RunCMake/file/RunCMakeTest.cmake | 2 ++ Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt | 1 + Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt | 19 +++++++++++++++++++ Tests/RunCMake/file/UPLOAD-netrc-bad.cmake | 15 +++++++++++++++ Tests/RunCMake/file/UPLOAD-netrc-bad.txt | 0 9 files changed, 72 insertions(+) create mode 100644 Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt create mode 100644 Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt create mode 100644 Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake create mode 100644 Tests/RunCMake/file/DOWNLOAD-netrc-bad.txt create mode 100644 Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt create mode 100644 Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt create mode 100644 Tests/RunCMake/file/UPLOAD-netrc-bad.cmake create mode 100644 Tests/RunCMake/file/UPLOAD-netrc-bad.txt diff --git a/Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt b/Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt new file mode 100644 index 0000000..96ce62a --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt @@ -0,0 +1,19 @@ +^CMake Error at DOWNLOAD-netrc-bad\.cmake:[0-9]+ \(file\): + file DOWNLOAD missing level value for NETRC\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at DOWNLOAD-netrc-bad\.cmake:[0-9]+ \(file\): + file DOWNLOAD missing file value for NETRC_FILE\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at DOWNLOAD-netrc-bad\.cmake:[0-9]+ \(file\): + file NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: INVALID +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at DOWNLOAD-netrc-bad\.cmake:[0-9]+ \(file\): + file NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: FALSE +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake b/Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake new file mode 100644 index 0000000..6a62df9 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake @@ -0,0 +1,15 @@ +if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/") + set(slash /) +endif() +file(DOWNLOAD "" "" NETRC) +file(DOWNLOAD "" "" NETRC_FILE) +set(CMAKE_NETRC FALSE) +file(DOWNLOAD + "file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-netrc-bad.txt" + "${CMAKE_CURRENT_BINARY_DIR}/netrc-bad.txt" + NETRC INVALID + ) +file(DOWNLOAD + "file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-netrc-bad.txt" + "${CMAKE_CURRENT_BINARY_DIR}/netrc-bad.txt" + ) diff --git a/Tests/RunCMake/file/DOWNLOAD-netrc-bad.txt b/Tests/RunCMake/file/DOWNLOAD-netrc-bad.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 26051b4..3be4fb7 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -3,9 +3,11 @@ include(RunCMake) run_cmake(DOWNLOAD-hash-mismatch) run_cmake(DOWNLOAD-unused-argument) run_cmake(DOWNLOAD-httpheader-not-set) +run_cmake(DOWNLOAD-netrc-bad) run_cmake(DOWNLOAD-pass-not-set) run_cmake(UPLOAD-unused-argument) run_cmake(UPLOAD-httpheader-not-set) +run_cmake(UPLOAD-netrc-bad) run_cmake(UPLOAD-pass-not-set) run_cmake(INSTALL-DIRECTORY) run_cmake(INSTALL-FILES_FROM_DIR) diff --git a/Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt b/Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt b/Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt new file mode 100644 index 0000000..d5752ea --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt @@ -0,0 +1,19 @@ +^CMake Error at UPLOAD-netrc-bad\.cmake:[0-9]+ \(file\): + file UPLOAD missing level value for NETRC\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at UPLOAD-netrc-bad\.cmake:[0-9]+ \(file\): + file UPLOAD missing file value for NETRC_FILE\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at UPLOAD-netrc-bad\.cmake:[0-9]+ \(file\): + file NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: INVALID +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) ++ +CMake Error at UPLOAD-netrc-bad\.cmake:[0-9]+ \(file\): + file NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: FALSE +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/UPLOAD-netrc-bad.cmake b/Tests/RunCMake/file/UPLOAD-netrc-bad.cmake new file mode 100644 index 0000000..e59a2c4 --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-netrc-bad.cmake @@ -0,0 +1,15 @@ +if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/") + set(slash /) +endif() +file(UPLOAD "" "" NETRC) +file(UPLOAD "" "" NETRC_FILE) +set(CMAKE_NETRC FALSE) +file(UPLOAD + "${CMAKE_CURRENT_SOURCE_DIR}/UPLOAD-netrc-bad.txt" + "file://${slash}${CMAKE_CURRENT_BINARY_DIR}/netrc-bad.txt" + NETRC INVALID + ) +file(UPLOAD + "${CMAKE_CURRENT_SOURCE_DIR}/UPLOAD-netrc-bad.txt" + "file://${slash}${CMAKE_CURRENT_BINARY_DIR}/netrc-bad.txt" + ) diff --git a/Tests/RunCMake/file/UPLOAD-netrc-bad.txt b/Tests/RunCMake/file/UPLOAD-netrc-bad.txt new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From 60c272b69ae1c3363aba02488c04c83f66264251 Mon Sep 17 00:00:00 2001 From: Shane Parris Date: Wed, 18 Oct 2017 10:28:28 -0400 Subject: ExternalProject: Add support for NETRC and NETRC_FILE suboption --- Auxiliary/vim/syntax/cmake.vim | 2 +- Modules/ExternalProject-download.cmake.in | 2 ++ Modules/ExternalProject.cmake | 46 +++++++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index d30c86e..971f7d0 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -47,7 +47,7 @@ syn keyword cmakeModule contained \ ExternalProject syn keyword cmakeKWExternalProject contained - \ ALGO AWS BINARY_DIR BUILD_ALWAYS BUILD_BYPRODUCTS BUILD_COMMAND BUILD_IN_SOURCE CMAKE_ARGS CMAKE_CACHE_ARGS CMAKE_CACHE_DEFAULT_ARGS CMAKE_TLS_CAINFO CMAKE_TLS_VERIFY COMMENT CONFIGURE_COMMAND CVS CVSROOT CVS_MODULE CVS_REPOSITORY CVS_TAG DEPENDEES DEPENDERS DEPENDS DOWNLOADED_FILE DOWNLOAD_COMMAND DOWNLOAD_DIR DOWNLOAD_NAME DOWNLOAD_NO_EXTRACT DOWNLOAD_NO_PROGRESS EP_BASE EP_INDEPENDENT_STEP_TARGETS EP_PREFIX EP_STEP_TARGETS EP_UPDATE_DISCONNECTED EXCLUDE_FROM_ALL FORCE GIT_CONFIG GIT_PROGRESS GIT_REMOTE_NAME GIT_REPOSITORY GIT_SHALLOW GIT_SUBMODULES GIT_TAG HG_REPOSITORY HG_TAG HTTP_HEADER HTTP_PASSWORD HTTP_USERNAME INDEPENDENT_STEP_TARGETS INSTALL_COMMAND INSTALL_DIR JOB_POOLS LIST_SEPARATOR LOG_ LOG_BUILD LOG_CONFIGURE LOG_DOWNLOAD LOG_INSTALL LOG_TEST LOG_UPDATE MAKE_EXE NAMES NOTE NO_DEPENDS PATCH_COMMAND PREFIX PROPERTY SOURCE_DIR SOURCE_SUBDIR STAMP_DIR STEP_TARGETS STRING SVN_PASSWORD SVN_REPOSITORY SVN_REVISION SVN_TRUST_CERT SVN_USERNAME TEST_AFTER_INSTALL TEST_BEFORE_INSTALL TEST_COMMAND TEST_EXCLUDE_FROM_MAIN TIMEOUT TLS_CAINFO TLS_VERIFY TMP_DIR TRUE UPDATE_COMMAND UPDATE_DISCONNECTED URL URL_HASH USES_TERMINAL_BUILD USES_TERMINAL_CONFIGURE USES_TERMINAL_DOWNLOAD USES_TERMINAL_INSTALL USES_TERMINAL_TEST USES_TERMINAL_UPDATE WORKING_DIRECTORY + \ ALGO AWS BINARY_DIR BUILD_ALWAYS BUILD_BYPRODUCTS BUILD_COMMAND BUILD_IN_SOURCE CMAKE_ARGS CMAKE_CACHE_ARGS CMAKE_CACHE_DEFAULT_ARGS CMAKE_TLS_CAINFO CMAKE_TLS_VERIFY COMMENT CONFIGURE_COMMAND CVS CVSROOT CVS_MODULE CVS_REPOSITORY CVS_TAG DEPENDEES DEPENDERS DEPENDS DOWNLOADED_FILE DOWNLOAD_COMMAND DOWNLOAD_DIR DOWNLOAD_NAME DOWNLOAD_NO_EXTRACT DOWNLOAD_NO_PROGRESS EP_BASE EP_INDEPENDENT_STEP_TARGETS EP_PREFIX EP_STEP_TARGETS EP_UPDATE_DISCONNECTED EXCLUDE_FROM_ALL FORCE GIT_CONFIG GIT_PROGRESS GIT_REMOTE_NAME GIT_REPOSITORY GIT_SHALLOW GIT_SUBMODULES GIT_TAG HG_REPOSITORY HG_TAG HTTP_HEADER HTTP_PASSWORD HTTP_USERNAME INDEPENDENT_STEP_TARGETS INSTALL_COMMAND INSTALL_DIR JOB_POOLS LIST_SEPARATOR LOG_ LOG_BUILD LOG_CONFIGURE LOG_DOWNLOAD LOG_INSTALL LOG_TEST LOG_UPDATE MAKE_EXE NAMES NETRC NETRC_FILE NOTE NO_DEPENDS PATCH_COMMAND PREFIX PROPERTY SOURCE_DIR SOURCE_SUBDIR STAMP_DIR STEP_TARGETS STRING SVN_PASSWORD SVN_REPOSITORY SVN_REVISION SVN_TRUST_CERT SVN_USERNAME TEST_AFTER_INSTALL TEST_BEFORE_INSTALL TEST_COMMAND TEST_EXCLUDE_FROM_MAIN TIMEOUT TLS_CAINFO TLS_VERIFY TMP_DIR TRUE UPDATE_COMMAND UPDATE_DISCONNECTED URL URL_HASH USES_TERMINAL_BUILD USES_TERMINAL_CONFIGURE USES_TERMINAL_DOWNLOAD USES_TERMINAL_INSTALL USES_TERMINAL_TEST USES_TERMINAL_UPDATE WORKING_DIRECTORY syn keyword cmakeKWadd_compile_options contained \ COMPILE_OPTIONS diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in index 7f92596..99fb917 100644 --- a/Modules/ExternalProject-download.cmake.in +++ b/Modules/ExternalProject-download.cmake.in @@ -116,6 +116,8 @@ foreach(i RANGE ${retry_number}) @TLS_VERIFY_CODE@ @TLS_CAINFO_CODE@ + @NETRC_CODE@ + @NETRC_FILE_CODE@ file( DOWNLOAD diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 76f5080..c041f03 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -193,6 +193,28 @@ External Project Definition ``CMAKE_TLS_CAINFO`` variable will be used instead (see :command:`file(DOWNLOAD)`) + ``NETRC `` + Specify whether the .netrc file is to be used for operation. If this + option is not specified, the value of the ``CMAKE_NETRC`` variable + will be used instead (see :command:`file(DOWNLOAD)`) + Valid levels are: + + ``IGNORED`` + The .netrc file is ignored. + This is the default. + ``OPTIONAL`` + The .netrc file is optional, and information in the URL is preferred. + The file will be scanned to find which ever information is not specified + in the URL. + ``REQUIRED`` + The .netrc file is required, and information in the URL is ignored. + + ``NETRC_FILE `` + Specify an alternative .netrc file to the one in your home directory + if the ``NETRC`` level is ``OPTIONAL`` or ``REQUIRED``. If this option + is not specified, the value of the ``CMAKE_NETRC_FILE`` variable will + be used instead (see :command:`file(DOWNLOAD)`) + *Git* NOTE: A git version of 1.6.5 or later is required if this download method is used. @@ -1343,7 +1365,7 @@ endif() endfunction(_ep_write_gitupdate_script) -function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd http_headers) +function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file) if(timeout) set(TIMEOUT_ARGS TIMEOUT ${timeout}) set(TIMEOUT_MSG "${timeout} seconds") @@ -1368,6 +1390,8 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p set(TLS_VERIFY_CODE "") set(TLS_CAINFO_CODE "") + set(NETRC_CODE "") + set(NETRC_FILE_CODE "") # check for curl globals in the project if(DEFINED CMAKE_TLS_VERIFY) @@ -1376,6 +1400,12 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p if(DEFINED CMAKE_TLS_CAINFO) set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${CMAKE_TLS_CAINFO}\")") endif() + if(DEFINED CMAKE_NETRC) + set(NETRC_CODE "set(CMAKE_NETRC \"${CMAKE_NETRC}\")") + endif() + if(DEFINED CMAKE_NETRC_FILE) + set(NETRC_FILE_CODE "set(CMAKE_NETRC_FILE \"${CMAKE_NETRC_FILE}\")") + endif() # now check for curl locals so that the local values # will override the globals @@ -1390,6 +1420,16 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p if(tls_cainfo_len GREATER 0) set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")") endif() + # check for netrc argument + string(LENGTH "${netrc}" netrc_len) + if(netrc_len GREATER 0) + set(NETRC_CODE "set(CMAKE_NETRC \"${netrc}\")") + endif() + # check for netrc_file argument + string(LENGTH "${netrc_file}" netrc_file_len) + if(netrc_file_len GREATER 0) + set(NETRC_FILE_CODE "set(CMAKE_NETRC_FILE \"${netrc_file}\")") + endif() if(userpwd STREQUAL ":") set(USERPWD_ARGS) @@ -2433,11 +2473,13 @@ function(_ep_add_download_command name) get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) + get_property(netrc TARGET ${name} PROPERTY _EP_NETRC) + get_property(netrc_file TARGET ${name} PROPERTY _EP_NETRC_FILE) get_property(http_username TARGET ${name} PROPERTY _EP_HTTP_USERNAME) get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD) get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER) set(download_script "${stamp_dir}/download-${name}.cmake") - _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}") set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) if (no_extract) -- cgit v0.12 From d45aa38a068ef38331b5dab195c42502e3829eb0 Mon Sep 17 00:00:00 2001 From: Shane Parris Date: Wed, 18 Oct 2017 10:29:03 -0400 Subject: Add dev notes for topic 'curl_netrc_options' --- Help/release/dev/curl_netrc_options.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Help/release/dev/curl_netrc_options.rst diff --git a/Help/release/dev/curl_netrc_options.rst b/Help/release/dev/curl_netrc_options.rst new file mode 100644 index 0000000..850c9ce --- /dev/null +++ b/Help/release/dev/curl_netrc_options.rst @@ -0,0 +1,14 @@ +curl_netrc_options +------------------ + +* The :command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands + gained ``NETRC`` and ``NETRC_FILE`` options to specify use of a + ``.netrc`` file. + +* The :module:`ExternalProject` module gained ``NETRC`` and ``NETRC_FILE`` + options to specify use of a ``.netrc`` file. + +* The :variable:`CMAKE_NETRC` and :variable:`CMAKE_NETRC_FILE` variables + were added to specify use of a ``.netrc`` file by the + :command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands and + the :module:`ExternalProject` module. -- cgit v0.12