aboutsummaryrefslogtreecommitdiff
path: root/installer/install-clangd.sh
blob: ddb235fdc8cb0af776dd4f61635891422622bbe0 (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
#!/usr/bin/env bash

set -e

os=$(uname -s | tr "[:upper:]" "[:lower:]")

case $os in
linux)
  platform="pc-linux-gnu"
  ;;
darwin)
  platform="darwin-apple"
  ;;
esac

if command -v lsb_release 2>/dev/null; then
  distributor_id=$(lsb_release -a 2>&1 | grep 'Distributor ID' | awk '{print $3}')
elif [ -e /etc/fedora-release ]; then
  distributor_id="Fedora"
elif [ -e /etc/redhat-release ]; then
  distributor_id=$(cat /etc/redhat-release | cut -d ' ' -f 1)
elif [ -e /etc/arch-release ]; then
  distributor_id="Arch"
elif [ -e /etc/SuSE-release ]; then
  distributor_id="SUSE"
elif [ -e /etc/mandriva-release ]; then
  distributor_id="Mandriva"
elif [ -e /etc/vine-release ]; then
  distributor_id="Vine"
elif [ -e /etc/gentoo-release ]; then
  distributor_id="Gentoo"
else
  distributor_id="Unkown"
fi

case $distributor_id in
# Check Ubuntu version
Ubuntu)
  ubuntu_version=$(lsb_release -a 2>&1 | grep 'Release' | awk '{print $2}')
  case $ubuntu_version in
  14.04 | 16.04 | 18.04)
    platform="linux-gnu-ubuntu-$ubuntu_version"
    ;;
  esac
  ;;
# Check LinuxMint version
LinuxMint)
  linuxmint_version=$(lsb_release -a 2>&1 | grep 'Release' | awk '{print $2}')
  case $linuxmint_version in
  19 | 19.1 | 19.2 | 19.3)
    platform="linux-gnu-ubuntu-18.04"
    ;;
  18 | 18.1 | 18.2 | 18.3)
    platform="linux-gnu-ubuntu-16.04"
    ;;
  esac
  ;;
# Check RedHat OS version
Fedora | Oracle | CentOS)
  platform="linux-sles11.3"
  ;;
esac

filename="clang+llvm-9.0.0-x86_64-$platform"
url="http://releases.llvm.org/9.0.0/$filename.tar.xz"
echo "Downloading clangd and LLVM..."
echo hello
curl -L "$url" | unxz | tar x --strip-components=1 $filename/
ln -sf bin/clangd .
./clangd --version