util/chroot: call unmount with check=False

If one of the chroot mounts fails to unmount, keep iterating so that we
don't stop and continue to unmount the rest.
Print an error message with the failed mounts, but don't fail the build.

Since failing to unmount doesn't fail the exiting of the context, and
the context itself doesn't know what will be running in the chroot,
do a lazy unmount.
This commit is contained in:
Achilleas Koutsou 2024-08-21 15:04:38 +02:00 committed by Brian C. Lane
parent d893e81004
commit 149e3ead96

View file

@ -37,5 +37,9 @@ class ChrootProcDevSys:
return self
def __exit__(self, exc_type, exc_value, tracebk):
failed_umounts = []
for d in ["/proc", "/dev", "/sys"]:
subprocess.check_call(["/usr/bin/umount", self.root + d])
if subprocess.run(["/usr/bin/umount", "--lazy", self.root + d], check=False).returncode != 0:
failed_umounts.append(d)
if failed_umounts:
print(f"Error unmounting paths from chroot: {failed_umounts}")