forked from Mirror/pmbootstrap
helpers: mount: drop args (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
1371525c2b
commit
e547bb7f9c
13 changed files with 29 additions and 29 deletions
|
@ -280,7 +280,7 @@ def override_source(args: PmbArgs, apkbuild, pkgver, src, chroot: Chroot=Chroot.
|
|||
# Mount source in chroot
|
||||
mount_path = "/mnt/pmbootstrap/source-override/"
|
||||
mount_path_outside = chroot / mount_path
|
||||
pmb.helpers.mount.bind(args, src, mount_path_outside, umount=True)
|
||||
pmb.helpers.mount.bind(src, mount_path_outside, umount=True)
|
||||
|
||||
# Delete existing append file
|
||||
append_path = "/tmp/APKBUILD.append"
|
||||
|
@ -337,14 +337,14 @@ def override_source(args: PmbArgs, apkbuild, pkgver, src, chroot: Chroot=Chroot.
|
|||
pmb.chroot.user(args, ["mv", append_path + "_", apkbuild_path], chroot)
|
||||
|
||||
|
||||
def mount_pmaports(args: PmbArgs, destination, chroot: Chroot=Chroot.native()):
|
||||
def mount_pmaports(destination, chroot: Chroot=Chroot.native()):
|
||||
"""
|
||||
Mount pmaports.git in chroot.
|
||||
|
||||
:param destination: mount point inside the chroot
|
||||
"""
|
||||
outside_destination = chroot / destination
|
||||
pmb.helpers.mount.bind(args, args.aports, outside_destination, umount=True)
|
||||
pmb.helpers.mount.bind(args.aports, outside_destination, umount=True)
|
||||
|
||||
|
||||
def link_to_git_dir(args: PmbArgs, suffix):
|
||||
|
|
|
@ -129,7 +129,7 @@ def run_abuild(args: PmbArgs, pkgname: str, arch: str, apkbuild_path: Path, kbui
|
|||
# development, making it easy to quickly sideload a new kernel or pmbootstrap
|
||||
# to create a boot image.
|
||||
|
||||
pmb.helpers.mount.bind(args, Path("."), chroot / "mnt/linux")
|
||||
pmb.helpers.mount.bind(Path("."), chroot / "mnt/linux")
|
||||
|
||||
if not os.path.exists(chroot / kbuild_out_source):
|
||||
raise RuntimeError("No '.output' dir found in your kernel source dir. "
|
||||
|
@ -164,7 +164,7 @@ def run_abuild(args: PmbArgs, pkgname: str, arch: str, apkbuild_path: Path, kbui
|
|||
pmb.chroot.user(args, cmd, working_dir=build_path, env=env)
|
||||
|
||||
# Clean up bindmount
|
||||
pmb.helpers.mount.umount_all(args, chroot / "mnt/linux")
|
||||
pmb.helpers.mount.umount_all(chroot / "mnt/linux")
|
||||
|
||||
# Clean up symlinks
|
||||
if kbuild_out != "":
|
||||
|
@ -211,6 +211,6 @@ def package_kernel(args: PmbArgs):
|
|||
try:
|
||||
run_abuild(args, pkgname, arch, apkbuild_path, kbuild_out)
|
||||
except Exception as e:
|
||||
pmb.helpers.mount.umount_all(args, Chroot.native() / "mnt/linux")
|
||||
pmb.helpers.mount.umount_all(Chroot.native() / "mnt/linux")
|
||||
raise e
|
||||
pmb.build.other.index_repo(args, arch)
|
||||
|
|
|
@ -65,7 +65,7 @@ def setup_qemu_emulation(args: PmbArgs, chroot: Chroot):
|
|||
|
||||
# mount --bind the qemu-user binary
|
||||
pmb.chroot.binfmt.register(args, arch)
|
||||
pmb.helpers.mount.bind_file(args, Chroot.native() / f"/usr/bin/qemu-{arch_qemu}",
|
||||
pmb.helpers.mount.bind_file(Chroot.native() / f"/usr/bin/qemu-{arch_qemu}",
|
||||
chroot / f"usr/bin/qemu-{arch_qemu}-static",
|
||||
create_folders=True)
|
||||
|
||||
|
|
|
@ -94,13 +94,13 @@ def mount(args: PmbArgs, chroot: Chroot=Chroot.native()):
|
|||
for source, target in mountpoints.items():
|
||||
target_outer = chroot / target
|
||||
#raise RuntimeError("test")
|
||||
pmb.helpers.mount.bind(args, source, target_outer)
|
||||
pmb.helpers.mount.bind(source, target_outer)
|
||||
|
||||
|
||||
def mount_native_into_foreign(args: PmbArgs, chroot: Chroot):
|
||||
source = Chroot.native().path
|
||||
target = chroot / "native"
|
||||
pmb.helpers.mount.bind(args, source, target)
|
||||
pmb.helpers.mount.bind(source, target)
|
||||
|
||||
musl = next(source.glob("lib/ld-musl-*.so.1")).name
|
||||
musl_link = (chroot / "lib" / musl)
|
||||
|
|
|
@ -66,7 +66,7 @@ def shutdown(args: PmbArgs, only_install_related=False):
|
|||
chroot = Chroot.native()
|
||||
|
||||
# Umount installation-related paths (order is important!)
|
||||
pmb.helpers.mount.umount_all(args, chroot / "mnt/install")
|
||||
pmb.helpers.mount.umount_all(chroot / "mnt/install")
|
||||
shutdown_cryptsetup_device(args, "pm_crypt")
|
||||
|
||||
# Umount all losetup mounted images
|
||||
|
@ -79,7 +79,7 @@ def shutdown(args: PmbArgs, only_install_related=False):
|
|||
for chroot_type in [ChrootType.ROOTFS, ChrootType.INSTALLER]:
|
||||
chroot = Chroot(chroot_type, args.device)
|
||||
if chroot.path.exists():
|
||||
pmb.helpers.mount.umount_all(args, chroot.path)
|
||||
pmb.helpers.mount.umount_all(chroot.path)
|
||||
|
||||
# Remove "in-pmbootstrap" marker from all chroots. This marker indicates
|
||||
# that pmbootstrap has set up all mount points etc. to run programs inside
|
||||
|
@ -94,7 +94,7 @@ def shutdown(args: PmbArgs, only_install_related=False):
|
|||
# The folders are explicitly iterated over, so folders symlinked inside
|
||||
# work dir get umounted as well (used in test_pkgrel_bump.py, #1595)
|
||||
for path in pmb.config.work.glob("*"):
|
||||
pmb.helpers.mount.umount_all(args, path)
|
||||
pmb.helpers.mount.umount_all(path)
|
||||
|
||||
# Clean up the rest
|
||||
for arch in pmb.config.build_device_architectures:
|
||||
|
|
|
@ -95,7 +95,7 @@ def sideload(args: PmbArgs):
|
|||
# Mount the buildroot
|
||||
chroot = Chroot.buildroot(args.deviceinfo["arch"])
|
||||
mountpoint = "/mnt/" / chroot
|
||||
pmb.helpers.mount.bind(args, chroot.path,
|
||||
pmb.helpers.mount.bind(chroot.path,
|
||||
Chroot.native().path / mountpoint)
|
||||
|
||||
# Missing recovery zip error
|
||||
|
|
|
@ -48,7 +48,7 @@ def init(args: PmbArgs):
|
|||
|
||||
# Mount folders from host system
|
||||
for folder in pmb.config.flash_mount_bind:
|
||||
pmb.helpers.mount.bind(args, folder, Chroot.native() / folder)
|
||||
pmb.helpers.mount.bind(folder, Chroot.native() / folder)
|
||||
|
||||
# Mount device chroot inside native chroot (required for kernel/ramdisk)
|
||||
mount_device_rootfs(args, Chroot(ChrootType.ROOTFS, args.device))
|
||||
|
|
|
@ -25,7 +25,7 @@ def ismount(folder: Path):
|
|||
return False
|
||||
|
||||
|
||||
def bind(args: PmbArgs, source: Path, destination: Path, create_folders=True, umount=False):
|
||||
def bind(source: Path, destination: Path, create_folders=True, umount=False):
|
||||
"""Mount --bind a folder and create necessary directory structure.
|
||||
|
||||
:param umount: when destination is already a mount point, umount it first.
|
||||
|
@ -33,7 +33,7 @@ def bind(args: PmbArgs, source: Path, destination: Path, create_folders=True, um
|
|||
# Check/umount destination
|
||||
if ismount(destination):
|
||||
if umount:
|
||||
umount_all(args, destination)
|
||||
umount_all(destination)
|
||||
else:
|
||||
return
|
||||
|
||||
|
@ -56,7 +56,7 @@ def bind(args: PmbArgs, source: Path, destination: Path, create_folders=True, um
|
|||
raise RuntimeError(f"Mount failed: {source} -> {destination}")
|
||||
|
||||
|
||||
def bind_file(args: PmbArgs, source: Path, destination: Path, create_folders=False):
|
||||
def bind_file(source: Path, destination: Path, create_folders=False):
|
||||
"""Mount a file with the --bind option, and create the destination file, if necessary."""
|
||||
# Skip existing mountpoint
|
||||
if ismount(destination):
|
||||
|
@ -98,7 +98,7 @@ def umount_all_list(prefix: Path, source: Path=Path("/proc/mounts")) -> List[Pat
|
|||
return ret
|
||||
|
||||
|
||||
def umount_all(args: PmbArgs, folder: Path):
|
||||
def umount_all(folder: Path):
|
||||
"""Umount all folders that are mounted inside a given folder."""
|
||||
for mountpoint in umount_all_list(folder):
|
||||
pmb.helpers.run.root(["umount", mountpoint])
|
||||
|
@ -106,7 +106,7 @@ def umount_all(args: PmbArgs, folder: Path):
|
|||
raise RuntimeError(f"Failed to umount: {mountpoint}")
|
||||
|
||||
|
||||
def mount_device_rootfs(args: PmbArgs, chroot_rootfs: Chroot) -> PurePath:
|
||||
def mount_device_rootfs(chroot_rootfs: Chroot) -> PurePath:
|
||||
"""
|
||||
Mount the device rootfs.
|
||||
:param chroot_rootfs: the chroot where the rootfs that will be
|
||||
|
@ -115,6 +115,6 @@ def mount_device_rootfs(args: PmbArgs, chroot_rootfs: Chroot) -> PurePath:
|
|||
:returns: the mountpoint (relative to the native chroot)
|
||||
"""
|
||||
mountpoint = PurePath("/mnt", chroot_rootfs.dirname)
|
||||
pmb.helpers.mount.bind(args, chroot_rootfs.path,
|
||||
pmb.helpers.mount.bind(chroot_rootfs.path,
|
||||
Chroot.native() / mountpoint)
|
||||
return mountpoint
|
||||
|
|
|
@ -853,7 +853,7 @@ def install_system_image(args: PmbArgs, size_reserve, chroot: Chroot, step, step
|
|||
pmb.chroot.root(args, ["mkinitfs"], chroot)
|
||||
|
||||
# Clean up after running mkinitfs in chroot
|
||||
pmb.helpers.mount.umount_all(args, chroot.path)
|
||||
pmb.helpers.mount.umount_all(chroot.path)
|
||||
pmb.helpers.run.root(["rm", chroot / "in-pmbootstrap"])
|
||||
pmb.chroot.remove_mnt_pmbootstrap(args, chroot)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ def previous_install(args: PmbArgs, path: Path):
|
|||
if not os.path.exists(blockdevice_outside):
|
||||
continue
|
||||
blockdevice_inside = "/dev/diskp1"
|
||||
pmb.helpers.mount.bind_file(args, blockdevice_outside,
|
||||
pmb.helpers.mount.bind_file(blockdevice_outside,
|
||||
Chroot.native() / blockdevice_inside)
|
||||
try:
|
||||
label = pmb.chroot.root(args, ["blkid", "-s", "LABEL",
|
||||
|
@ -52,7 +52,7 @@ def mount_disk(args: PmbArgs, path: Path):
|
|||
raise RuntimeError(f"{path_mount} is mounted! Will not attempt to"
|
||||
" format this!")
|
||||
logging.info(f"(native) mount /dev/install (host: {path})")
|
||||
pmb.helpers.mount.bind_file(args, path, Chroot.native() / "dev/install")
|
||||
pmb.helpers.mount.bind_file(path, Chroot.native() / "dev/install")
|
||||
if previous_install(args, path):
|
||||
if not pmb.helpers.cli.confirm(args, "WARNING: This device has a"
|
||||
" previous installation of pmOS."
|
||||
|
@ -86,7 +86,7 @@ def create_and_mount_image(args: PmbArgs, size_boot, size_root, size_reserve,
|
|||
for img_path in [img_path_full, img_path_boot, img_path_root]:
|
||||
outside = chroot / img_path
|
||||
if os.path.exists(outside):
|
||||
pmb.helpers.mount.umount_all(args, chroot / "mnt")
|
||||
pmb.helpers.mount.umount_all(chroot / "mnt")
|
||||
pmb.install.losetup.umount(args, img_path)
|
||||
pmb.chroot.root(args, ["rm", img_path])
|
||||
|
||||
|
@ -122,7 +122,7 @@ def create_and_mount_image(args: PmbArgs, size_boot, size_root, size_reserve,
|
|||
logging.info(f"(native) mount {mount_point} ({img_path.name})")
|
||||
pmb.install.losetup.mount(args, img_path)
|
||||
device = pmb.install.losetup.device_by_back_file(args, img_path)
|
||||
pmb.helpers.mount.bind_file(args, device, Chroot.native() / mount_point)
|
||||
pmb.helpers.mount.bind_file(device, Chroot.native() / mount_point)
|
||||
|
||||
|
||||
def create(args: PmbArgs, size_boot, size_root, size_reserve, split, disk: Optional[Path]):
|
||||
|
@ -135,7 +135,7 @@ def create(args: PmbArgs, size_boot, size_root, size_reserve, split, disk: Optio
|
|||
:param split: create separate images for boot and root partitions
|
||||
:param disk: path to disk block device (e.g. /dev/mmcblk0) or None
|
||||
"""
|
||||
pmb.helpers.mount.umount_all(args, Chroot.native() / "dev/install")
|
||||
pmb.helpers.mount.umount_all(Chroot.native() / "dev/install")
|
||||
if disk:
|
||||
mount_disk(args, disk)
|
||||
else:
|
||||
|
|
|
@ -21,7 +21,7 @@ def init(args: PmbArgs):
|
|||
for loopdevice in Path("/dev/").glob("loop*"):
|
||||
if loopdevice.is_dir():
|
||||
continue
|
||||
pmb.helpers.mount.bind_file(args, loopdevice, Chroot.native() / loopdevice)
|
||||
pmb.helpers.mount.bind_file(loopdevice, Chroot.native() / loopdevice)
|
||||
|
||||
|
||||
def mount(args: PmbArgs, img_path: Path):
|
||||
|
|
|
@ -56,7 +56,7 @@ def partitions_mount(args: PmbArgs, layout, disk: Optional[Path]):
|
|||
for i in partitions:
|
||||
source = Path(f"{partition_prefix}{i}")
|
||||
target = Chroot.native() / "dev" / f"installp{i}"
|
||||
pmb.helpers.mount.bind_file(args, source, target)
|
||||
pmb.helpers.mount.bind_file(source, target)
|
||||
|
||||
|
||||
def partition(args: PmbArgs, layout, size_boot, size_reserve):
|
||||
|
|
|
@ -31,7 +31,7 @@ def test_chroot_mount(args: PmbArgs):
|
|||
assert (mnt_dir / "packages").exists()
|
||||
|
||||
# Umount everything, like in pmb.install.install_system_image
|
||||
pmb.helpers.mount.umount_all(args, chroot.path)
|
||||
pmb.helpers.mount.umount_all(chroot.path)
|
||||
|
||||
# Remove all /mnt/pmbootstrap dirs
|
||||
pmb.chroot.remove_mnt_pmbootstrap(args, chroot)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue