From: DaanDeMeyer Date: Fri, 4 Jul 2025 18:38:35 +0000 (+0200) Subject: Rename sandbox verb to box X-Git-Tag: v26~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1eab5a783bd3f5f0fb6a1d3dd60e9517cfae353;p=thirdparty%2Fmkosi.git Rename sandbox verb to box It's both shorter, and doesn't give the wrong impression that this is about security sandboxing, so let's rename the sandbox name to just box. Keep the old name as well of course for compat. --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a4f6b089..2e8b271ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -212,14 +212,14 @@ jobs: run: sudo mkosi summary - name: Build tools tree - run: sudo mkosi -f sandbox -- true + run: sudo mkosi -f box -- true - name: Build image run: sudo mkosi --distribution ${{ matrix.distro }} -f - name: Run integration tests run: | - sudo mkosi sandbox -- \ + sudo mkosi box -- \ timeout -k 30 1h \ python3 -m pytest \ --tb=no \ diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 99a424f97..c4a3564a2 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -74,7 +74,7 @@ from mkosi.config import ( expand_delayed_specifiers, finalize_configdir, format_bytes, - in_sandbox, + in_box, parse_boolean, parse_config, resolve_deps, @@ -4114,11 +4114,11 @@ def build_image(context: Context) -> None: print_output_size(context.config.output_dir_or_cwd() / context.config.output_with_compression) -def run_sandbox(args: Args, config: Config) -> None: - if in_sandbox(): +def run_box(args: Args, config: Config) -> None: + if in_box(): die( - "mkosi sandbox cannot be invoked from within another mkosi sandbox environment", - hint="Exit the current sandbox environment and try again", + "mkosi box cannot be invoked from within another mkosi box environment", + hint="Exit the current mkosi box environment and try again", ) if not args.cmdline: @@ -4139,7 +4139,7 @@ def run_sandbox(args: Args, config: Config) -> None: hd, hr = detect_distribution() - env = {"MKOSI_IN_SANDBOX": "1"} + env = {"MKOSI_IN_BOX": "1"} if hd: env |= {"MKOSI_HOST_DISTRIBUTION": str(hd)} if hr: @@ -5106,7 +5106,8 @@ def run_verb(args: Args, tools: Optional[Config], images: Sequence[Config], *, r Verb.ssh: run_ssh, Verb.journalctl: run_journalctl, Verb.coredumpctl: run_coredumpctl, - Verb.sandbox: run_sandbox, + Verb.box: run_box, + Verb.sandbox: run_box, }[args.verb](args, last) if last.output_format == OutputFormat.none: diff --git a/mkosi/config.py b/mkosi/config.py index c966260a8..e7da3fde6 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -87,6 +87,7 @@ class Verb(StrEnum): dependencies = enum.auto() completion = enum.auto() sysupdate = enum.auto() + box = enum.auto() sandbox = enum.auto() init = enum.auto() @@ -104,12 +105,13 @@ class Verb(StrEnum): Verb.completion, Verb.documentation, Verb.sysupdate, + Verb.box, Verb.sandbox, Verb.dependencies, ) def needs_tools(self) -> bool: - return self in (Verb.sandbox, Verb.journalctl, Verb.coredumpctl, Verb.ssh) + return self in (Verb.box, Verb.sandbox, Verb.journalctl, Verb.coredumpctl, Verb.ssh) def needs_build(self) -> bool: return self in ( @@ -675,8 +677,8 @@ def parse_boolean(s: str) -> bool: return value -def in_sandbox() -> bool: - return parse_boolean(os.getenv("MKOSI_IN_SANDBOX", "0")) +def in_box() -> bool: + return parse_boolean(os.getenv("MKOSI_IN_BOX", "0")) def parse_path( @@ -1479,7 +1481,7 @@ def config_parse_minimum_version(value: Optional[str], old: Optional[str]) -> Op return old if hash := startswith(value, "commit:"): - if not in_sandbox(): + if not in_box(): gitdir = Path(__file__).parent.parent if not (gitdir / ".git").exists(): die("Cannot check mkosi git version, not running mkosi from a git repository") @@ -2175,7 +2177,7 @@ class Config: return self.package_cache_dir or (INVOKING_USER.cache_dir() / "mkosi" / key) def tools(self) -> Path: - if in_sandbox(): + if in_box(): return Path("/") return self.tools_tree or Path("/") @@ -2310,8 +2312,8 @@ class Config: # Caching the package manager used does not matter for the default tools tree because we don't # cache the package manager metadata for the tools tree either. In fact, it can cause issues as # the cache manifest for the tools tree will sometimes be different depending on whether we're - # running inside or outside of the mkosi sandbox. To avoid these issues, don't cache the package - # manager used in the tools tree cache manifest. + # running inside or outside of the mkosi box environment. To avoid these issues, don't cache the + # package manager used in the tools tree cache manifest. **( {"package_manager": self.distribution.package_manager(self).executable(self)} if self.image != "tools" @@ -5172,7 +5174,7 @@ def parse_config( tools = None if config.get("tools_tree") == Path("default"): - if in_sandbox(): + if in_box(): config["tools_tree"] = Path(os.environ["MKOSI_DEFAULT_TOOLS_TREE_PATH"]) else: tools = finalize_default_tools(context, config, configdir=configdir, resources=resources) diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index feea867a9..d7b4671d6 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -30,7 +30,7 @@ mkosi — Build Bespoke OS Images `mkosi [options…] sysupdate [-- sysupdate settings…]` -`mkosi [options…] sandbox [-- command line…]` +`mkosi [options…] box [-- command line…]` `mkosi [options…] dependencies [-- options…]` @@ -143,8 +143,8 @@ The following command line verbs are known: specified after the `sysupdate` verb and separated from the regular options with `--` are passed directly to **systemd-sysupdate**. -`sandbox` -: Run arbitrary commands inside of the same sandbox used to execute +`box` +: Run arbitrary commands inside of the same environment used to execute other verbs such as `boot`, `shell`, `vm` and more. This means `/usr` will be replaced by `/usr` from the tools tree if one is used while everything else will remain in place. If no command is provided, diff --git a/tests/test_config.py b/tests/test_config.py index acd446adf..d9c537e08 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -21,7 +21,7 @@ from mkosi.config import ( OutputFormat, Verb, config_parse_bytes, - in_sandbox, + in_box, parse_config, parse_ini, ) @@ -1487,8 +1487,8 @@ def test_tools(tmp_path: Path) -> None: d = tmp_path argv = ["--tools-tree=default"] - if in_sandbox(): - pytest.skip("Cannot run test_tools() test within mkosi sandbox environment") + if in_box(): + pytest.skip("Cannot run test_tools() test within mkosi box environment") with resource_path(mkosi.resources) as resources, chdir(d): _, tools, _ = parse_config(argv, resources=resources)