-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·72 lines (60 loc) · 1.94 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·72 lines (60 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
# Installs the latest feint release binary for your platform.
#
# curl -fsSL ewry.net/feint.sh | sh
#
# Set FEINT_VERSION to pin a version (e.g. FEINT_VERSION=0.2.0). Set
# FEINT_INSTALL_DIR to install somewhere other than ~/.local/bin.
set -eu
REPO="immanuwell/feint"
VERSION="${FEINT_VERSION:-latest}"
INSTALL_DIR="${FEINT_INSTALL_DIR:-$HOME/.local/bin}"
os() {
case "$(uname -s)" in
Linux) echo "unknown-linux-gnu" ;;
Darwin) echo "apple-darwin" ;;
*)
echo "error: unsupported OS $(uname -s). Build from source instead: see README.md" >&2
exit 1
;;
esac
}
arch() {
case "$(uname -m)" in
x86_64 | amd64) echo "x86_64" ;;
arm64 | aarch64) echo "aarch64" ;;
*)
echo "error: unsupported architecture $(uname -m). Build from source instead: see README.md" >&2
exit 1
;;
esac
}
target="$(arch)-$(os)"
# aarch64 Linux binaries aren't published yet.
if [ "$target" = "aarch64-unknown-linux-gnu" ]; then
echo "error: no prebuilt binary for $target yet. Build from source instead: see README.md" >&2
exit 1
fi
if [ "$VERSION" = "latest" ]; then
# GitHub's "latest" alias doesn't apply to individual asset URLs, so
# resolve the actual tag first.
VERSION="$(curl -fsSL "https://github.com/$REPO/releases/latest" -o /dev/null -w '%{url_effective}' | sed 's#.*/tag/##')"
fi
asset="feint-$VERSION-$target.tar.gz"
url="https://github.com/$REPO/releases/download/$VERSION/$asset"
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
echo "Downloading $asset..."
curl -fsSL "$url" -o "$tmp_dir/$asset"
tar xzf "$tmp_dir/$asset" -C "$tmp_dir"
mkdir -p "$INSTALL_DIR"
install -m 755 "$tmp_dir/feint-$VERSION-$target/feint" "$INSTALL_DIR/feint"
echo "Installed feint $VERSION to $INSTALL_DIR/feint"
case ":$PATH:" in
*":$INSTALL_DIR:"*) ;;
*)
echo ""
echo "$INSTALL_DIR is not on your PATH. Add this to your shell profile:"
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
;;
esac