diff options
author | Tom Overlund <tomov@dilacero.org> | 2025-03-28 10:58:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-28 14:58:25 +0000 |
commit | cd2ed0c275c2a70f23c69005ba3d1ccae781f5e1 (patch) | |
tree | 7d29cb71a022415f198f17892e71a39b58896163 /python | |
parent | 482d28e4ff5b3114f9504859f3d74957eab33816 (diff) | |
download | servo-cd2ed0c275c2a70f23c69005ba3d1ccae781f5e1.tar.gz servo-cd2ed0c275c2a70f23c69005ba3d1ccae781f5e1.zip |
Check for existence of 'sudo' on Linux in ./mach bootstrap (#35739)
* Check for existence of sudo command in ./mach bootstrap on Linux (#35736)
Signed-off-by: Tom Overlund <tomov@dilacero.org>
* Remove extraneous semicolon from previous commit (test-tidy fix).
Signed-off-by: Tom Overlund <tomov@dilacero.org>
---------
Signed-off-by: Tom Overlund <tomov@dilacero.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/servo/platform/linux.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/python/servo/platform/linux.py b/python/servo/platform/linux.py index 411a8fc1578..8ff35b25bdf 100644 --- a/python/servo/platform/linux.py +++ b/python/servo/platform/linux.py @@ -10,6 +10,7 @@ import distro import os import subprocess +import shutil from typing import Optional, Tuple from .base import Base @@ -204,6 +205,12 @@ class Linux(Base): if not install: return False + def check_sudo(): + if os.geteuid() != 0: + if shutil.which('sudo') is None: + return False + return True + def run_as_root(command, force=False): if os.geteuid() != 0: command.insert(0, 'sudo') @@ -212,6 +219,13 @@ class Linux(Base): return subprocess.call(command) print("Installing missing dependencies...") + if not check_sudo(): + print("'sudo' command not found." + " You may be able to install dependencies manually." + " See https://github.com/servo/servo/wiki/Building.") + input("Press Enter to continue...") + return False + if run_as_root(command + pkgs, force) != 0: raise EnvironmentError("Installation of dependencies failed.") return True |