Skip to content
Snippets Groups Projects
Unverified Commit e0a2fbf2 authored by Newbyte's avatar Newbyte :snowflake:
Browse files

pmb.config: Check for kpartx and losetup with --json support (MR 2450)

Running these inside the chroot is tricky, and we ended up reverting
previous commits that attempted to make them run there (see
1ec55fc1). As such, just accept defeat
and ensure that the host has these.

Also see #2465
parent 612e212a
No related branches found
No related tags found
1 merge request!2450pmb.config: Check for kpartx and losetup with --json support
......@@ -47,6 +47,8 @@ Issues are being tracked
* For python3 < 3.11: tomli
* OpenSSL
* git
* kpartx (from multipath-tools)
* losetup (with --json support, e.g. util-linux version)
* ps
* tar
......
......@@ -59,6 +59,8 @@ ondev_min_version = "0.2.0"
# idea is to run almost everything in Alpine chroots.
required_programs = [
"git",
"kpartx",
"losetup",
"openssl",
"ps",
"tar",
......
......@@ -39,10 +39,31 @@ def require_programs() -> None:
for program in pmb.config.required_programs:
if not shutil.which(program):
missing.append(program)
losetup_missing_json = False
if "losetup" not in missing:
# Check if losetup supports the --json argument.
try:
pmb.helpers.run.user(["losetup", "--json"], check=True)
except RuntimeError:
losetup_missing_json = True
error_message = ""
if missing:
raise NonBugError(
f"Can't find all programs required to run pmbootstrap. Please install first: {', '.join(missing)}"
)
error_message += f"Can't find all programs required to run pmbootstrap. Please install the following: {', '.join(missing)}"
if missing and losetup_missing_json:
error_message += "\n\nAdditionally, your"
elif losetup_missing_json:
error_message += "Your"
if losetup_missing_json:
error_message += " system's losetup implementation is missing --json support. If you are using BusyBox, try installing losetup from util-linux."
if error_message:
raise NonBugError(error_message)
def ask_for_username(default_user: str) -> str:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment