|
6 | 6 | set -e |
7 | 7 |
|
8 | 8 | sudo apt-get update |
| 9 | + |
9 | 10 | # Install lsb_release to check Ubuntu version |
10 | | -sudo apt-get -y install --no-install-recommends lsb-release git wget |
| 11 | +sudo apt-get -y install --no-install-recommends lsb-release git wget gnupg ca-certificates |
| 12 | + |
| 13 | +# Get the current Ubuntu system version |
| 14 | +VERSION=$(lsb_release -rs) |
| 15 | +# Get the current Ubuntu system codename |
| 16 | +CODENAME=$(lsb_release -cs) |
| 17 | + |
| 18 | +echo "Ubuntu version: $VERSION, Ubuntu codename: $CODENAME" |
| 19 | + |
| 20 | +# Define the LLVM version corresponding to different Ubuntu versions. |
| 21 | +# Ubuntu 18.04 -> LLVM 11 |
| 22 | +# Ubuntu 20.04 22.04 24.04 -> LLVM 13 |
| 23 | +declare -A LLVM_VERSION_MAP=( |
| 24 | + ["18.04"]="11" |
| 25 | + ["20.04"]="13" |
| 26 | + ["22.04"]="13" |
| 27 | + ["24.04"]="13" |
| 28 | +) |
| 29 | + |
| 30 | +# Obtain the LLVM version that should be installed on the current system. |
| 31 | +TARGET_LLVM_VERSION=${LLVM_VERSION_MAP[$VERSION]} |
11 | 32 |
|
12 | | -if [[ $(lsb_release -rs) == "18.04" ]]; then |
| 33 | +# LLVM sources.list file |
| 34 | +LLVM_SOURCES_LIST_FILE="/etc/apt/sources.list.d/llvm.list" |
| 35 | +# LLVM gpg key file |
| 36 | +LLVM_GPG_KEY_FILE="/etc/apt/trusted.gpg.d/llvm.gpg" |
| 37 | + |
| 38 | +# soupport ubuntu 18.04 20.04 22.04 24.04 |
| 39 | +if [ "$VERSION" == "18.04" ]; then |
13 | 40 | # Add Kitware's APT repository to get cmake 3.15 or newer on Ubuntu 18.04 following https://apt.kitware.com/ |
14 | | - sudo apt-get -y install \ |
15 | | - apt-transport-https \ |
16 | | - ca-certificates \ |
17 | | - gnupg \ |
18 | | - software-properties-common \ |
19 | | - wget |
20 | | - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null |
21 | | - sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' |
22 | | - |
23 | | - # Add LLVM APT repository to get clang-11/libc++-11 on Ubuntu 18.04 |
24 | | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - |
25 | | - sudo apt-add-repository 'deb http://apt.llvm.org/bionic llvm-toolchain-bionic-11 main' |
26 | | -fi |
| 41 | + # bionic |
| 42 | + sudo apt-get -y install \ |
| 43 | + apt-transport-https \ |
| 44 | + software-properties-common |
27 | 45 |
|
28 | | -if [[ $(lsb_release -rs) == "20.04" ]]; then |
29 | | - sudo apt-get -y install software-properties-common |
30 | | - # Add Ubuntu proposed main and universe repositories to get clang-13/libc++-13 on Ubuntu 20.04 |
31 | | - sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu/ focal-proposed main universe" |
| 46 | + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null |
| 47 | + sudo apt-add-repository -y "deb https://apt.kitware.com/ubuntu/ ${CODENAME} main" |
| 48 | + |
| 49 | + # Add the official Vulkan PPA repository to support the installation of vulkan-tools on Ubuntu 18.04. |
| 50 | + sudo add-apt-repository -y ppa:graphics-drivers/ppa |
32 | 51 | fi |
33 | 52 |
|
| 53 | +# Add LLVM APT repository to get clang-11/libc++-11 on Ubuntu 18.04 |
| 54 | +# Add LLVM APT repository to get clang-13/libc++-13 on Ubuntu 20.04 22.04 24.04 |
| 55 | +wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key 2>/dev/null | sudo gpg --dearmor - | sudo tee ${LLVM_GPG_KEY_FILE} >/dev/null |
| 56 | +echo "deb [signed-by=${LLVM_GPG_KEY_FILE}] http://apt.llvm.org/${CODENAME}/ llvm-toolchain-${CODENAME}-${TARGET_LLVM_VERSION} main" | sudo tee ${LLVM_SOURCES_LIST_FILE} |
| 57 | + |
| 58 | +# Update package lists |
| 59 | +sudo apt-get update |
| 60 | + |
34 | 61 | # Install prerequisites |
35 | 62 | sudo apt-get -y install --no-install-recommends \ |
36 | 63 | build-essential \ |
37 | 64 | rsync \ |
38 | 65 | make \ |
39 | 66 | cmake \ |
40 | | - clang-13 \ |
41 | | - libc++-13-dev \ |
42 | | - libc++abi-13-dev \ |
| 67 | + clang-${TARGET_LLVM_VERSION} \ |
| 68 | + libc++-${TARGET_LLVM_VERSION}-dev \ |
| 69 | + libc++abi-${TARGET_LLVM_VERSION}-dev \ |
43 | 70 | ninja-build \ |
44 | 71 | libvulkan1 \ |
45 | 72 | vulkan-tools |
0 commit comments