-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathdl_binaries.sh
executable file
·56 lines (51 loc) · 1.69 KB
/
dl_binaries.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
#!/bin/sh
set -e
TABNINE_UPDATE_SERVICE=${1:-"https://update.tabnine.com"}
DEPENDS='unzip curl' # list of dependencies (commands)
HAS_ALL_DEPS=1 # 1 = present, 0 = missing
for dep in ${DEPENDS}; do
if ! command -v "$dep" >/dev/null 2>/dev/null; then # if command not accessible
echo "ERROR: $dep is required to download Tabnine binaries. Please install $dep and run this again." >&2
HAS_ALL_DEPS=0
fi
done
if [ "${HAS_ALL_DEPS}" -eq 0 ]; then # missing something.
exit 1
fi
# This script downloads the binaries for the most recent version of TabNine.
# Infrastructure detection heavily inspired by https://github.com/tzachar/cmp-tabnine/blob/main/install.sh
version=${version:-$(curl -fsSL "$TABNINE_UPDATE_SERVICE/bundles/version")}
case $(uname -s) in
"Darwin")
if [ "$(uname -m)" = "arm64" ]; then
targets="aarch64-apple-darwin"
elif [ "$(uname -m)" = "x86_64" ]; then
targets="x86_64-apple-darwin"
fi
;;
"Linux")
if [ "$(uname -m)" = "x86_64" ]; then
targets="x86_64-unknown-linux-musl"
elif [ "$(uname -m)" = "aarch64" ]; then
targets="aarch64-unknown-linux-musl"
fi
;;
esac
if [ -z "$targets" ]; then
echo "Target detection failed. Installing all targets"
targets='x86_64-apple-darwin
x86_64-unknown-linux-musl
aarch64-unknown-linux-musl
aarch64-apple-darwin'
fi
rm -rf ./binaries
echo "$targets" | while read -r target; do
mkdir -p "binaries/$version/$target"
path=$version/$target
echo "downloading $path"
curl -fsSL "$TABNINE_UPDATE_SERVICE/bundles/$path/TabNine.zip" -o "binaries/$path/TabNine.zip" ||
continue
unzip -o "binaries/$path/TabNine.zip" -d "binaries/$path"
rm "binaries/$path/TabNine.zip"
chmod +x "binaries/$path/"*
done