1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-13 03:19:47 +03:00

pmbootstrap chroot: fix --image bugs (MR 2556)

- Properly run commands at host to mount rootfs
- Always refuse to zap chroot_image, since it is never added to workdir.cfg

Co-authored-by: Newbyte <newbyte@postmarketos.org>
This commit is contained in:
Anri Dellal 2025-02-20 13:16:16 +03:00 committed by Oliver Smith
parent d90a037fd6
commit f85899ef3d
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 8 additions and 4 deletions

View file

@ -31,11 +31,12 @@ def mount_chroot_image(chroot: Chroot) -> None:
)
pmb.helpers.mount.bind_file(loopdev, chroot_native / "dev/install")
# Set up device mapper bits
pmb.chroot.root(["kpartx", "-u", "/dev/install"], chroot_native)
pmb.helpers.run.root(["kpartx", "-u", loopdev])
chroot.path.mkdir(exist_ok=True)
loopdev_basename = os.path.basename(loopdev)
# # The name of the IMAGE chroot is the path to the rootfs image
pmb.helpers.run.root(["mount", "/dev/mapper/install2", chroot.path])
pmb.helpers.run.root(["mount", "/dev/mapper/install1", chroot.path / "boot"])
pmb.helpers.run.root(["mount", f"/dev/mapper/{loopdev_basename}p2", chroot.path])
pmb.helpers.run.root(["mount", f"/dev/mapper/{loopdev_basename}p1", chroot.path / "boot"])
pmb.config.workdir.chroot_save_init(chroot)

View file

@ -12,7 +12,7 @@ from typing import overload
import pmb.config
import pmb.config.pmaports
from pmb.core import Chroot
from pmb.core import Chroot, ChrootType
from pmb.core.context import get_context
from pmb.helpers import logging
@ -86,6 +86,9 @@ def chroot_check_channel(chroot: Chroot) -> bool:
"""Check the chroot channel against the current channel. Returns
True if the chroot should be zapped (both that it needs zapping and
the user has auto_zap_misconfigured_chroots enabled), False otherwise."""
if chroot.type == ChrootType.IMAGE:
return False
config = get_context().config
path = config.work / "workdir.cfg"
msg_again = (