chroot: cleanups, initialize(): unmount everything except / before create_rootfs()
This commit is contained in:
parent
686c94c3ad
commit
3874b4e626
2 changed files with 5 additions and 6 deletions
|
@ -8,7 +8,6 @@ from wrapper import enforce_wrap
|
|||
from .abstract import Chroot
|
||||
from .base import get_base_chroot
|
||||
from .build import get_build_chroot, BuildChroot
|
||||
#from .device import get_device_chroot, DeviceChroot
|
||||
from .helpers import get_chroot_path
|
||||
|
||||
# export Chroot class
|
||||
|
@ -59,4 +58,3 @@ def cmd_chroot(type: str = 'build', arch: str = None, enable_crossdirect=True):
|
|||
chroot.activate()
|
||||
logging.debug(f'Starting shell in {chroot.name}:')
|
||||
chroot.run_cmd('bash', attach_tty=True)
|
||||
chroot.run_cmd('bash', attach_tty=True)
|
||||
|
|
|
@ -116,11 +116,12 @@ class Chroot(AbstractChroot):
|
|||
if self.initialized and not reset:
|
||||
# chroot must have been initialized already!
|
||||
if fail_if_initialized:
|
||||
raise Exception(f"Chroot {self.name} is already initialized, this seems like a bug")
|
||||
raise Exception(f"Chroot {self.name} ({self.uuid}) is already initialized, this seems like a bug")
|
||||
logging.debug(f"Base chroot {self.name} ({self.uuid}) already initialized")
|
||||
return
|
||||
|
||||
active_previously = self.active
|
||||
self.deactivate_core()
|
||||
self.deactivate(fail_if_inactive=False, ignore_rootfs=True)
|
||||
|
||||
self.create_rootfs(reset, pacman_conf_target, active_previously)
|
||||
|
||||
|
@ -203,11 +204,11 @@ class Chroot(AbstractChroot):
|
|||
# additional mounts like crossdirect are intentionally left intact. Is such a chroot still `active` afterwards?
|
||||
self.active = False
|
||||
|
||||
def deactivate(self, fail_if_inactive: bool = False):
|
||||
def deactivate(self, fail_if_inactive: bool = False, ignore_rootfs: bool = False):
|
||||
if not self.active:
|
||||
if fail_if_inactive:
|
||||
raise Exception(f"Chroot {self.name} not activated, can't deactivate!")
|
||||
self.umount_many(self.active_mounts)
|
||||
self.umount_many([mnt for mnt in self.active_mounts if mnt != '/' or not ignore_rootfs])
|
||||
self.active = False
|
||||
|
||||
def run_cmd(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue