pmb.chroot.shutdown: losetup with auto_init=False (MR 1912)

Do not go through the pmb.chroot.init() code path when running
pmb.install.losetup.umount() inside pmb.chroot.shutdown(). This is not
necessary, as pmb.install.losetup.umount() only gets called if the
chroot is already initialized and /dev/loop-control is mounted inside
the chroot.

Not going through this code path is important for the upcoming workdir
migration patch. Without this fix, it will fail with the following if
running "pmbootstrap install" before the work migration:

ERROR: Could not figure out on which release channel the 'native' chroot is
This commit is contained in:
Daniele Debernardi 2020-05-09 00:45:39 +02:00 committed by Oliver Smith
parent 5a256f66de
commit d3dc3b2c98
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
2 changed files with 7 additions and 7 deletions

View File

@ -65,7 +65,7 @@ def shutdown(args, only_install_related=False):
pattern = chroot + "/home/pmos/rootfs/*.img"
for path_outside in glob.glob(pattern):
path = path_outside[len(chroot):]
pmb.install.losetup.umount(args, path)
pmb.install.losetup.umount(args, path, auto_init=False)
# Umount device rootfs chroot
chroot_rootfs = args.work + "/chroot_rootfs_" + args.device

View File

@ -50,14 +50,14 @@ def mount(args, img_path):
raise RuntimeError("Failed to mount loop device: " + img_path)
def device_by_back_file(args, back_file):
def device_by_back_file(args, back_file, auto_init=True):
"""
Get the /dev/loopX device, that points to a specific image file.
"""
# Get list from losetup
losetup_output = pmb.chroot.root(args, ["losetup", "--json",
"--list"], output_return=True)
losetup_output = pmb.chroot.root(args, ["losetup", "--json", "--list"],
output_return=True, auto_init=auto_init)
if not losetup_output:
return None
@ -69,12 +69,12 @@ def device_by_back_file(args, back_file):
return None
def umount(args, img_path):
def umount(args, img_path, auto_init=True):
"""
:param img_path: Path to the img file inside native chroot.
"""
device = device_by_back_file(args, img_path)
device = device_by_back_file(args, img_path, auto_init)
if not device:
return
logging.debug("(native) umount " + device)
pmb.chroot.root(args, ["losetup", "-d", device])
pmb.chroot.root(args, ["losetup", "-d", device], auto_init=auto_init)