-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathinstall.sh
More file actions
84 lines (71 loc) · 1.81 KB
/
Copy pathinstall.sh
File metadata and controls
84 lines (71 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
set -e
REPO="refaktor/rye"
INSTALL_DIR="/usr/local/bin"
# 1. Detect Architecture
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64)
ARCH="x86_64"
;;
aarch64|arm64)
ARCH="arm64"
;;
*)
echo "Error: Unsupported architecture $ARCH"
exit 1
;;
esac
# 2. Detect OS
OS=$(uname -s)
case "$OS" in
Linux)
OS="Linux"
;;
Darwin)
OS="Darwin"
;;
*)
echo "Error: Unsupported OS $OS"
exit 1
;;
esac
# 3. Determine Download Tool (wget or curl)
if command -v curl >/dev/null 2>&1; then
FETCH="curl -fsSL"
elif command -v wget >/dev/null 2>&1; then
FETCH="wget -qO-"
else
echo "Error: Neither curl nor wget is installed."
exit 1
fi
# 4. Fetch Latest Release Version Tag
echo "Fetching latest Rye release tag..."
TAG=$($FETCH "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$TAG" ]; then
echo "Error: Could not determine latest release version."
exit 1
fi
TARBALL="rye_${OS}_${ARCH}.tar.gz"
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$TAG/$TARBALL"
# 5. Download and Extract
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
echo "Downloading Rye $TAG for $OS/$ARCH..."
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$DOWNLOAD_URL" -o "$TMP_DIR/$TARBALL"
else
wget -q "$DOWNLOAD_URL" -O "$TMP_DIR/$TARBALL"
fi
tar -xzf "$TMP_DIR/$TARBALL" -C "$TMP_DIR"
# 6. Install Binary
if [ -w "$INSTALL_DIR" ]; then
mv "$TMP_DIR/rye" "$INSTALL_DIR/rye"
else
echo "Installing to $INSTALL_DIR requires elevated privileges."
sudo mv "$TMP_DIR/rye" "$INSTALL_DIR/rye"
fi
chmod +x "$INSTALL_DIR/rye"
echo ""
echo "Successfully installed Rye ($TAG) to $INSTALL_DIR/rye"
echo "Run 'rye' to start the REPL!"