DownloadURL now works with either wget or curl

The reason is that Ubuntu does not have curl at the very beginning of
provisioning scripts, and also does not have the repositories configured
in order to install it.

Change-Id: Ia485c1672f894bc800f199b742d238b2945938e5
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
This commit is contained in:
Dimitrios Apostolou
2019-09-20 13:00:12 +02:00
parent 8f4c12bc03
commit 4e3a0f79fb

View File

@@ -46,6 +46,15 @@ command -v sha512sum >/dev/null || alias sha512sum='shasum -a 512'
########################################################################
Download () {
url="$1"
targetFile="$2"
command -v curl >/dev/null \
&& curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url" \
|| wget --tries 5 -O "$targetFile" "$url"
}
VerifyHash () {
file=$1
expectedHash=$2
@@ -87,10 +96,10 @@ DownloadURL () {
echo "Skipping download, found and validated existing file: $targetFile"
else
echo "Downloading from primary URL: $url"
if ! curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url"
if ! Download "$url" "$targetFile"
then
echo "FAIL! to download, trying alternative URL: $url2" 1>&2
if ! curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url2"
if ! Download "$url" "$targetFile"
then
echo 'FAIL! to download even from alternative url' 1>&2
return 1