Commit 2de47e9d authored by Frédéric Leroy's avatar Frédéric Leroy Committed by herlesupreeth

fix(build_helper): use SUDO when we are a regular user

root user is not tied to a container.
Let the possibility to build when we run as a regular user in a
container.
parent 9a06ceba
...@@ -40,7 +40,15 @@ esac ...@@ -40,7 +40,15 @@ esac
KERNEL_VERSION=$(uname -r | cut -d '.' -f1) KERNEL_VERSION=$(uname -r | cut -d '.' -f1)
KERNEL_MAJOR=$(uname -r | cut -d '.' -f2) KERNEL_MAJOR=$(uname -r | cut -d '.' -f2)
SUDO='sudo -E' #check if we run inside a container
IS_CONTAINER=`egrep -c "docker|podman|kubepods" /proc/self/cgroup || true`
#sudo is not needed when we are root
if [ "$UID" = 0 ]
then
SUDO=''
else
SUDO='sudo -S -E'
fi
############################### ###############################
## echo and family ## echo and family
...@@ -216,10 +224,22 @@ install_protobuf_from_source(){ ...@@ -216,10 +224,22 @@ install_protobuf_from_source(){
#wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz #wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
#tar -xzvf protobuf-2.6.1.tar.gz --owner $USER --group $USER --no-same-owner #tar -xzvf protobuf-2.6.1.tar.gz --owner $USER --group $USER --no-same-owner
#cd protobuf-2.6.1/ #cd protobuf-2.6.1/
rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0
wget https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz if [ $IS_CONTAINER -eq 0 ]
tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $USER --group $(groups | cut -d" " -f1) --no-same-owner then
cd protobuf-3.3.0/ rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0
wget --tries=3 --retry-connrefused https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz
tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $USER --group $(groups | cut -d" " -f1) --no-same-owner
cd protobuf-3.3.0/
else
export LD_LIBRARY_PATH=/usr/local/lib #protoc needs to know where toclook for shared libs
rm -rf /tmp/protobuf
git clone --depth=1 --branch=v3.3.0 https://github.com/protocolbuffers/protobuf.git /tmp/protobuf
cd /tmp/protobuf
git submodule update --init --recursive
./autogen.sh
fi
./configure ./configure
echo "Compiling protobuf" echo "Compiling protobuf"
make -j`nproc` make -j`nproc`
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment