diff options
Diffstat (limited to 'remote')
-rw-r--r-- | remote/includes/downloader.inc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/remote/includes/downloader.inc b/remote/includes/downloader.inc index e12c8a02..4ca71433 100644 --- a/remote/includes/downloader.inc +++ b/remote/includes/downloader.inc @@ -7,17 +7,26 @@ download () { [ $# -lt 1 -o $# -gt 2 ] && perror "download called with $# arguments, need 1 or 2" [ -z "$1" ] && perror "download: URL empty." + local URL="$1" + # If a sourceforge mirror is set in ./config, try to use it + if [[ -n "$sourceforge_mirror" -a "$URL" != *use_mirror* ]] && [[ "$URL" == *sourceforge.net* -o "$URL" == *.sf.net* ]]; then + if [[ "$URL" == *\?* ]]; then + URL+="&use_mirror=$sourceforge_mirror" + else + URL+="?use_mirror=$sourceforge_mirror" + fi + fi if [ $# -eq 2 ]; then [ -z "$2" ] && perror "download: target file name given but empty" - pinfo "Downloading $2 from '$1'...." - wget -O "$2" "$1" + pinfo "Downloading $2 from '$URL'...." + wget -O "$2" "$URL" local RET=$? else - pinfo "Downloading '$1'...." - wget "$1" + pinfo "Downloading '$URL'...." + wget "$URL" local RET=$? fi - [ "x$RET" != "x0" ] && perror "downloading $1 failed, wget returned exit code $RET" + [ "x$RET" != "x0" ] && perror "downloading $URL failed, wget returned exit code $RET" } # download a file and untar it. usage: |