forked from Mirror/pmbootstrap
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.
This commit is contained in:
parent
a7e2592f1a
commit
1ec55fc11a
1 changed files with 8 additions and 9 deletions
|
@ -13,7 +13,7 @@ import pmb.chroot
|
||||||
from pmb.core import Chroot
|
from pmb.core import Chroot
|
||||||
|
|
||||||
|
|
||||||
def init() -> None:
|
def init():
|
||||||
if not Path("/sys/module/loop").is_dir():
|
if not Path("/sys/module/loop").is_dir():
|
||||||
pmb.helpers.run.root(["modprobe", "loop"])
|
pmb.helpers.run.root(["modprobe", "loop"])
|
||||||
for loopdevice in Path("/dev/").glob("loop*"):
|
for loopdevice in Path("/dev/").glob("loop*"):
|
||||||
|
@ -22,7 +22,7 @@ def init() -> None:
|
||||||
pmb.helpers.mount.bind_file(loopdevice, Chroot.native() / loopdevice)
|
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.
|
: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
|
raise e
|
||||||
pass
|
pass
|
||||||
|
|
||||||
raise AssertionError("This should never be reached")
|
|
||||||
|
|
||||||
|
|
||||||
def device_by_back_file(back_file: Path) -> Path:
|
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}")
|
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.
|
: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])
|
pmb.chroot.root(["losetup", "-d", device])
|
||||||
|
|
||||||
|
|
||||||
def detach_all() -> None:
|
def detach_all():
|
||||||
"""
|
"""
|
||||||
Detach all loop devices used by pmbootstrap
|
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:
|
if not losetup_output:
|
||||||
return
|
return
|
||||||
losetup = json.loads(losetup_output)
|
losetup = json.loads(losetup_output)
|
||||||
work = get_context().config.work
|
work = get_context().config.work
|
||||||
for loopdevice in losetup["loopdevices"]:
|
for loopdevice in losetup["loopdevices"]:
|
||||||
|
print(loopdevice["back-file"])
|
||||||
if Path(loopdevice["back-file"]).is_relative_to(work):
|
if Path(loopdevice["back-file"]).is_relative_to(work):
|
||||||
pmb.chroot.root(["kpartx", "-d", loopdevice["name"]], check=False)
|
pmb.helpers.run.root(["kpartx", "-d", loopdevice["name"]], check=False)
|
||||||
pmb.chroot.root(["losetup", "-d", loopdevice["name"]])
|
pmb.helpers.run.root(["losetup", "-d", loopdevice["name"]])
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue