summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@oath.com>2018-09-14 14:53:10 +0000
committerGeir Storli <geirst@oath.com>2018-09-14 14:55:44 +0000
commit67ecb882ec22420dab988f7a58e55aece081dbd3 (patch)
treeffb83ac12752f2e694cedaafe4a25eed4a7c588f
parent3f98f9c03a2f15df9a80a09959b15a5bd03436db (diff)
Add option to setup unprivileged compilation of Vespa.
-rwxr-xr-xbootstrap-cmake.sh39
-rwxr-xr-xbootstrap-cpp.sh25
2 files changed, 54 insertions, 10 deletions
diff --git a/bootstrap-cmake.sh b/bootstrap-cmake.sh
index 0c2d9553213..fd2b3322f1c 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,6 +39,19 @@ if [ -z "$VESPA_LLVM_VERSION" ]; then
VESPA_LLVM_VERSION=5.0
fi
+if $UNPRIVILEGED; then
+cmake3 \
+ -DCMAKE_INSTALL_PREFIX=$HOME/vespa \
+ -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="$HOME/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" \
+ -DVESPA_USER=$(id -un) \
+ -DVESPA_UNPRIVILEGED=yes \
+ ${EXTRA_CMAKE_ARGS} \
+ -DVESPA_LLVM_VERSION=$VESPA_LLVM_VERSION \
+ "${SOURCE_DIR}"
+else
cmake3 \
-DCMAKE_INSTALL_PREFIX=/opt/vespa \
-DJAVA_HOME=/usr/lib/jvm/java-openjdk \
@@ -33,3 +61,4 @@ cmake3 \
${EXTRA_CMAKE_ARGS} \
-DVESPA_LLVM_VERSION=$VESPA_LLVM_VERSION \
"${SOURCE_DIR}"
+fi
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}"