util/chroot: use subprocess.run() for all commands

For consistency, use subprocess.run() with check=True for the calls that
were previously using subprocess.check_call().

Update the affected tests to match.
This commit is contained in:
Achilleas Koutsou 2024-08-27 12:55:07 +02:00 committed by Brian C. Lane
parent 73464ff119
commit 1093b5eeb2
3 changed files with 24 additions and 26 deletions

View file

@ -21,18 +21,17 @@ class Chroot:
print(f"Making missing chroot directory: {d}")
os.makedirs(self.root + d)
subprocess.check_call(["/usr/bin/mount",
"-t", "proc",
"-o", "nosuid,noexec,nodev",
"proc", f"{self.root}/proc"])
subprocess.check_call(["/usr/bin/mount",
"-t", "devtmpfs",
"-o", "mode=0755,noexec,nosuid,strictatime",
"devtmpfs", f"{self.root}/dev"])
subprocess.check_call(["/usr/bin/mount",
"-t", "sysfs",
"-o", "nosuid,noexec,nodev",
"sysfs", f"{self.root}/sys"])
subprocess.run(["/usr/bin/mount", "-t", "proc", "-o", "nosuid,noexec,nodev",
"proc", f"{self.root}/proc"],
check=True)
subprocess.run(["/usr/bin/mount", "-t", "devtmpfs", "-o", "mode=0755,noexec,nosuid,strictatime",
"devtmpfs", f"{self.root}/dev"],
check=True)
subprocess.run(["/usr/bin/mount", "-t", "sysfs", "-o", "nosuid,noexec,nodev",
"sysfs", f"{self.root}/sys"],
check=True)
return self