diff options
author | Geir Storli <geirstorli@yahoo.no> | 2018-09-17 13:42:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-17 13:42:12 +0200 |
commit | 9e2921379530ce31c343898f47ab1432eecee33f (patch) | |
tree | 359003246c36fb41e5a3bcded9be5134bb2cefe1 | |
parent | a940b388669b3ad3cc364c6f6ce638919ee76676 (diff) | |
parent | 483f01297240b5cc3f28eb103340d9fb879f15b4 (diff) |
Merge pull request #6968 from vespa-engine/geirst/add-option-to-setup-unprivileged-compilation-of-vespa
Add option to setup unprivileged compilation of Vespa.
-rwxr-xr-x | bootstrap-cmake.sh | 38 | ||||
-rwxr-xr-x | bootstrap-cpp.sh | 25 |
2 files changed, 51 insertions, 12 deletions
diff --git a/bootstrap-cmake.sh b/bootstrap-cmake.sh index 0c2d9553213..b484d41e8b6 100755 --- a/bootstrap-cmake.sh +++ b/bootstrap-cmake.sh @@ -2,13 +2,28 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. usage() { - echo "Usage: $0 <source-dir> [<extra-cmake-args>]" >&2 + echo "Usage: $0 [-u] <source-dir> [<extra-cmake-args>]" >&2 } -if [[ $# -eq 1 && ( "$1" = "-h" || "$1" = "--help" )]]; then - usage - exit 0 -elif [[ $# -eq 1 ]]; then +UNPRIVILEGED=false +while getopts "uh" opt; do + case "${opt}" in + u) + UNPRIVILEGED=true + ;; + h) + usage + exit 0 + ;; + *) + usage + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +if [[ $# -eq 1 ]]; then SOURCE_DIR=$1 EXTRA_CMAKE_ARGS="" elif [ $# -eq 2 ]; then @@ -24,12 +39,21 @@ if [ -z "$VESPA_LLVM_VERSION" ]; then VESPA_LLVM_VERSION=5.0 fi +if $UNPRIVILEGED; then + VESPA_INSTALL_PREFIX="$HOME/vespa" + UNPRIVILEGED_ARGS="-DVESPA_USER=$(id -un) -DVESPA_UNPRIVILEGED=yes" +else + VESPA_INSTALL_PREFIX="/opt/vespa" + UNPRIVILEGED_ARGS="" +fi + cmake3 \ - -DCMAKE_INSTALL_PREFIX=/opt/vespa \ + -DCMAKE_INSTALL_PREFIX=${VESPA_INSTALL_PREFIX} \ -DJAVA_HOME=/usr/lib/jvm/java-openjdk \ -DEXTRA_LINK_DIRECTORY="/opt/vespa-gtest/lib;/opt/vespa-boost/lib;/opt/vespa-cppunit/lib;/usr/lib64/llvm$VESPA_LLVM_VERSION/lib" \ -DEXTRA_INCLUDE_DIRECTORY="/opt/vespa-gtest/include;/opt/vespa-boost/include;/opt/vespa-cppunit/include;/usr/include/llvm$VESPA_LLVM_VERSION" \ - -DCMAKE_INSTALL_RPATH="/opt/vespa/lib64;/opt/vespa-gtest/lib;/opt/vespa-boost/lib;/opt/vespa-cppunit/lib;/usr/lib/jvm/java-1.8.0/jre/lib/amd64/server;/usr/lib64/llvm$VESPA_LLVM_VERSION/lib" \ + -DCMAKE_INSTALL_RPATH="${VESPA_INSTALL_PREFIX}/lib64;/opt/vespa-gtest/lib;/opt/vespa-boost/lib;/opt/vespa-cppunit/lib;/usr/lib/jvm/java-1.8.0/jre/lib/amd64/server;/usr/lib64/llvm$VESPA_LLVM_VERSION/lib" \ + ${UNPRIVILEGED_ARGS} \ ${EXTRA_CMAKE_ARGS} \ -DVESPA_LLVM_VERSION=$VESPA_LLVM_VERSION \ "${SOURCE_DIR}" diff --git a/bootstrap-cpp.sh b/bootstrap-cpp.sh index e6b4c816065..bc4c6466596 100755 --- a/bootstrap-cpp.sh +++ b/bootstrap-cpp.sh @@ -2,16 +2,31 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. usage() { - echo "Usage: $0 <source-dir> <build-dir>" >&2 + echo "Usage: $0 [-u] <source-dir> <build-dir>" >&2 } +UNPRIVILEGED="" +while getopts "uh" opt; do + case "${opt}" in + u) + UNPRIVILEGED="-u" + ;; + h) + usage + exit 0 + ;; + *) + usage + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + # Parse arguments if [ $# -eq 2 ]; then SOURCE_DIR="$1" BUILD_DIR="$2" -elif [[ $# -eq 1 && ( "$1" = "-h" || "$1" = "--help" )]]; then - usage - exit 0 else echo "Wrong number of arguments: expected 2, was $#" >&2 usage @@ -37,4 +52,4 @@ source /opt/rh/devtoolset-7/enable || true cd "${SOURCE_DIR}" bash ./bootstrap.sh full cd "${BUILD_DIR}" -bash ${SOURCE_DIR}/bootstrap-cmake.sh "${SOURCE_DIR}" +bash ${SOURCE_DIR}/bootstrap-cmake.sh ${UNPRIVILEGED} "${SOURCE_DIR}" |