From 818275b7249250780ddd5ed021cae64288514270 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Fri, 25 Mar 2022 22:57:31 +0000 Subject: Add support to `sudo` if necessary Instead if executing system-relevant changes directly, use `sudo` on Ubuntu-based machines. Simplifies the installation procedure. --- scripts/build/p-clang-linux-ubuntu.inc | 45 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'scripts/build/p-clang-linux-ubuntu.inc') diff --git a/scripts/build/p-clang-linux-ubuntu.inc b/scripts/build/p-clang-linux-ubuntu.inc index fb781513..736cc097 100644 --- a/scripts/build/p-clang-linux-ubuntu.inc +++ b/scripts/build/p-clang-linux-ubuntu.inc @@ -6,37 +6,36 @@ install_binary_artifact_clang() { [[ "${LLVM_VERSION_MAJOR}" -le 6 ]] && version="-${LLVM_VERSION}" [[ "${LLVM_VERSION_MAJOR}" -ge 7 ]] && version="-${LLVM_VERSION_MAJOR}" - # apt.llvm packages for Trusty clang 5.0 package is broken with atomics. Don't use it. - if [[ "${LLVM_VERSION_MAJOR}" -gt 6 ]]; then - # Add certificate - apt update -y - dependencies=( - ca-certificates - wget - lsb-release - gnupg - ) - - apt -y --no-install-recommends install "${dependencies[@]}" - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key| 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}" >> /etc/apt/sources.list - apt update -y - fi + source "${DIR}/common-functions" + + # 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 - apt update -y + with_sudo apt update -y dependencies=( "llvm${version}" "clang${version}" ) #Install essential dependencies - apt -y --no-install-recommends install "${dependencies[@]}" || return 1 + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" || return 1 } get_docker_config_id_clang() { -- cgit 1.4.1