Skip to content

Commit 3c593e1

Browse files
committed
install script
1 parent 96274ac commit 3c593e1

2 files changed

Lines changed: 54 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ FFWebP is a small, single-binary CLI for converting images between formats, thin
1515

1616
### Prebuilt binaries (recommended)
1717

18-
- Download the appropriate binary for your OS/arch from the [releases](https://github.com/coalaura/ffwebp/releases).
19-
- Choose a variant:
20-
- core: includes the most popular codecs for everyday use
21-
- full: contains all available codecs
22-
- Make the binary executable and place it on your `PATH`.
18+
You can bootstrap **ffwebp-full** with a single command. This script will detect your OS and CPU (`amd64`/`arm64`), download the correct binary and install it to `/usr/local/bin/ffwebp`.
2319

2420
```bash
25-
chmod +x ffwebp && sudo mv ffwebp /usr/local/bin/
21+
curl -sL https://src.w2k.sh/ffwebp/install.sh | sh
2622
```
2723

2824
### Build from source (optional)

install.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
set -e
3+
4+
OS=$(uname -s | tr 'A-Z' 'a-z')
5+
6+
ARCH=$(uname -m)
7+
case "$ARCH" in
8+
x86_64)
9+
ARCH=amd64
10+
;;
11+
aarch64|arm64)
12+
ARCH=arm64
13+
;;
14+
*)
15+
echo "Unsupported architecture: $ARCH" >&2
16+
exit 1
17+
;;
18+
esac
19+
20+
echo "Resolving latest version..."
21+
22+
VERSION=$(curl -sL https://api.github.com/repos/coalaura/ffwebp/releases/latest | grep -Po '"tag_name": *"\K.*?(?=")')
23+
24+
if ! printf '%s\n' "$VERSION" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
25+
echo "Error: '$VERSION' is not in vMAJOR.MINOR.PATCH format" >&2
26+
exit 1
27+
fi
28+
29+
rm -f /tmp/ffwebp
30+
31+
BIN="ffwebp_${VERSION}_full_${OS}_${ARCH}"
32+
URL="https://github.com/coalaura/ffwebp/releases/download/${VERSION}/${BIN}"
33+
34+
echo "Downloading ${BIN}..."
35+
36+
if ! curl -sL "$URL" -o /tmp/ffwebp; then
37+
echo "Error: failed to download $URL" >&2
38+
exit 1
39+
fi
40+
41+
trap 'rm -f /tmp/ffwebp' EXIT
42+
43+
chmod +x /tmp/ffwebp
44+
45+
echo "Installing to /usr/local/bin/ffwebp requires sudo"
46+
47+
if ! sudo install -m755 /tmp/ffwebp /usr/local/bin/ffwebp; then
48+
echo "Error: install failed" >&2
49+
exit 1
50+
fi
51+
52+
echo "ffwebp $VERSION installed to /usr/local/bin/ffwebp"

0 commit comments

Comments
 (0)