Skip to content

Commit f7f1a1b

Browse files
Merge pull request #355 from bwest2397/fix-sudo-when-building-in-docker-container
When running as root, skip sudo in setup script
2 parents 08c1d7d + 78fc040 commit f7f1a1b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

setup.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@ CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/
1212

1313
echo "Installing dependencies"
1414
if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
15-
sudo apt-get update --yes
16-
sudo apt-get install --yes cmake graphviz llvm clang pkg-config m4 \
15+
SUDO=''
16+
if command -v sudo >/dev/null; then
17+
# sudo is present on the system, so use it
18+
SUDO='sudo'
19+
fi
20+
$SUDO apt-get update --yes
21+
$SUDO apt-get install --yes cmake graphviz llvm clang pkg-config m4 \
1722
wget curl python3-distutils python3-dev
1823
# Install Doxygen
1924
# the newest version in Ubuntu 20.04 repository is 1.8.17, but we need Doxygen 1.9 series
2025
wget -c -q https://www.doxygen.nl/files/doxygen-1.9.7.linux.bin.tar.gz
2126
tar xf doxygen-1.9.7.linux.bin.tar.gz
22-
cd doxygen-1.9.7 && sudo make install && cd -
27+
cd doxygen-1.9.7 && $SUDO make install && cd -
2328
rm -rf doxygen-1.9.7 doxygen-1.9.7.linux.bin.tar.gz
2429
elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
2530
brew update || true # allow failure

0 commit comments

Comments
 (0)