aboutsummaryrefslogtreecommitdiffstats
path: root/coin/provisioning/common/macos/InstallPKGFromURL.sh
diff options
context:
space:
mode:
authorTony Sarajärvi <tony.sarajarvi@qt.io>2018-03-08 13:30:24 +0200
committerTony Sarajärvi <tony.sarajarvi@qt.io>2018-03-19 11:57:00 +0000
commita98b0f3d7989bedf6f0bcc1a83b52aad1d3baa3e (patch)
tree14fd897680fa5afc82dd54951657882d14dc4d0e /coin/provisioning/common/macos/InstallPKGFromURL.sh
parent90261c1df5cb62a47b44d2d9b84c0753d6ebf9e4 (diff)
Remove try_catch codes from common macOS scripts
Change-Id: I66291e2da5514499387b61e01ad85a652cd24d7b Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
Diffstat (limited to 'coin/provisioning/common/macos/InstallPKGFromURL.sh')
-rwxr-xr-xcoin/provisioning/common/macos/InstallPKGFromURL.sh75
1 files changed, 15 insertions, 60 deletions
diff --git a/coin/provisioning/common/macos/InstallPKGFromURL.sh b/coin/provisioning/common/macos/InstallPKGFromURL.sh
index 881086ba..f5c4e2e4 100755
--- a/coin/provisioning/common/macos/InstallPKGFromURL.sh
+++ b/coin/provisioning/common/macos/InstallPKGFromURL.sh
@@ -33,16 +33,7 @@
##
#############################################################################
-# shellcheck source=try_catch.sh
-source "${BASH_SOURCE%/*}/../unix/try_catch.sh"
-
-ExceptionCreateTmpFile=100
-ExceptionDownloadPrimaryUrl=101
-ExceptionDownloadAltUrl=102
-ExceptionSHA1=103
-ExceptionInstallerPKG=104
-ExceptionDeleteTmpFile=105
-
+set -ex
function InstallPKGFromURL {
url=$1
@@ -50,55 +41,19 @@ function InstallPKGFromURL {
expectedSha1=$3
targetDirectory=$4
- try
- (
- echo "Creating temporary file"
- targetFile=$(mktemp "$TMPDIR$(uuidgen).pkg") || trow $ExceptionCreateTmpFile
- try
- (
- echo "Downloading PKG 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 PKG 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
- /usr/bin/shasum --check $targetFile.sha1 || throw $ExceptionSHA1
- echo "Run installer on PKG"
- sudo installer -package "$targetFile" -target "$targetDirectory" || throw $ExceptionInstallerPKG
- echo "Removing file '$targetFile'"
- rm "$targetFile" || throw $ExceptionDeleteTmpFile
+ echo "Creating temporary file"
+ targetFile=$(mktemp "$TMPDIR$(uuidgen).pkg")
+ echo "Downloading PKG from primary URL '$url'"
+ curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url" || (
+ echo "Failed to download '$url' multiple times"
+ echo "Downloading PKG from alternative URL '$url_alt'"
+ curl --fail -L --retry 5 --retry-delay 5 -o "$targetFile" "$url_alt"
)
-
- catch || {
- case $ex_code in
- $ExceptionCreateTmpFile)
- echo "Failed to create temporary file"
- exit 1;
- ;;
- $ExceptionDownloadAltUrl)
- echo "Failed downloading PKG from primary and alternative URLs"
- exit 1;
- ;;
- $ExceptionSHA1)
- echo "Failed to check sha1sum."
- exit 1;
- ;;
- $ExceptionInstallerPKG)
- echo "Failed running installer on PKG."
- exit 1;
- ;;
- $ExceptionDeleteTmpFile)
- echo "Failed deleting temporary file."
- exit 1;
- ;;
- esac
- }
+ echo "Checking SHA1 on PKG '$targetFile'"
+ echo "$expectedSha1 *$targetFile" > $targetFile.sha1
+ /usr/bin/shasum --check $targetFile.sha1
+ echo "Run installer on PKG"
+ sudo installer -package "$targetFile" -target "$targetDirectory"
+ echo "Removing file '$targetFile'"
+ rm "$targetFile"
}