-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·65 lines (53 loc) · 1.83 KB
/
install.sh
File metadata and controls
executable file
·65 lines (53 loc) · 1.83 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
#!/bin/bash
set -e
OWNER="sonesuke"
REPO="arxiv-cli"
BINARY_NAME="arxiv-cli"
# Detect OS and Arch
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64) ARCH="x86_64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
case "$OS" in
linux) PLATFORM="linux-${ARCH}" ;;
darwin) PLATFORM="macos-${ARCH}" ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
echo "Detecting latest version..."
LATEST_TAG=$(curl -s "https://api.github.com/repos/$OWNER/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$LATEST_TAG" ]; then
echo "Failed to fetch latest version."
exit 1
fi
echo "Downloading $BINARY_NAME $LATEST_TAG for $PLATFORM..."
ASSET_NAME="${BINARY_NAME}-${PLATFORM}.tar.gz"
DOWNLOAD_URL="https://github.com/$OWNER/$REPO/releases/download/$LATEST_TAG/$ASSET_NAME"
TEMP_DIR=$(mktemp -d)
curl -L "$DOWNLOAD_URL" -o "$TEMP_DIR/$ASSET_NAME"
tar -xzf "$TEMP_DIR/$ASSET_NAME" -C "$TEMP_DIR"
if [ "$OS" = "linux" ]; then
# User-local installation for Linux without sudo
INSTALL_DIR="$HOME/.local/bin"
else
# On macOS, try /usr/local/bin if writable (no sudo required), else fallback to ~/.local/bin
if [ -w "/usr/local/bin" ]; then
INSTALL_DIR="/usr/local/bin"
else
INSTALL_DIR="$HOME/.local/bin"
fi
fi
echo "Installing to $INSTALL_DIR..."
mkdir -p "$INSTALL_DIR"
mv "$TEMP_DIR/$BINARY_NAME" "$INSTALL_DIR/"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
rm -rf "$TEMP_DIR"
echo "Successfully installed $BINARY_NAME $LATEST_TAG to $INSTALL_DIR"
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo ""
echo "WARNING: $INSTALL_DIR is not in your PATH."
echo "Please add the following line to your shell profile (e.g., ~/.bashrc, ~/.zshrc):"
echo "export PATH=\"\$PATH:$INSTALL_DIR\""
fi