-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·72 lines (60 loc) · 1.94 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
63
64
65
66
67
68
69
70
71
#!/usr/bin/env sh
#
# Download the `ctags-query` binary, falling back to building with `cargo` if that fails.
#
# Script modified from autozimu/LanguageClient-neovim
# https://github.com/autozimu/LanguageClient-neovim/blob/next/LICENSE.txt
#
# Copyright (c) 2017 Junfeng Li <[email protected]> and contributors.
set -o nounset # error when referencing undefined variable
set -o errexit # exit when command fails
name=ctags-query
url=https://github.com/matt-snider/$name
version=0.1.1
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 "Downloading binary ${name}..."
mkdir -p bin/
url=$url/releases/download/$version/${1}
if (try_curl "$url" || try_wget "$url"); then
chmod a+x bin/$name
return
else
try_build || echo "Prebuilt binary not found, please try again shortly or report the issue\n\nhttps://github.com/matt-snider/vim-tagquery/issues"
fi
}
try_build() {
if command -v cargo > /dev/null; then
echo "Building locally..."
# Get/update repo
cd $name/ \
|| git clone $url \
&& cd $name/
git pull
cargo build --release
# Create bin
cd ..
mkdir bin/
cp $name/target/release/$name bin/
chmod a+x bin/ctags-query
else
return 1
fi
}
rm -f bin/$name
arch=$(uname -sm)
case "${arch}" in
"Linux x86_64") download $name-$version-x86_64-unknown-linux-gnu ;;
# "Linux i686") download $name-$version-i686-unknown-linux-musl ;;
# "Linux aarch64") download $name-$version-aarch64-unknown-linux-gnu ;;
# "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