Commit cad82409 authored by Frédéric Leroy's avatar Frédéric Leroy

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 68619cae
...@@ -42,12 +42,12 @@ KERNEL_MAJOR=$(uname -r | cut -d '.' -f2) ...@@ -42,12 +42,12 @@ KERNEL_MAJOR=$(uname -r | cut -d '.' -f2)
#check if we run inside a container #check if we run inside a container
IS_CONTAINER=`egrep -c "docker|podman|kubepods" /proc/self/cgroup || true` IS_CONTAINER=`egrep -c "docker|podman|kubepods" /proc/self/cgroup || true`
#sudo is not needed inside a container #sudo is not needed when we are root
if [ $IS_CONTAINER -eq 0 ] if [ "$UID" = 0 ]
then then
SUDO='sudo -S -E'
else
SUDO='' SUDO=''
else
SUDO='sudo -S -E'
fi fi
############################### ###############################
...@@ -258,11 +258,6 @@ install_protobuf_from_source(){ ...@@ -258,11 +258,6 @@ install_protobuf_from_source(){
wget --tries=3 --retry-connrefused https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz 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 tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $USER --group $(groups | cut -d" " -f1) --no-same-owner
cd protobuf-3.3.0/ cd protobuf-3.3.0/
./configure
echo "Compiling protobuf"
make -j`nproc`
$SUDO make install
$SUDO ldconfig
else else
export LD_LIBRARY_PATH=/usr/local/lib #protoc needs to know where toclook for shared libs export LD_LIBRARY_PATH=/usr/local/lib #protoc needs to know where toclook for shared libs
rm -rf /tmp/protobuf rm -rf /tmp/protobuf
...@@ -270,11 +265,12 @@ install_protobuf_from_source(){ ...@@ -270,11 +265,12 @@ install_protobuf_from_source(){
cd /tmp/protobuf cd /tmp/protobuf
git submodule update --init --recursive git submodule update --init --recursive
./autogen.sh ./autogen.sh
fi
./configure ./configure
echo "Compiling protobuf"
make -j`nproc` make -j`nproc`
make install $SUDO make install
ldconfig $SUDO ldconfig
fi
) >& $protobuf_install_log ) >& $protobuf_install_log
} }
......
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