summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitrios Apostolou <jimis@qt.io>2019-09-20 13:00:12 +0200
committerJukka Jokiniva <jukka.jokiniva@qt.io>2019-11-20 12:35:20 +0200
commit2217a2db89be1b74849585f6ad14a7212d35e0f2 (patch)
treee1c4011ca2682b394e5efa63a2416c2b48729980
parent8ed03772f79b47675428ae4b9d24af79ef188bc3 (diff)
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> (cherry picked from commit 4e3a0f79fbe8bea7915b267e132ba1e0d4b67733)
-rwxr-xr-xcoin/provisioning/common/unix/DownloadURL.sh13
1 files changed, 11 insertions, 2 deletions
diff --git a/coin/provisioning/common/unix/DownloadURL.sh b/coin/provisioning/common/unix/DownloadURL.sh
index da6d772f..0579451f 100755
--- a/coin/provisioning/common/unix/DownloadURL.sh
+++ b/coin/provisioning/common/unix/DownloadURL.sh
@@ -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