mirror of
git://code.qt.io/qt/qt5.git
synced 2026-04-21 04:16:39 +08:00
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>
This commit is contained in:
committed by
Jani Heikkinen
parent
8fae7aa66d
commit
8a47814c91
@@ -40,51 +40,21 @@
|
|||||||
# If called directly from another script, it will exit the parent script
|
# If called directly from another script, it will exit the parent script
|
||||||
# as well, if not called in its own subshell with parentheses.
|
# 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 {
|
function DownloadURL {
|
||||||
url=$1
|
url=$1
|
||||||
url_alt=$2
|
url_alt=$2
|
||||||
expectedSha1=$3
|
expectedSha1=$3
|
||||||
targetFile=$4
|
targetFile=$4
|
||||||
|
|
||||||
try
|
echo "Downloading from primary URL '$url'"
|
||||||
(
|
curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url" || (
|
||||||
try
|
echo "Failed to download '$url' multiple times"
|
||||||
(
|
echo "Downloading from alternative URL '$url_alt'"
|
||||||
echo "Downloading from primary URL '$url'"
|
curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url_alt"
|
||||||
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
|
|
||||||
)
|
)
|
||||||
|
|
||||||
catch || {
|
echo "Checking SHA1 on PKG '$targetFile'"
|
||||||
case $ex_code in
|
echo "$expectedSha1 *$targetFile" > $targetFile.sha1
|
||||||
$ExceptionDownloadAltUrl)
|
sha1sum --check $targetFile.sha1
|
||||||
echo "Failed downloading PKG from primary and alternative URLs"
|
|
||||||
exit 1;
|
|
||||||
;;
|
|
||||||
$ExceptionSHA1)
|
|
||||||
echo "Failed checksum on $targetFile."
|
|
||||||
exit 1;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user