Skip to content
Snippets Groups Projects
Verified Commit 7fcfd391 authored by Newbyte's avatar Newbyte :snowflake:
Browse files

pmb.install.losetup: Avoid using --json parameter for losetup in detach_all()


The default losetup implementation in Alpine and thus postmarketOS is
BusyBox losetup. It doesn't support the --json parameter, and so unless
the util-linux variant gets installed this code path won't work.
Installing additional packages during shutdown doesn't seem like a great
approach to me as it makes this code path more fragile and completely
breaks it if e.g. your Internet is out, so just bring back the old code
from shutdown.py in pmbootstrap 2.3.1 to do this job for us.

Co-developed-by: default avatarOliver Smith <ollieparanoid@postmarketos.org>

Fixes 0975d064

Closes #2465
Supersedes: !2435
parent a7e2592f
No related branches found
No related tags found
1 merge request!2436Draft: pmb.install.losetup: Avoid using --json parameter for losetup in detach_all()
Pipeline #208378 failed
......@@ -94,13 +94,10 @@ def detach_all() -> None:
"""
Detach all loop devices used by pmbootstrap
"""
losetup_output = pmb.chroot.root(["losetup", "--json", "--list"], output_return=True)
if not losetup_output:
return
losetup = json.loads(losetup_output)
work = get_context().config.work
for loopdevice in losetup["loopdevices"]:
if Path(loopdevice["back-file"]).is_relative_to(work):
pmb.chroot.root(["kpartx", "-d", loopdevice["name"]], check=False)
pmb.chroot.root(["losetup", "-d", loopdevice["name"]])
chroot = Chroot.native()
if pmb.helpers.mount.ismount(chroot / "/dev/loop-control"):
pattern = chroot / "/home/pmos/rootfs/*.img"
for path_outside in glob.glob(pattern):
path = path_outside[len(chroot):]
pmb.install.losetup.umount(args, path, auto_init=False)
return
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment