aboutsummaryrefslogtreecommitdiffstats
path: root/coin/provisioning
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@qt.io>2018-02-22 15:00:47 +0100
committerJani Heikkinen <jani.heikkinen@qt.io>2018-03-14 05:12:41 +0000
commit8a47814c91828a2f1541b99b58c8ee2eb085cb51 (patch)
tree140b2c1dda490fce5e865178cafc726166dd21d2 /coin/provisioning
parent8fae7aa66de2a8e632032e5024fc4bbb01459b56 (diff)
Simplify DownloadURL
The script was over-engineered. The new version provides the same functionality while removing uninteresting postmortem messages. In addition try_catch.sh has a bug that injects set +e to a sourcing script which was propagating through DownloadURL.sh to almost all provisioning scripts. So it is good to avoid using it. Change-Id: If191a0dcf52a29c4bec580a254e8e58a00130f6d Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'coin/provisioning')
-rwxr-xr-xcoin/provisioning/common/unix/DownloadURL.sh46
1 files changed, 8 insertions, 38 deletions
diff --git a/coin/provisioning/common/unix/DownloadURL.sh b/coin/provisioning/common/unix/DownloadURL.sh
index d3a8a7d0..c1e1d6cc 100755
--- a/coin/provisioning/common/unix/DownloadURL.sh
+++ b/coin/provisioning/common/unix/DownloadURL.sh
@@ -40,51 +40,21 @@
# If called directly from another script, it will exit the parent script
# as well, if not called in its own subshell with parentheses.
-# shellcheck source=try_catch.sh
-source "${BASH_SOURCE%/*}/try_catch.sh"
-
-ExceptionDownloadPrimaryUrl=100
-ExceptionDownloadAltUrl=101
-ExceptionSHA1=102
-
function DownloadURL {
url=$1
url_alt=$2
expectedSha1=$3
targetFile=$4
- try
- (
- try
- (
- echo "Downloading from primary URL '$url'"
- curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url" || throw $ExceptionDownloadPrimaryUrl
- )
- catch || {
- case $ex_code in
- $ExceptionDownloadPrimaryUrl)
- echo "Failed to download '$url' multiple times"
- echo "Downloading tar.gz from alternative URL '$url_alt'"
- curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url_alt" || throw $ExceptionDownloadAltUrl
- ;;
- esac
- }
- echo "Checking SHA1 on PKG '$targetFile'"
- echo "$expectedSha1 *$targetFile" > $targetFile.sha1
- sha1sum --check $targetFile.sha1 || throw $ExceptionSHA1
+ echo "Downloading from primary URL '$url'"
+ curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url" || (
+ echo "Failed to download '$url' multiple times"
+ echo "Downloading from alternative URL '$url_alt'"
+ curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url_alt"
)
- catch || {
- case $ex_code in
- $ExceptionDownloadAltUrl)
- echo "Failed downloading PKG from primary and alternative URLs"
- exit 1;
- ;;
- $ExceptionSHA1)
- echo "Failed checksum on $targetFile."
- exit 1;
- ;;
- esac
- }
+ echo "Checking SHA1 on PKG '$targetFile'"
+ echo "$expectedSha1 *$targetFile" > $targetFile.sha1
+ sha1sum --check $targetFile.sha1
}