From f85899ef3dd30342db591b7cf7c746fb791e8503 Mon Sep 17 00:00:00 2001 From: Anri Dellal Date: Thu, 20 Feb 2025 13:16:16 +0300 Subject: [PATCH] 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 --- pmb/chroot/mount.py | 7 ++++--- pmb/config/workdir.py | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pmb/chroot/mount.py b/pmb/chroot/mount.py index 8931fe16..efd19734 100644 --- a/pmb/chroot/mount.py +++ b/pmb/chroot/mount.py @@ -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) diff --git a/pmb/config/workdir.py b/pmb/config/workdir.py index 41d968e5..033ae4fd 100644 --- a/pmb/config/workdir.py +++ b/pmb/config/workdir.py @@ -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 = (