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/common-functions | 9 +++++++ scripts/build/p-clang-linux-ubuntu.inc | 45 +++++++++++++++---------------- scripts/build/p-gtest-linux-ubuntu.inc | 5 ++-- scripts/build/p-klee-linux-ubuntu.inc | 10 ++++--- scripts/build/p-klee-osx.inc | 8 +++++- scripts/build/p-klee.inc | 1 + scripts/build/p-libcxx-linux-ubuntu.inc | 14 ++++++---- scripts/build/p-libcxx-osx.inc | 4 ++- scripts/build/p-llvm-linux-ubuntu.inc | 13 ++++----- scripts/build/p-metasmt-linux-ubuntu.inc | 5 ++-- scripts/build/p-sqlite-linux-ubuntu.inc | 10 ++++--- scripts/build/p-stp-linux-ubuntu.inc | 8 +++--- scripts/build/p-tcmalloc-linux-ubuntu.inc | 5 ++-- scripts/build/p-uclibc-linux-ubuntu.inc | 6 ++--- scripts/build/p-z3-linux-ubuntu.inc | 7 ++--- scripts/build/run-tests.sh | 2 ++ 16 files changed, 92 insertions(+), 60 deletions(-) (limited to 'scripts') diff --git a/scripts/build/common-functions b/scripts/build/common-functions index 6d810d73..c964419f 100644 --- a/scripts/build/common-functions +++ b/scripts/build/common-functions @@ -30,4 +30,13 @@ function get_git_hash() { else echo "${commit_id:0:7}" fi +} + +function with_sudo() { + echo "Checking sudo $@" + if [[ $(whoami) != "root" ]]; then + sudo "$@" + else + "$@" + fi } \ No newline at end of file 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() { diff --git a/scripts/build/p-gtest-linux-ubuntu.inc b/scripts/build/p-gtest-linux-ubuntu.inc index f636d321..15b4f36a 100644 --- a/scripts/build/p-gtest-linux-ubuntu.inc +++ b/scripts/build/p-gtest-linux-ubuntu.inc @@ -1,5 +1,6 @@ install_build_dependencies_gtest() { - apt update -y + source "${DIR}/common-functions" + with_sudo apt update -y dependencies=( ca-certificates @@ -8,5 +9,5 @@ install_build_dependencies_gtest() { ) #Install essential dependencies - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" } \ No newline at end of file diff --git a/scripts/build/p-klee-linux-ubuntu.inc b/scripts/build/p-klee-linux-ubuntu.inc index 4b8a89bf..98cac0c5 100644 --- a/scripts/build/p-klee-linux-ubuntu.inc +++ b/scripts/build/p-klee-linux-ubuntu.inc @@ -1,5 +1,5 @@ install_build_dependencies_klee() { - apt update -y + source "${DIR}/common-functions" # Add Kitware's certificate for CMake dependencies=( @@ -42,8 +42,10 @@ install_build_dependencies_klee() { dependencies+=(doxygen graphviz) fi - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" - pip3 install lit - pip3 install tabulate + pip3 install --user lit + pip3 install --user tabulate + base_path="$(python3 -m site --user-base)" + export PATH="$PATH:${base_path}/bin" } diff --git a/scripts/build/p-klee-osx.inc b/scripts/build/p-klee-osx.inc index 38eaa02c..0561e28f 100644 --- a/scripts/build/p-klee-osx.inc +++ b/scripts/build/p-klee-osx.inc @@ -2,8 +2,14 @@ install_build_dependencies_klee() { brew upgrade python # upgrade to Python 3 brew link --overwrite python + if [[ $(to_bool "${ENABLE_DOXYGEN}") -eq 1 ]]; then brew install doxygen graphviz fi - pip3 install lit tabulate + + pip3 install --user --upgrade lit tabulate + + # Get path of package location + base_path=$(python3 -m site --user-base) + export PATH="${base_path}/bin:$PATH" } \ No newline at end of file diff --git a/scripts/build/p-klee.inc b/scripts/build/p-klee.inc index 7a3d68e7..4137cac0 100644 --- a/scripts/build/p-klee.inc +++ b/scripts/build/p-klee.inc @@ -3,6 +3,7 @@ validate_build_config_klee() { } setup_build_variables_klee() { + source "${DIR}/common-functions" KLEE_SUFFIX="${LLVM_VERSION_SHORT}${SOLVER_SUFFIX}${SANITIZER_SUFFIX}" KLEE_BUILD_DIR="${BASE}/klee_build${KLEE_SUFFIX}" KLEE_SRC="$DIR/../../" diff --git a/scripts/build/p-libcxx-linux-ubuntu.inc b/scripts/build/p-libcxx-linux-ubuntu.inc index 46705c86..8fd8a056 100644 --- a/scripts/build/p-libcxx-linux-ubuntu.inc +++ b/scripts/build/p-libcxx-linux-ubuntu.inc @@ -1,5 +1,5 @@ -install_build_dependencies_libcxx() { - apt-get update -y +install_build_dependencies_libcxx() { + source "${DIR}/common-functions" # Add Kitware's certificate for CMake dependencies=( @@ -19,8 +19,10 @@ install_build_dependencies_libcxx() { codename="$(lsb_release --codename --short)" apt-add-repository "deb https://apt.kitware.com/ubuntu/ ${codename} main" + with_sudo apt-get update -y dependencies=( build-essential + ca-certificates git python3 python3-pip @@ -29,7 +31,9 @@ install_build_dependencies_libcxx() { file # Needed for wllvm ) - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" - pip3 install wllvm -} + pip3 install --user wllvm + base_path="$(python3 -m site --user-base)" + export PATH="$PATH:${base_path}/bin" +} \ No newline at end of file diff --git a/scripts/build/p-libcxx-osx.inc b/scripts/build/p-libcxx-osx.inc index c53ac37f..d112fff2 100644 --- a/scripts/build/p-libcxx-osx.inc +++ b/scripts/build/p-libcxx-osx.inc @@ -3,5 +3,7 @@ install_build_dependencies_libcxx() { set +e brew upgrade python # upgrade to Python 3 set -e - pip3 install wllvm + pip3 install --user wllvm + base_path="$(python3 -m site --user-base)" + export PATH="$PATH:${base_path}/bin" } \ No newline at end of file diff --git a/scripts/build/p-llvm-linux-ubuntu.inc b/scripts/build/p-llvm-linux-ubuntu.inc index 8a9d0fe9..1474d1da 100644 --- a/scripts/build/p-llvm-linux-ubuntu.inc +++ b/scripts/build/p-llvm-linux-ubuntu.inc @@ -40,7 +40,7 @@ install_build_dependencies_llvm() { fi #Install essential dependencies - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" } install_binary_artifact_llvm() { @@ -62,17 +62,18 @@ install_binary_artifact_llvm() { [[ "${requires_rtti}" -eq 0 ]] && return 1 # Enable/Disable optimized does not matter - + source "${DIR}/common-functions" + # Add certificate - apt update -y + with_sudo 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 - + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key| with_sudo apt-key add - local version="" [[ "${LLVM_VERSION_MAJOR}" -le 6 ]] && version="-${LLVM_VERSION}" @@ -94,7 +95,7 @@ install_binary_artifact_llvm() { ) #Install essential dependencies - apt -y --no-install-recommends install "${dependencies[@]}" || return 1 + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" || return 1 } # Check if the binary artifact is installed diff --git a/scripts/build/p-metasmt-linux-ubuntu.inc b/scripts/build/p-metasmt-linux-ubuntu.inc index 1e381b78..8bc03ceb 100644 --- a/scripts/build/p-metasmt-linux-ubuntu.inc +++ b/scripts/build/p-metasmt-linux-ubuntu.inc @@ -3,7 +3,8 @@ setup_build_variables_metasmt() { } install_build_dependencies_metasmt() { - apt update -y + source "${DIR}/common-functions" + with_sudo apt update -y dependencies=( # libgmp, gperf (required by yices2) @@ -27,5 +28,5 @@ install_build_dependencies_metasmt() { ) #Install essential dependencies - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" } \ No newline at end of file diff --git a/scripts/build/p-sqlite-linux-ubuntu.inc b/scripts/build/p-sqlite-linux-ubuntu.inc index 6f90c680..e0f317cb 100644 --- a/scripts/build/p-sqlite-linux-ubuntu.inc +++ b/scripts/build/p-sqlite-linux-ubuntu.inc @@ -1,5 +1,6 @@ install_build_dependencies_sqlite() { - apt update -y + source "${DIR}/common-functions" + with_sudo apt update -y dependencies=( build-essential @@ -8,16 +9,17 @@ install_build_dependencies_sqlite() { wget ) - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" } install_binary_artifact_sqlite() { [[ "${SANITIZER_SUFFIX}x" == "x" ]] || return 1 - apt update -y + source "${DIR}/common-functions" + with_sudo apt update -y dependencies=( libsqlite3-dev ) - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" } # Check if the binary artifact is installed diff --git a/scripts/build/p-stp-linux-ubuntu.inc b/scripts/build/p-stp-linux-ubuntu.inc index f4030023..612022ef 100644 --- a/scripts/build/p-stp-linux-ubuntu.inc +++ b/scripts/build/p-stp-linux-ubuntu.inc @@ -1,7 +1,7 @@ -#!/bin/bash # Build dependencies -install_build_dependencies_stp() { - apt update -y +install_build_dependencies_stp() { + source "${DIR}/common-functions" + with_sudo apt update -y dependencies=( build-essential @@ -15,5 +15,5 @@ install_build_dependencies_stp() { ) #Install essential dependencies - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" } \ No newline at end of file diff --git a/scripts/build/p-tcmalloc-linux-ubuntu.inc b/scripts/build/p-tcmalloc-linux-ubuntu.inc index 26bf2da9..1d5352de 100644 --- a/scripts/build/p-tcmalloc-linux-ubuntu.inc +++ b/scripts/build/p-tcmalloc-linux-ubuntu.inc @@ -1,5 +1,6 @@ install_build_dependencies_tcmalloc() { - apt update -y + source "${DIR}/common-functions" + with_sudo apt update -y dependencies=( build-essential @@ -9,5 +10,5 @@ install_build_dependencies_tcmalloc() { wget ) - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" } \ No newline at end of file diff --git a/scripts/build/p-uclibc-linux-ubuntu.inc b/scripts/build/p-uclibc-linux-ubuntu.inc index 36bdce58..e10304aa 100644 --- a/scripts/build/p-uclibc-linux-ubuntu.inc +++ b/scripts/build/p-uclibc-linux-ubuntu.inc @@ -1,7 +1,7 @@ -#!/bin/bash # Build dependencies install_build_dependencies_uclibc() { - apt update -y + source "${DIR}/common-functions" + with_sudo apt update -y dependencies=( build-essential @@ -13,5 +13,5 @@ install_build_dependencies_uclibc() { ) #Install essential dependencies - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" } \ No newline at end of file diff --git a/scripts/build/p-z3-linux-ubuntu.inc b/scripts/build/p-z3-linux-ubuntu.inc index 2a46ac46..41130232 100644 --- a/scripts/build/p-z3-linux-ubuntu.inc +++ b/scripts/build/p-z3-linux-ubuntu.inc @@ -1,6 +1,7 @@ # Build dependencies Z3 -install_build_dependencies_z3() { - apt update -y +install_build_dependencies_z3() { + source "${DIR}/common-functions" + with_sudo apt update -y dependencies=( build-essential @@ -11,5 +12,5 @@ install_build_dependencies_z3() { ) #Install essential dependencies - apt -y --no-install-recommends install "${dependencies[@]}" + with_sudo apt -y --no-install-recommends install "${dependencies[@]}" } \ No newline at end of file diff --git a/scripts/build/run-tests.sh b/scripts/build/run-tests.sh index 48337f40..76500da7 100755 --- a/scripts/build/run-tests.sh +++ b/scripts/build/run-tests.sh @@ -68,6 +68,8 @@ run_tests() { # If metaSMT is the only solver, then rerun lit tests with non-default metaSMT backends if [ "X${SOLVERS}" == "XmetaSMT" ]; then + base_path="$(python3 -m site --user-base)" + export PATH="$PATH:${base_path}/bin" available_metasmt_backends="btor stp z3 yices2 cvc4" for backend in $available_metasmt_backends; do if [ "X${METASMT_DEFAULT}" != "X$backend" ]; then -- cgit 1.4.1