| 189 | |
| 190 | @functools.cache |
| 191 | def init_podman_command() -> PodmanCommand: |
| 192 | podman_path: Path | None |
| 193 | settings = Settings() |
| 194 | |
| 195 | if settings.custom_runtime_specified(): |
| 196 | podman_path = Path(settings.get("container_runtime")) |
| 197 | if not podman_path.exists(): |
| 198 | raise errors.UnsupportedContainerRuntime(podman_path) |
| 199 | else: |
| 200 | podman_path = get_podman_path() |
| 201 | |
| 202 | options = env = None |
| 203 | if platform.system() != "Linux" and not settings.custom_runtime_specified(): |
| 204 | env = os.environ.copy() |
| 205 | env["CONTAINERS_CONF"] = str(create_containers_conf()) |
| 206 | options = PodmanCommand.GlobalOptions( |
| 207 | connection=PODMAN_MACHINE_NAME, |
| 208 | storage_opt="overlay.mount_program=/usr/bin/fuse-overlayfs", |
| 209 | ) |
| 210 | if settings.debug: |
| 211 | options.log_level = "debug" |
| 212 | elif linux_system_is("Tails"): |
| 213 | env = os.environ.copy() |
| 214 | env["HTTPS_PROXY"] = get_tails_socks_proxy() |
| 215 | try: |
| 216 | return PodmanCommand(path=podman_path, env=env, options=options) |
| 217 | except PodmanNotInstalled: |
| 218 | if getattr(sys, "dangerzone_dev", False): |
| 219 | raise errors.ContainerException( |
| 220 | "It seems that Podman is not present in your development environment." |
| 221 | " You can run `mazette install` to download and install it." |
| 222 | f" Expected path: {podman_path}" |
| 223 | ) |
| 224 | else: |
| 225 | raise errors.ContainerException( |
| 226 | "Dangerzone could not find the Podman binary locally, which" |
| 227 | " is necessary to start containers. This binary should be included as" |
| 228 | " part of the installation, so the fact that it's missing indicates" |
| 229 | " that your installation may be broken. You can try reinstalling" |
| 230 | " Dangerzone, but if the problem persists, please contact us." |
| 231 | ) |
| 232 | |
| 233 | |
| 234 | def list_image_digests() -> list[str]: |