From 89c50da976419cfc25c96d604b53e0c1c35a765f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rg=20Behrmann?= Date: Thu, 29 Aug 2024 11:05:37 +0200 Subject: [PATCH] Inline apivfs_script_cmd --- mkosi/installer/__init__.py | 12 ++++++++++-- mkosi/run.py | 13 ------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/mkosi/installer/__init__.py b/mkosi/installer/__init__.py index 203be6877..8a5468f5c 100644 --- a/mkosi/installer/__init__.py +++ b/mkosi/installer/__init__.py @@ -6,7 +6,7 @@ from pathlib import Path from mkosi.config import Config, ConfigFeature, OutputFormat from mkosi.context import Context from mkosi.mounts import finalize_crypto_mounts -from mkosi.run import apivfs_options, apivfs_script_cmd, finalize_passwd_mounts, find_binary +from mkosi.run import apivfs_options, finalize_interpreter, finalize_passwd_mounts, find_binary from mkosi.tree import rmtree from mkosi.types import PathString from mkosi.util import flatten, startswith @@ -114,7 +114,15 @@ class PackageManager: @classmethod def apivfs_script_cmd(cls, context: Context) -> list[PathString]: - return apivfs_script_cmd(tools=bool(context.config.tools_tree), options=cls.options(root="/buildroot")) + return [ + finalize_interpreter(bool(context.config.tools_tree)), "-SI", "/sandbox.py", + "--bind", "/", "/", + "--same-dir", + "--bind", "/var/tmp", "/buildroot/var/tmp", + *apivfs_options(), + *cls.options(root="/buildroot"), + "--", + ] @classmethod def sandbox(cls, context: Context, *, apivfs: bool) -> AbstractContextManager[list[PathString]]: diff --git a/mkosi/run.py b/mkosi/run.py index e6d4852b4..904da2573 100644 --- a/mkosi/run.py +++ b/mkosi/run.py @@ -560,19 +560,6 @@ def apivfs_options(*, root: Path = Path("/buildroot")) -> list[PathString]: ] -def apivfs_script_cmd(*, tools: bool, options: Sequence[PathString] = ()) -> list[PathString]: - exe = Path(sys.executable) - return [ - "python3" if tools or not exe.is_relative_to("/usr") else exe, "-SI", "/sandbox.py", - "--bind", "/", "/", - "--same-dir", - "--bind", "/var/tmp", "/buildroot/var/tmp", - *apivfs_options(), - *options, - "--", - ] - - def chroot_options() -> list[PathString]: return [ # Let's always run as (fake) root when we chroot inside the image as tools executed within the image could -- 2.47.2