mirror of
https://github.com/coalaura/ffwebp.git
synced 2025-09-08 13:59:54 +00:00
install script
This commit is contained in:
@@ -15,14 +15,10 @@ FFWebP is a small, single-binary CLI for converting images between formats, thin
|
|||||||
|
|
||||||
### Prebuilt binaries (recommended)
|
### Prebuilt binaries (recommended)
|
||||||
|
|
||||||
- Download the appropriate binary for your OS/arch from the [releases](https://github.com/coalaura/ffwebp/releases).
|
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`.
|
||||||
- Choose a variant:
|
|
||||||
- core: includes the most popular codecs for everyday use
|
|
||||||
- full: contains all available codecs
|
|
||||||
- Make the binary executable and place it on your `PATH`.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
chmod +x ffwebp && sudo mv ffwebp /usr/local/bin/
|
curl -sL https://src.w2k.sh/ffwebp/install.sh | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
### Build from source (optional)
|
### Build from source (optional)
|
||||||
|
52
install.sh
Normal file
52
install.sh
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
OS=$(uname -s | tr 'A-Z' 'a-z')
|
||||||
|
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
case "$ARCH" in
|
||||||
|
x86_64)
|
||||||
|
ARCH=amd64
|
||||||
|
;;
|
||||||
|
aarch64|arm64)
|
||||||
|
ARCH=arm64
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported architecture: $ARCH" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "Resolving latest version..."
|
||||||
|
|
||||||
|
VERSION=$(curl -sL https://api.github.com/repos/coalaura/ffwebp/releases/latest | grep -Po '"tag_name": *"\K.*?(?=")')
|
||||||
|
|
||||||
|
if ! printf '%s\n' "$VERSION" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
|
||||||
|
echo "Error: '$VERSION' is not in vMAJOR.MINOR.PATCH format" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f /tmp/ffwebp
|
||||||
|
|
||||||
|
BIN="ffwebp_${VERSION}_full_${OS}_${ARCH}"
|
||||||
|
URL="https://github.com/coalaura/ffwebp/releases/download/${VERSION}/${BIN}"
|
||||||
|
|
||||||
|
echo "Downloading ${BIN}..."
|
||||||
|
|
||||||
|
if ! curl -sL "$URL" -o /tmp/ffwebp; then
|
||||||
|
echo "Error: failed to download $URL" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
trap 'rm -f /tmp/ffwebp' EXIT
|
||||||
|
|
||||||
|
chmod +x /tmp/ffwebp
|
||||||
|
|
||||||
|
echo "Installing to /usr/local/bin/ffwebp requires sudo"
|
||||||
|
|
||||||
|
if ! sudo install -m755 /tmp/ffwebp /usr/local/bin/ffwebp; then
|
||||||
|
echo "Error: install failed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "ffwebp $VERSION installed to /usr/local/bin/ffwebp"
|
Reference in New Issue
Block a user