diff options
author | Alexey Neyman <stilor@att.net> | 2017-02-13 22:45:45 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-13 22:45:45 -0800 |
commit | fbc69323085e2370faeb8b46291cd66cbf9ef649 (patch) | |
tree | 10da28cd40b45913f6104c07badbf48971500066 /scripts/functions | |
parent | c440a13a8231e267827349065a90f98fac3d4cc0 (diff) | |
parent | f9bec4ed7c4540de73c82c94053f975c5c7c29e4 (diff) | |
download | crosstool-ng-fbc69323085e2370faeb8b46291cd66cbf9ef649.tar.gz crosstool-ng-fbc69323085e2370faeb8b46291cd66cbf9ef649.tar.bz2 crosstool-ng-fbc69323085e2370faeb8b46291cd66cbf9ef649.zip |
Merge pull request #594 from stilor/wget-vs-curl
Select wget vs curl, BSD stat vs GNU stat
Diffstat (limited to 'scripts/functions')
-rw-r--r-- | scripts/functions | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/scripts/functions b/scripts/functions index 9f852b39..84054d58 100644 --- a/scripts/functions +++ b/scripts/functions @@ -567,15 +567,15 @@ CT_DoForceRmdir() { local mode for dir in "${@}"; do [ -d "${dir}" ] || continue - case "$CT_SYS_OS" in - Linux|CYGWIN*) + case "${CT_CONFIGURE_has_stat_flavor_GNU},${CT_CONFIGURE_has_stat_flavor_BSD}" in + y,*) mode="$(stat -c '%a' "$(dirname "${dir}")")" ;; - Darwin|*BSD) + *,y) mode="$(stat -f '%Lp' "$(dirname "${dir}")")" ;; *) - CT_Abort "Unhandled host OS $CT_SYS_OS" + CT_Abort "Unknown stat format options" ;; esac CT_DoExecLog ALL chmod u+w "$(dirname "${dir}")" @@ -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}\"" |