about summary refs log tree commit diff homepage
path: root/scripts/build/p-sanitizer-linux-ubuntu.inc
blob: bb6187ea116f6a5986f632d2c6d0ecccfa6e04db (plain) (blame)
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
install_binary_artifact_sanitizer() {
  if [[ -z "${SANITIZER_BUILD:=}" ]]; then
    return 1
  fi

  source "${DIR}/common-functions"
  local SANITIZER_LLVM_VERSION_MAJOR="${SANITIZER_LLVM_VERSION/.*/}"
  local SANITIZER_LLVM_VERSION_MINOR="${SANITIZER_LLVM_VERSION/*./}"

  local version=""
  [[ "${SANITIZER_LLVM_VERSION_MAJOR}" -le 6 ]] && version="-${SANITIZER_LLVM_VERSION}"
  [[ "${SANITIZER_LLVM_VERSION_MAJOR}" -ge 7 ]] && version="-${SANITIZER_LLVM_VERSION_MAJOR}"

  # Add certificate
  with_sudo apt update -y
  dependencies=(
    ca-certificates
    wget
    lsb-release
    gnupg
  )

  with_sudo apt -y --no-install-recommends install "${dependencies[@]}"
  wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | with_sudo apt-key add -

  # Add repository
  codename="$(lsb_release --codename --short)"
  apt_entry="deb http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}${version} main"
  if [[ ! $(grep -rq "${apt_entry}" /etc/apt) ]]; then
    echo "${apt_entry}" | with_sudo tee -a /etc/apt/sources.list
    with_sudo apt update -y
  fi

  with_sudo apt update -y
  dependencies=(
    "llvm${version}"
    "clang${version}"
  )

  #Install essential dependencies
  with_sudo apt -y --no-install-recommends install "${dependencies[@]}" || return 1
}

get_docker_config_id_sanitizer() {
  return 0
}