mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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>
This commit is contained in:
parent
482d28e4ff
commit
cd2ed0c275
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue