blob: 79de578ef38422b41fe3f7561af51fbc498d922d (
plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!/usr/bin/env sh
set -e
detect_os() {
case "$(uname -s)" in
Linux*) echo "linux";;
Darwin*) echo "darwin";;
*)
echo "error: unsupported OS $(uname -s)" >&2
exit 1
;;
esac
}
detect_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "amd64";;
aarch64|arm64) echo "arm64";;
*)
echo "error: unsupported architecture $(uname -m)" >&2
exit 1
;;
esac
}
checksum_tool() {
if command -v sha256sum >/dev/null 2>&1; then
echo "sha256sum -c"
elif command -v shasum >/dev/null 2>&1; then
echo "shasum -a 256 -c"
else
echo ""
fi
}
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
OS=$(detect_os)
ARCH=$(detect_arch)
echo "installing eno ($OS-$ARCH) to $INSTALL_DIR..."
command -v curl >/dev/null 2>&1 || { echo "error: curl is required" >&2; exit 1; }
RELEASE_INFO=$(curl -fsSL "https://gitlab.com/api/v4/projects/whiteboardguy%2Feno/releases/permalink/latest")
TAG=$(echo "$RELEASE_INFO" | sed -n 's/.*"tag_name":"\([^"]*\)".*/\1/p')
if [ -n "$TAG" ]; then
VERSION="${TAG#v}"
ARCHIVE_NAME="eno-${VERSION}-${OS}-${ARCH}.tar.gz"
ARCHIVE_URL="https://gitlab.com/api/v4/projects/whiteboardguy%2Feno/packages/generic/eno/${VERSION}/${ARCHIVE_NAME}"
CHECKSUM_URL="https://gitlab.com/api/v4/projects/whiteboardguy%2Feno/packages/generic/eno/${VERSION}/checksums.txt"
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
if curl -fsSL -o "$TMPDIR/eno.tar.gz" "$ARCHIVE_URL" && \
curl -fsSL -o "$TMPDIR/checksums.txt" "$CHECKSUM_URL"; then
CHK_TOOL=$(checksum_tool)
if [ -n "$CHK_TOOL" ]; then
cd "$TMPDIR"
grep "$ARCHIVE_NAME" checksums.txt | $CHK_TOOL >/dev/null 2>&1 || {
echo "error: checksum verification failed" >&2
exit 1
}
cd - >/dev/null
fi
mkdir -p "$INSTALL_DIR"
cd "$TMPDIR"
tar xzf eno.tar.gz
BINARY=$(find . -name eno -type f | head -1)
[ -z "$BINARY" ] && { echo "error: binary not found in archive" >&2; exit 1; }
install -m 755 "$BINARY" "$INSTALL_DIR/eno"
echo "installed eno $TAG to $INSTALL_DIR/eno"
case ":$PATH:" in
*":$INSTALL_DIR:"*) ;;
*) echo "note: add $INSTALL_DIR to your PATH" ;;
esac
exit 0
fi
echo "pre-built binary not available for $OS-$ARCH, trying go install..."
else
echo "no releases found, trying go install..."
fi
command -v go >/dev/null 2>&1 || { echo "error: go is required for source install" >&2; echo "see https://go.dev/dl/ to install Go" >&2; exit 1; }
go install gitlab.com/whiteboardguy/eno/cmd/eno@latest
echo "installed via go install to $(go env GOPATH)/bin/eno"
|