diff options
author | Alexey Neyman <stilor@att.net> | 2017-02-12 13:51:42 -0800 |
---|---|---|
committer | Alexey Neyman <stilor@att.net> | 2017-02-12 22:02:23 -0800 |
commit | 35f89c406423344b19dcf3e3f95ff6296f329e42 (patch) | |
tree | 69b473f6d211cc56bfc437e37b457407ad052a43 /scripts/functions | |
parent | c31ed45a65e9e30fe2000bf1704583038522646e (diff) | |
download | crosstool-ng-35f89c406423344b19dcf3e3f95ff6296f329e42.tar.gz crosstool-ng-35f89c406423344b19dcf3e3f95ff6296f329e42.tar.bz2 crosstool-ng-35f89c406423344b19dcf3e3f95ff6296f329e42.zip |
Detect both wget/curl and allow user to select the agent
Signed-off-by: Alexey Neyman <stilor@att.net>
Diffstat (limited to 'scripts/functions')
-rw-r--r-- | scripts/functions | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/scripts/functions b/scripts/functions index 9f852b39..65ce4981 100644 --- a/scripts/functions +++ b/scripts/functions @@ -663,29 +663,34 @@ CT_DoGetFile() { local url="${1}" local dest="${CT_TARBALLS_DIR}/${url##*/}" local tmp="${dest}.tmp-dl" + local ok + local T # Remove potential left-over from a previous run rm -f "${tmp}" - # We also retry a few times, in case there is a transient error (eg. behind - # a dynamic IP that changes during the transfer...) - # With automated download as we are doing, it can be very dangerous to - # continue the downloads. It's far better to simply overwrite the - # destination file. - # Some company networks have firewalls to connect to the internet, but it's - # not easy to detect them, so force a global ${CT_CONNECT_TIMEOUT}-second - # timeout. - if [ ${CT_CONNECT_TIMEOUT} = -1 ]; then - T= - else - T="-T ${CT_CONNECT_TIMEOUT}" + # Replace a special value of '-1' with empty string + if [ ${CT_CONNECT_TIMEOUT} != -1 ]; then + T="${CT_CONNECT_TIMEOUT}" + fi + + if [ "${CT_DOWNLOAD_AGENT_WGET}" = "y" ]; then + if CT_DoExecLog ALL wget ${CT_DOWNLOAD_WGET_OPTIONS} \ + ${T:+-T ${T}} \ + -O "${tmp}" \ + "${url}"; then + ok=y + fi + elif [ "${CT_DOWNLOAD_AGENT_CURL}" = "y" ]; then + if CT_DoExecLog ALL curl ${CT_DOWNLOAD_CURL_OPTIONS} \ + ${T:+--connect-timeout ${T}} \ + -o "${tmp}" \ + "${url}"; then + ok=y + fi fi - if CT_DoExecLog ALL wget --passive-ftp --tries=3 -nc \ - --progress=dot:binary \ - ${T} \ - -O "${tmp}" \ - "${url}" - then + + if [ "${ok}" = "y" ]; then # Success, we got it, good! mv "${tmp}" "${dest}" CT_DoLog DEBUG "Got it from: \"${url}\"" |