diff --git a/README.md b/README.md index 2c857afc1b19f6529e041dc607f6165ee87f6850..b4287a78e6dd0bc5dbdc9b9b7be1e0411799ca9e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py index a29532f59a6fc2f7bcb10f144fe69d64d7b7748a..34f521becabee6d098a3aec9c0adb08e955de01a 100644 --- a/pmb/config/__init__.py +++ b/pmb/config/__init__.py @@ -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", diff --git a/pmb/config/init.py b/pmb/config/init.py index 5f7ab7ccb44e26c8f3be9352dc110d0091d57435..2da3624ef56adc7e00b9867d8165fc7d0bc30ec9 100644 --- a/pmb/config/init.py +++ b/pmb/config/init.py @@ -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: