Skip to content

Commit 6db43e4

Browse files
committed
Add a script to download Wild if it's not already on the path
1 parent 16466b6 commit 6db43e4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

script/install-wild

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
# Install wild-linker official binaries from GitHub Releases.
4+
5+
set -euo pipefail
6+
7+
WILD_VERSION="${WILD_VERSION:-${1:-0.5.0}}"
8+
if [ "$(uname -s)" != "Linux" ]; then
9+
echo "Error: This script is intended for Linux systems only."
10+
exit 1
11+
elif [ -z "$WILD_VERSION" ]; then
12+
echo "Usage: $0 [version]"
13+
exit 1
14+
elif which -s wild && wild --version | grep -Fq "$WILD_VERSION" ; then
15+
echo "Warning: existing wild $WILD_VERSION found at $(which wild). Skipping installation."
16+
exit 0
17+
fi
18+
19+
if [ "$(whoami)" = root ]; then SUDO=; else SUDO="$(command -v sudo || command -v doas || true)"; fi
20+
21+
ARCH="$(uname -m)"
22+
WILD_REPO="${WILD_REPO:-https://github.com/davidlattimore/wild}"
23+
WILD_PACKAGE="wild-linker-${ARCH}-unknown-linux-gnu"
24+
WILD_URL="${WILD_URL:-$WILD_REPO}/releases/download/$WILD_VERSION/${WILD_PACKAGE}.tar.xz"
25+
26+
echo "Downloading from $WILD_URL"
27+
curl -fsSL --output - "$WILD_URL" \
28+
| $SUDO tar -C /usr/local/bin --strip-components=1 --no-overwrite-dir -xJf - \
29+
"wild-linker-${ARCH}-unknown-linux-gnu/wild"

0 commit comments

Comments
 (0)