fix(install): use sudo for apt-get when not running as root

GitHub Actions runners are not root, so apt-get needs sudo.
Detect if running as non-root and use sudo when available.
This commit is contained in:
Vito Castellano 2025-12-29 23:14:51 +01:00
commit 75ad954791
No known key found for this signature in database
GPG key ID: E13085DB38BC5819

View file

@ -88,16 +88,22 @@ command_exists() {
install_linux_deps() { install_linux_deps() {
info "Installing required dependencies..." info "Installing required dependencies..."
# Use sudo if available and not root
SUDO=""
if [ "$(id -u)" -ne 0 ] && command_exists sudo; then
SUDO="sudo"
fi
if command_exists apt-get; then if command_exists apt-get; then
# Debian/Ubuntu # Debian/Ubuntu
apt-get update -qq $SUDO apt-get update -qq
apt-get install -y -qq build-essential procps curl file git > /dev/null $SUDO apt-get install -y -qq build-essential procps curl file git > /dev/null
elif command_exists dnf; then elif command_exists dnf; then
# Fedora/RHEL # Fedora/RHEL
dnf install -y -q procps-ng curl file git gcc make > /dev/null $SUDO dnf install -y -q procps-ng curl file git gcc make > /dev/null
elif command_exists pacman; then elif command_exists pacman; then
# Arch # Arch
pacman -Sy --noconfirm --quiet base-devel procps-ng curl file git > /dev/null $SUDO pacman -Sy --noconfirm --quiet base-devel procps-ng curl file git > /dev/null
else else
warn "Could not detect package manager. Please install: git, curl, build-essential" warn "Could not detect package manager. Please install: git, curl, build-essential"
fi fi