From 543f5ce6d2523ba950017cfcd2561280c838e574 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 30 Dec 2022 18:19:55 +0100 Subject: [PATCH] Don't use sudo in pre-build script when running as root Just run apt-get directly in this case. --- build/tools/before_install.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build/tools/before_install.sh b/build/tools/before_install.sh index 65908a89bd..bc185efd45 100755 --- a/build/tools/before_install.sh +++ b/build/tools/before_install.sh @@ -9,10 +9,18 @@ set -e -SUDO=sudo - case $(uname -s) in Linux) + # Use sudo if it's available or assume root otherwise. + if command -v sudo > /dev/null; then + SUDO=sudo + else + if [ `id -u` -ne 0 ]; then + echo "Please install sudo or run as root (and not user `id -u`)." >& 2 + exit 1 + fi + fi + # Debian/Ubuntu if [ -f /etc/apt/sources.list ]; then # Show information about the repositories and priorities used.