From 08f1167cc5f4f864d76ea859a5bed320dbdfc80c Mon Sep 17 00:00:00 2001 From: Jeremy McFarland <4937801+teck968@users.noreply.github.com> Date: Mon, 7 Apr 2025 12:09:51 -0400 Subject: [PATCH] fix: Added check for bzip2 in download_cli.sh (#1998) Co-authored-by: Jeremy --- download_cli.sh | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/download_cli.sh b/download_cli.sh index 98b5e5ae..0abebff5 100755 --- a/download_cli.sh +++ b/download_cli.sh @@ -22,12 +22,20 @@ set -eu # ** other provider specific environment variables (eg. DATABRICKS_HOST) ############################################################################## -# --- 1) Check for curl --- +# --- 1) Check for dependencies --- +# Check for curl if ! command -v curl >/dev/null 2>&1; then echo "Error: 'curl' is required to download Goose. Please install curl and try again." exit 1 fi +# Check for tar +if ! command -v tar >/dev/null 2>&1; then + echo "Error: 'tar' is required to download Goose. Please install tar and try again." + exit 1 +fi + + # --- 2) Variables --- REPO="block/goose" OUT_FILE="goose" @@ -88,7 +96,24 @@ fi trap 'rm -rf "$TMP_DIR"' EXIT echo "Extracting $FILE to temporary directory..." -tar -xjf "$FILE" -C "$TMP_DIR" +set +e # Disable immediate exit on error +tar -xjf "$FILE" -C "$TMP_DIR" 2> tar_error.log +tar_exit_code=$? +set -e # Re-enable immediate exit on error + +# Check for tar errors +if [ $tar_exit_code -ne 0 ]; then + if grep -iEq "missing.*bzip2|bzip2.*missing|bzip2.*No such file|No such file.*bzip2" tar_error.log; then + echo "Error: Failed to extract $FILE. 'bzip2' is required but not installed. See details below:" + else + echo "Error: Failed to extract $FILE. See details below:" + fi + cat tar_error.log + rm tar_error.log + exit 1 +fi +rm tar_error.log + rm "$FILE" # clean up the downloaded tarball # Make binary executable