From 96b905a501a1472c9d0d236a0c04d6e0f6e62709 Mon Sep 17 00:00:00 2001 From: Kalvin C Date: Tue, 25 Mar 2025 10:17:18 -0700 Subject: [PATCH] feat: use temp dir for extracting goose binary (#1838) --- download_cli.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/download_cli.sh b/download_cli.sh index 9e2016fafb..98b5e5ae12 100755 --- a/download_cli.sh +++ b/download_cli.sh @@ -78,12 +78,21 @@ if ! curl -sLf "$DOWNLOAD_URL" --output "$FILE"; then exit 1 fi -echo "Extracting $FILE..." -tar -xjf "$FILE" +# Create a temporary directory for extraction +TMP_DIR="/tmp/goose_install_$RANDOM" +if ! mkdir -p "$TMP_DIR"; then + echo "Error: Could not create temporary extraction directory" + exit 1 +fi +# Clean up temporary directory +trap 'rm -rf "$TMP_DIR"' EXIT + +echo "Extracting $FILE to temporary directory..." +tar -xjf "$FILE" -C "$TMP_DIR" rm "$FILE" # clean up the downloaded tarball -# Make binaries executable -chmod +x goose +# Make binary executable +chmod +x "$TMP_DIR/goose" # --- 5) Install to $GOOSE_BIN_DIR --- if [ ! -d "$GOOSE_BIN_DIR" ]; then @@ -92,7 +101,7 @@ if [ ! -d "$GOOSE_BIN_DIR" ]; then fi echo "Moving goose to $GOOSE_BIN_DIR/$OUT_FILE" -mv goose "$GOOSE_BIN_DIR/$OUT_FILE" +mv "$TMP_DIR/goose" "$GOOSE_BIN_DIR/$OUT_FILE" # skip configuration for non-interactive installs e.g. automation, docker if [ "$CONFIGURE" = true ]; then