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 | |
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')
-rw-r--r-- | scripts/functions | 41 | ||||
-rw-r--r-- | scripts/scripts.mk.in (renamed from scripts/scripts.mk) | 24 |
2 files changed, 40 insertions, 25 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}\"" diff --git a/scripts/scripts.mk b/scripts/scripts.mk.in index 77368a7e..99b9d76b 100644 --- a/scripts/scripts.mk +++ b/scripts/scripts.mk.in @@ -26,9 +26,19 @@ updatetools: $(CONFIG_SUB_DEST) $(CONFIG_GUESS_DEST) # ---------------------------------------------------------- # How to retrieve the tools -wget_opt=-o /dev/null -ifeq ($(strip $(V)),2) - wget_opt= +ifneq ($(strip $(V)),2) + wget_silent_opt = -o /dev/null + curl_silent_opt = --silent +endif + +ifneq (@@CT_wget@@,) +download_cmd = wget --passive-ftp $(wget_silent_opt) -O $@ +else +ifneq (@@CT_curl@@,) +download_cmd = curl --ftp-pasv $(curl_silent_opt) -o $@ +else +download_cmd = $(error wget or curl needed for downloads) +endif endif PHONY += scripts @@ -37,13 +47,13 @@ scripts: $(SILENT)mkdir -p $@ $(CONFIG_SUB_DEST): scripts FORCE - @$(CT_ECHO) ' WGET $@' - $(SILENT)wget $(wget_opt) -O $@ $(CONFIG_SUB_SRC) + @$(CT_ECHO) ' DOWNLOAD $@' + $(SILENT)$(download_cmd) $(CONFIG_SUB_SRC) $(SILENT)chmod u+rwx,go+rx-w $@ $(CONFIG_GUESS_DEST): scripts FORCE - @$(CT_ECHO) ' WGET $@' - $(SILENT)wget $(wget_opt) -O $@ $(CONFIG_GUESS_SRC) + @$(CT_ECHO) ' DOWNLOAD $@' + $(SILENT)$(download_cmd) $(CONFIG_GUESS_SRC) $(SILENT)chmod u+rwx,go+rx-w $@ # ---------------------------------------------------------- |