forked from autozimu/LanguageClient-neovim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·62 lines (53 loc) · 1.66 KB
/
install.sh
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
#!/usr/bin/env sh
# Try install by
# - download binary
# - build with cargo
set -o nounset # error when referencing undefined variable
set -o errexit # exit when command fails
version=0.1.161
name=languageclient
arch=$(uname -sm)
try_curl() {
command -v curl > /dev/null && \
curl --fail --location "$1" --output bin/$name
}
try_wget() {
command -v wget > /dev/null && \
wget --output-document=bin/$name "$1"
}
download() {
echo "Trying download bin/${name} ${version}..."
url=https://github.com/autozimu/LanguageClient-neovim/releases/download/$version/${1}
if (try_curl "$url" || try_wget "$url"); then
chmod a+x bin/$name
return
else
echo "Prebuilt binary is not available for:" "${arch}"
try_build
fi
}
try_build() {
if command -v cargo > /dev/null; then
echo "Trying build locally ${version} ..."
make release
else
echo "cargo is not available. Abort."
return 1
fi
}
bin=bin/languageclient
if [ -f "$bin" ]; then
installed_version=$($bin -V)
case "${installed_version}" in
*${version}*) echo "Version is equal to ${version}, skip install." ; exit 0 ;;
*) rm -f "$bin" ;;
esac
fi
case "${arch}" in
"Linux x86_64") download $name-$version-x86_64-unknown-linux-musl ;;
"Linux i686") download $name-$version-i686-unknown-linux-musl ;;
"Linux aarch64") download $name-$version-aarch64-unknown-linux-musl ;;
"Darwin x86_64") download $name-$version-x86_64-apple-darwin ;;
"FreeBSD amd64") download $name-$version-x86_64-unknown-freebsd ;;
*) echo "No pre-built binary available for ${arch}."; try_build ;;
esac