Skip to content

Commit

Permalink
fix install on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Flaque committed Jun 13, 2023
1 parent 08a3e77 commit feec42f
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ fi
command -v unzip >/dev/null ||
error 'unzip is required to install lintrule'


# Make sure the target dir exists
mkdir -p "${TARGET_DIR}"

Expand All @@ -40,14 +39,8 @@ case $(uname -ms) in
;;
esac

if [[ $target = darwin-x64 ]]; then
# Is this process running in Rosetta?
# redirect stderr to devnull to avoid error message when not running in Rosetta
if [[ $(sysctl -n sysctl.proc_translated 2>/dev/null) = 1 ]]; then
target=darwin-aarch64
info "Your shell is running in Rosetta 2. Downloading rules for $target instead"
fi
fi
# Set up temporary directory for download and extraction
TMPDIR=$(mktemp -d)

GITHUB=${GITHUB-"https://github.com"}

Expand All @@ -68,26 +61,21 @@ fi

# Download the 'rules' CLI binary from the specified URL.
echo "Downloading '${BINARY_NAME}' CLI binary..."
echo "curl -L -o \"${TARGET_FILE}.zip\" \"${RULES_BINARY_URL}\""
curl -L -o "${TARGET_FILE}.zip" "${RULES_BINARY_URL}"
curl -L -o "${TMPDIR}/${BINARY_NAME}.zip" "${RULES_BINARY_URL}"

echo "unzip -o \"${TARGET_FILE}.zip\" -d \"${TARGET_DIR}/dist\""
unzip -o "$TARGET_FILE.zip" -d "$TARGET_DIR/dist" ||
# Extract the zip file in the temporary directory.
echo "unzip -o \"${TMPDIR}/${BINARY_NAME}.zip\" -d \"${TMPDIR}/dist\""
unzip -o "${TMPDIR}/${BINARY_NAME}.zip" -d "${TMPDIR}/dist" ||
error 'Failed to extract rules'

# rename the binary to 'rules'
mv "$TARGET_DIR/dist/rules-$target" "$TARGET_DIR/$BINARY_NAME"

# Move the binary to the target directory.
mv "${TMPDIR}/dist/rules-$target" "${TARGET_DIR}/${BINARY_NAME}"

# Make the downloaded binary executable.
chmod +x "${TARGET_FILE}"

# remove the dist directory
rm -rf "$TARGET_DIR/dist"

# remove the downloaded zip file
rm "$TARGET_FILE.zip"

# Clean up the temporary directory.
rm -rf "${TMPDIR}"

# Verify that the 'rules' CLI binary is successfully installed.
if [ -f "${TARGET_FILE}" ]; then
Expand All @@ -110,4 +98,4 @@ if [ -f "${TARGET_FILE}" ]; then

else
echo "Installation failed. '${BINARY_NAME}' CLI could not be installed."
fi
fi

0 comments on commit feec42f

Please sign in to comment.