1#!/usr/bin/env bash
2
3# Install wild-linker official binaries from GitHub Releases.
4
5set -euo pipefail
6
7WILD_VERSION="${WILD_VERSION:-${1:-0.6.0}}"
8if [ "$(uname -s)" != "Linux" ]; then
9 echo "Error: This script is intended for Linux systems only."
10 exit 1
11elif [ -z "$WILD_VERSION" ]; then
12 echo "Usage: $0 [version]"
13 exit 1
14elif 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
17fi
18
19if [ "$(whoami)" = root ]; then SUDO=; else SUDO="$(command -v sudo || command -v doas || true)"; fi
20
21ARCH="$(uname -m)"
22WILD_REPO="${WILD_REPO:-https://github.com/davidlattimore/wild}"
23WILD_PACKAGE="wild-linker-${WILD_VERSION}-${ARCH}-unknown-linux-gnu"
24WILD_URL="${WILD_URL:-$WILD_REPO}/releases/download/$WILD_VERSION/${WILD_PACKAGE}.tar.gz"
25
26echo "Downloading from $WILD_URL"
27curl -fsSL --output - "$WILD_URL" \
28 | $SUDO tar -C /usr/local/bin --strip-components=1 --no-overwrite-dir -xzf - \
29 "${WILD_PACKAGE}/wild"