Skip to content
Snippets Groups Projects
Verified Commit 1ec55fc1 authored by Clayton Craft's avatar Clayton Craft :speech_balloon:
Browse files

Revert "pmb.install.losetup: Run kpartx, losetup in chroot (MR 2430)"

This series breaks pmbootstrap, and that's not good[1]. A bug was filed
about this (#2465), and there have been multiple attempts to fix it (!
2435 and !2436). It kinda seems like we don't have time to fix/test this
for a while longer, which is fine, but given the impact this bug has I
think we should be revert this series until this issue is solved/tested.

1. pmb is broken in some specific cases, which means some workflows are
broken. One example is that this breaks the pmaports CI, so no work can
be done in pmaports.
parent a7e2592f
No related branches found
No related tags found
1 merge request!2437Revert "pmb.install.losetup: Run kpartx, losetup in chroot (MR 2430)"
Pipeline #208384 passed
......@@ -13,7 +13,7 @@ import pmb.chroot
from pmb.core import Chroot
def init() -> None:
def init():
if not Path("/sys/module/loop").is_dir():
pmb.helpers.run.root(["modprobe", "loop"])
for loopdevice in Path("/dev/").glob("loop*"):
......@@ -22,7 +22,7 @@ def init() -> None:
pmb.helpers.mount.bind_file(loopdevice, Chroot.native() / loopdevice)
def mount(img_path: Path, _sector_size: int | None = None) -> Path:
def mount(img_path: Path, _sector_size: int | None = None):
"""
:param img_path: Path to the img file inside native chroot.
"""
......@@ -56,8 +56,6 @@ def mount(img_path: Path, _sector_size: int | None = None) -> Path:
raise e
pass
raise AssertionError("This should never be reached")
def device_by_back_file(back_file: Path) -> Path:
"""
......@@ -77,7 +75,7 @@ def device_by_back_file(back_file: Path) -> Path:
raise RuntimeError(f"Failed to find loop device for {back_file}")
def umount(img_path: Path) -> None:
def umount(img_path: Path):
"""
:param img_path: Path to the img file inside native chroot.
"""
......@@ -90,17 +88,18 @@ def umount(img_path: Path) -> None:
pmb.chroot.root(["losetup", "-d", device])
def detach_all() -> None:
def detach_all():
"""
Detach all loop devices used by pmbootstrap
"""
losetup_output = pmb.chroot.root(["losetup", "--json", "--list"], output_return=True)
losetup_output = pmb.helpers.run.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"]:
print(loopdevice["back-file"])
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"]])
pmb.helpers.run.root(["kpartx", "-d", loopdevice["name"]], check=False)
pmb.helpers.run.root(["losetup", "-d", loopdevice["name"]])
return
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment