Refactor chroot.py into Chroot class

This commit is contained in:
InsanePrawn 2021-10-19 06:40:30 +02:00
parent 8d1061004a
commit c5183bd0bf
2 changed files with 382 additions and 227 deletions

View file

@ -23,7 +23,7 @@ def umount(dest):
)
def mount(src: str, dest: str, options=['bind'], fs_type=None) -> subprocess.CompletedProcess:
def mount(src: str, dest: str, options=['bind'], fs_type=None, register_unmount=True) -> subprocess.CompletedProcess:
opts = []
for opt in options:
opts += ['-o', opt]
@ -38,7 +38,7 @@ def mount(src: str, dest: str, options=['bind'], fs_type=None) -> subprocess.Com
],
capture_output=False,
)
if result.returncode == 0:
if result.returncode == 0 and register_unmount:
atexit.register(umount, dest)
return result