mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-10 07:40:03 -06:00
Merge topic 'curl_netrc_options'
d45aa38aAdd dev notes for topic 'curl_netrc_options'60c272b6ExternalProject: Add support for NETRC and NETRC_FILE suboption754e39ddAdd testcases for file(DOWNLOAD|UPLOAD) netrc options5d67e902file(DOWNLOAD|UPLOAD): Add 'NETRC' and 'NETRC_FILE' suboption Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Ruslan Baratov <ruslan_baratov@yahoo.com> Merge-request: !1376
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -232,6 +232,31 @@ Options to both ``DOWNLOAD`` and ``UPLOAD`` are:
|
||||
``HTTPHEADER <HTTP-header>``
|
||||
HTTP header for operation. Suboption can be repeated several times.
|
||||
|
||||
``NETRC <level>``
|
||||
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 <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=<value>``
|
||||
|
||||
@@ -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
|
||||
|
||||
14
Help/release/dev/curl_netrc_options.rst
Normal file
14
Help/release/dev/curl_netrc_options.rst
Normal file
@@ -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.
|
||||
9
Help/variable/CMAKE_NETRC.rst
Normal file
9
Help/variable/CMAKE_NETRC.rst
Normal file
@@ -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.
|
||||
9
Help/variable/CMAKE_NETRC_FILE.rst
Normal file
9
Help/variable/CMAKE_NETRC_FILE.rst
Normal file
@@ -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.
|
||||
@@ -116,6 +116,8 @@ foreach(i RANGE ${retry_number})
|
||||
|
||||
@TLS_VERIFY_CODE@
|
||||
@TLS_CAINFO_CODE@
|
||||
@NETRC_CODE@
|
||||
@NETRC_FILE_CODE@
|
||||
|
||||
file(
|
||||
DOWNLOAD
|
||||
|
||||
@@ -193,6 +193,28 @@ External Project Definition
|
||||
``CMAKE_TLS_CAINFO`` variable will be used instead (see
|
||||
:command:`file(DOWNLOAD)`)
|
||||
|
||||
``NETRC <level>``
|
||||
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 <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.
|
||||
@@ -1346,7 +1368,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")
|
||||
@@ -1371,6 +1393,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)
|
||||
@@ -1379,6 +1403,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
|
||||
@@ -1393,6 +1423,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)
|
||||
@@ -2436,11 +2476,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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -9,5 +9,7 @@
|
||||
#include <string>
|
||||
|
||||
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
|
||||
|
||||
@@ -2626,6 +2626,9 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> 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<cmCryptoHash> hash;
|
||||
@@ -2681,6 +2684,22 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> 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<std::string> 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<std::string> 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<std::string> curl_headers;
|
||||
|
||||
@@ -3000,6 +3032,22 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> 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<std::string> 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());
|
||||
|
||||
1
Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt
Normal file
1
Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
19
Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt
Normal file
19
Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt
Normal file
@@ -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\)$
|
||||
15
Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake
Normal file
15
Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake
Normal file
@@ -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"
|
||||
)
|
||||
0
Tests/RunCMake/file/DOWNLOAD-netrc-bad.txt
Normal file
0
Tests/RunCMake/file/DOWNLOAD-netrc-bad.txt
Normal file
@@ -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)
|
||||
|
||||
1
Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt
Normal file
1
Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
19
Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt
Normal file
19
Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt
Normal file
@@ -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\)$
|
||||
15
Tests/RunCMake/file/UPLOAD-netrc-bad.cmake
Normal file
15
Tests/RunCMake/file/UPLOAD-netrc-bad.cmake
Normal file
@@ -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"
|
||||
)
|
||||
0
Tests/RunCMake/file/UPLOAD-netrc-bad.txt
Normal file
0
Tests/RunCMake/file/UPLOAD-netrc-bad.txt
Normal file
Reference in New Issue
Block a user