30 lines
891 B
Bash
Executable File
30 lines
891 B
Bash
Executable File
#!/bin/sh
|
|
# Download and install rust analyzer to ~/.local/bin
|
|
|
|
set -ex
|
|
|
|
## Set this to get a fixed version
|
|
# PIN_VERSION="2022-05-02"
|
|
|
|
if [ -n "$PIN_VERSION" ]
|
|
then
|
|
REPO="https://github.com/rust-analyzer/rust-analyzer"
|
|
VERSION="$PIN_VERSION"
|
|
DLURL="$REPO/releases/download/$VERSION/rust-analyzer-x86_64-unknown-linux-gnu.gz"
|
|
else
|
|
API_URL="https://api.github.com/repos/rust-lang/rust-analyzer/releases/latest"
|
|
API_RESP="$(curl "$API_URL")"
|
|
VERSION=$(echo "$API_RESP" | jq -r '.tag_name')
|
|
DLURL=$(echo "$API_RESP" | jq -r '.assets[]|select(.name|match("x86_64.*gnu")).browser_download_url')
|
|
fi
|
|
|
|
GZFILE="$HOME/.cache/rust-analyzer-$VERSION-x86_64-unknown-linux-gnu.gz"
|
|
BINDIR="$HOME/.local/bin"
|
|
|
|
test -f "$GZFILE" ||
|
|
wget -O "$GZFILE" "$DLURL"
|
|
|
|
rm -f "$BINDIR/rust-analyzer"
|
|
gunzip "$GZFILE" --stdout > "$BINDIR/rust-analyzer"
|
|
chmod u+x "$BINDIR/rust-analyzer"
|