forked from Mirror/pmbootstrap
chroot: shutdown: simplify (MR 2252)
Remove some of the duplicated parts, make sure we actually shut down loop devices. Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
c061ef8123
commit
c97ea203a4
1 changed files with 20 additions and 24 deletions
|
@ -70,16 +70,7 @@ def shutdown(only_install_related=False):
|
||||||
shutdown_cryptsetup_device("pm_crypt")
|
shutdown_cryptsetup_device("pm_crypt")
|
||||||
|
|
||||||
# Umount all losetup mounted images
|
# Umount all losetup mounted images
|
||||||
if pmb.helpers.mount.ismount(chroot / "dev/loop-control"):
|
pmb.install.losetup.detach_all()
|
||||||
for path_outside in (chroot / "/home/pmos/rootfs").glob("*.img"):
|
|
||||||
path = path_outside.relative_to(chroot.path)
|
|
||||||
pmb.install.losetup.umount(path)
|
|
||||||
|
|
||||||
# Umount device rootfs and installer chroots
|
|
||||||
for chroot_type in [ChrootType.ROOTFS, ChrootType.INSTALLER]:
|
|
||||||
chroot = Chroot(chroot_type, get_context().config.device)
|
|
||||||
if chroot.path.exists():
|
|
||||||
pmb.helpers.mount.umount_all(chroot.path)
|
|
||||||
|
|
||||||
# Remove "in-pmbootstrap" marker from all chroots. This marker indicates
|
# Remove "in-pmbootstrap" marker from all chroots. This marker indicates
|
||||||
# that pmbootstrap has set up all mount points etc. to run programs inside
|
# that pmbootstrap has set up all mount points etc. to run programs inside
|
||||||
|
@ -89,18 +80,23 @@ def shutdown(only_install_related=False):
|
||||||
for marker in get_context().config.work.glob("chroot_*/in-pmbootstrap"):
|
for marker in get_context().config.work.glob("chroot_*/in-pmbootstrap"):
|
||||||
pmb.helpers.run.root(["rm", marker])
|
pmb.helpers.run.root(["rm", marker])
|
||||||
|
|
||||||
if not only_install_related:
|
# Umount device rootfs and installer chroots
|
||||||
for path in Chroot.glob():
|
if only_install_related:
|
||||||
if path.exists():
|
for chroot_type in [ChrootType.ROOTFS, ChrootType.INSTALLER]:
|
||||||
pmb.helpers.mount.umount_all(path)
|
chroot = Chroot(chroot_type, get_context().config.device)
|
||||||
# Umount all folders inside work dir
|
if chroot.path.exists():
|
||||||
# The folders are explicitly iterated over, so folders symlinked inside
|
pmb.helpers.mount.umount_all(chroot.path)
|
||||||
# work dir get umounted as well (used in test_pkgrel_bump.py, #1595)
|
return
|
||||||
for path in get_context().config.work.glob("*"):
|
|
||||||
pmb.helpers.mount.umount_all(path)
|
|
||||||
|
|
||||||
# Clean up the rest
|
# Umount all folders inside work dir
|
||||||
for arch in Arch.supported():
|
# The folders are explicitly iterated over, so folders symlinked inside
|
||||||
if arch.cpu_emulation_required():
|
# work dir get umounted as well (used in test_pkgrel_bump.py, #1595)
|
||||||
pmb.chroot.binfmt.unregister(arch)
|
for path in get_context().config.work.glob("*"):
|
||||||
logging.debug("Shutdown complete")
|
pmb.helpers.mount.umount_all(path)
|
||||||
|
|
||||||
|
# Clean up the rest
|
||||||
|
for arch in Arch.supported():
|
||||||
|
if arch.cpu_emulation_required():
|
||||||
|
pmb.chroot.binfmt.unregister(arch)
|
||||||
|
|
||||||
|
logging.debug("Shutdown complete")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue