Skip to content

Commit 1762eab

Browse files
committed
chore: Add installation script and improve manual installation instructions
1 parent eca73ac commit 1762eab

File tree

2 files changed

+195
-1
lines changed

2 files changed

+195
-1
lines changed

docs/about/installation.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,37 @@ To use this configuration:
5757

5858
### GitHub Releases
5959

60-
Download pre-compiled binaries for multiple platforms from the [GitHub releases page](https://github.com/Quozul/PicoLimbo/releases).
60+
For the easiest installation, use the one-line install script:
61+
62+
```bash
63+
curl -fsSL https://picolimbo.quozul.dev/pico_limbo_installation.sh | bash
64+
```
65+
66+
**Requirements:** Linux, curl, and bash
67+
68+
If you cannot use the installation script due to missing dependencies or unsupported platform, you can manually download the appropriate binary from the [GitHub releases page](https://github.com/Quozul/PicoLimbo/releases).
69+
70+
#### Choosing the Right Binary
71+
72+
Select the binary that matches your system:
73+
74+
- **`pico_limbo_linux-x86_64-musl.tar.gz`** - Linux systems with Intel/AMD 64-bit processors (most common)
75+
- **`pico_limbo_linux-aarch64-musl.tar.gz`** - Linux systems with ARM 64-bit processors (e.g., Raspberry Pi 4+, Apple Silicon under emulation)
76+
- **`pico_limbo_macos-aarch64.tar.gz`** - macOS with Apple Silicon (M1/M2/M3 chips)
77+
- **`pico_limbo_windows-x86_64.zip`** - Windows with Intel/AMD 64-bit processors
78+
79+
#### Manual Installation
80+
81+
1. **Download** the appropriate binary for your system from the releases page
82+
2. **Extract** the archive:
83+
- **Linux/macOS**: `tar -xzf pico_limbo_*.tar.gz`
84+
- **Windows**: Use your preferred archive tool or built-in extraction
85+
3. **Run** the binary:
86+
- **Linux/macOS**: `./pico_limbo`
87+
- **Windows**: Double-click `pico_limbo.exe` or run it from Command Prompt
88+
89+
> [!TIP]
90+
> On Linux systems, you may want to move the binary to a directory in your PATH (like `/usr/local/bin/`) to run it from anywhere, or make it executable with `chmod +x pico_limbo` if needed.
6191

6292
### Compiling from Source
6393

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
NC='\033[0m'
9+
10+
REPO="Quozul/PicoLimbo"
11+
BINARY_NAME="pico_limbo"
12+
13+
print_status() {
14+
echo -e "${GREEN}[INFO]${NC} $1" >&2
15+
}
16+
17+
print_warning() {
18+
echo -e "${YELLOW}[WARN]${NC} $1" >&2
19+
}
20+
21+
print_error() {
22+
echo -e "${RED}[ERROR]${NC} $1" >&2
23+
}
24+
25+
detect_arch() {
26+
local arch=$(uname -m)
27+
case $arch in
28+
x86_64)
29+
echo "x86_64"
30+
;;
31+
aarch64|arm64)
32+
echo "aarch64"
33+
;;
34+
*)
35+
print_error "Unsupported architecture: $arch"
36+
print_error "Supported architectures: x86_64, aarch64"
37+
exit 1
38+
;;
39+
esac
40+
}
41+
42+
get_install_dir() {
43+
if [[ $EUID -eq 0 ]]; then
44+
echo "/usr/local/bin"
45+
else
46+
local user_bin="$HOME/.local/bin"
47+
mkdir -p "$user_bin"
48+
echo "$user_bin"
49+
fi
50+
}
51+
52+
check_path() {
53+
local dir="$1"
54+
if [[ ":$PATH:" != *":$dir:"* ]]; then
55+
print_warning "Directory '$dir' is not in your PATH."
56+
print_warning "Please add the following line to your shell profile (e.g., ~/.bashrc or ~/.zshrc):"
57+
print_warning "export PATH=\"\$PATH:$dir\""
58+
fi
59+
}
60+
61+
get_latest_release_url() {
62+
local arch="$1"
63+
local api_url="https://api.github.com/repos/$REPO/releases/latest"
64+
65+
local download_url
66+
if command -v curl >/dev/null 2>&1; then
67+
download_url=$(curl -s "$api_url" | grep -o "https://[^\"]*linux-${arch}-musl\.tar\.gz" | head -1)
68+
elif command -v wget >/dev/null 2>&1; then
69+
download_url=$(wget -qO- "$api_url" | grep -o "https://[^\"]*linux-${arch}-musl\.tar\.gz" | head -1)
70+
else
71+
print_error "Neither curl nor wget is available. Please install one of them."
72+
exit 1
73+
fi
74+
75+
if [[ -z "$download_url" ]]; then
76+
print_error "Could not find download URL for architecture: $arch"
77+
print_error "Please check if a release asset exists for your architecture."
78+
exit 1
79+
fi
80+
81+
echo "$download_url"
82+
}
83+
84+
download_and_install() {
85+
local url="$1"
86+
local install_dir="$2"
87+
local temp_dir=$(mktemp -d)
88+
89+
local filename=$(basename "$url")
90+
if command -v curl >/dev/null 2>&1; then
91+
if ! curl --fail --silent --location -o "$temp_dir/$filename" "$url"; then
92+
print_error "Failed to download the file using curl."
93+
rm -rf "$temp_dir"
94+
exit 1
95+
fi
96+
else
97+
if ! wget --quiet -O "$temp_dir/$filename" "$url"; then
98+
print_error "Failed to download the file using wget."
99+
rm -rf "$temp_dir"
100+
exit 1
101+
fi
102+
fi
103+
104+
if ! tar -xzf "$temp_dir/$filename" -C "$temp_dir"; then
105+
print_error "Failed to extract the archive. It may be corrupted."
106+
rm -rf "$temp_dir"
107+
exit 1
108+
fi
109+
110+
local binary_path=$(find "$temp_dir" -name "$BINARY_NAME" -type f | head -1)
111+
112+
if [[ -z "$binary_path" ]]; then
113+
print_error "Could not find '$BINARY_NAME' in the extracted files."
114+
print_error "Contents of archive:"
115+
find "$temp_dir"
116+
rm -rf "$temp_dir"
117+
exit 1
118+
fi
119+
120+
if ! mv "$binary_path" "$install_dir/$BINARY_NAME"; then
121+
print_error "Failed to move binary to $install_dir. Check permissions."
122+
rm -rf "$temp_dir"
123+
exit 1
124+
fi
125+
chmod +x "$install_dir/$BINARY_NAME"
126+
127+
rm -rf "$temp_dir"
128+
}
129+
130+
main() {
131+
if [[ "$(uname)" != "Linux" ]]; then
132+
print_error "This script is designed for Linux systems only."
133+
exit 1
134+
fi
135+
136+
local arch=$(detect_arch)
137+
138+
local install_dir=$(get_install_dir)
139+
140+
if [[ ! -w "$install_dir" ]]; then
141+
print_error "No write permission to $install_dir."
142+
if [[ $EUID -ne 0 ]]; then
143+
print_error "Try running with 'sudo' for a global installation."
144+
fi
145+
exit 1
146+
fi
147+
148+
local download_url=$(get_latest_release_url "$arch")
149+
150+
download_and_install "$download_url" "$install_dir"
151+
152+
if [[ $EUID -ne 0 ]]; then
153+
check_path "$install_dir"
154+
fi
155+
156+
local binary_path="$install_dir/$BINARY_NAME"
157+
print_status "The program has been installed at: $binary_path"
158+
159+
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
160+
"$BINARY_NAME" --help
161+
fi
162+
}
163+
164+
main "$@"

0 commit comments

Comments
 (0)