Skip to content
Snippets Groups Projects
Unverified Commit 765ba770 authored by Casey's avatar Casey :recycle: Committed by Oliver Smith
Browse files

chroot: merge executibles_absolute_path() logic into require_programs() (MR 2475)


Remove this chroot-specific helper and merge it in with the existing
require_programs() logic. Now we have one unified way to discover and
use programs from the host and where we can put any additional special
handling we might need.

Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
parent 585c4772
No related branches found
No related tags found
1 merge request!2475require_programs: Debian: find kpartx and losetup
......@@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import os
from pathlib import Path, PurePath
import shutil
import subprocess
from collections.abc import Sequence
from typing import overload, Literal
......@@ -23,23 +22,6 @@ from pmb.types import (
)
def executables_absolute_path():
"""
Get the absolute paths to the sh and chroot executables.
"""
ret = {}
for binary in ["sh", "chroot"]:
path = shutil.which(binary, path=pmb.config.chroot_host_path)
if not path:
raise RuntimeError(
f"Could not find the '{binary}'"
" executable. Make sure that it is in"
" your current user's PATH."
)
ret[binary] = path
return ret
def rootm(
cmds: Sequence[Sequence[PathString]],
chroot: Chroot = Chroot.native(),
......@@ -97,8 +79,8 @@ def rootm(
# cmd: ["echo", "test"]
# cmd_chroot: ["/sbin/chroot", "/..._native", "/bin/sh", "-c", "echo test"]
# cmd_sudo: ["sudo", "env", "-i", "sh", "-c", "PATH=... /sbin/chroot ..."]
executables = executables_absolute_path()
cmd_chroot = [
executables = pmb.config.required_programs
cmd_chroot: list[PathString] = [
executables["chroot"],
chroot.path,
"/bin/sh",
......
......@@ -148,7 +148,7 @@ chroot_path = ":".join(
# The PATH variable used on the host, to find the "chroot" and "sh"
# executables. As pmbootstrap runs as user, not as root, the location
# for the chroot executable may not be in the PATH (Debian).
chroot_host_path = os.environ["PATH"] + ":/usr/sbin/"
host_path = os.environ["PATH"] + ":/usr/sbin/"
# Folders that get mounted inside the chroot
# $WORK gets replaced with get_context().config.work
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment