From: Daan De Meyer Date: Tue, 27 Aug 2024 09:08:40 +0000 (+0200) Subject: Move sandbox tree logic into Config.sandbox() X-Git-Tag: v25~336^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d395a704264a42c58cc61d21e059d11023d81e0d;p=thirdparty%2Fmkosi.git Move sandbox tree logic into Config.sandbox() --- diff --git a/mkosi/config.py b/mkosi/config.py index 60f3ba452..38769fb48 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -1763,7 +1763,7 @@ class Config: relaxed: bool = False, tools: bool = True, scripts: Optional[Path] = None, - usroverlaydirs: Sequence[PathString] = (), + sandbox_tree: Optional[Path] = None, options: Sequence[PathString] = (), setup: Sequence[PathString] = (), ) -> AbstractContextManager[list[PathString]]: @@ -1782,6 +1782,15 @@ class Config: tools = False opt += flatten(("--ro-bind", d, d) for d in self.extra_search_paths if not relaxed) + if sandbox_tree: + opt += [ + # This mount is writable so we can create extra directories or symlinks inside of it as needed. + # This isn't a problem as the sandbox tree directory is created by mkosi and thrown away when the + # build finishes. + *(["--bind", str(p), "/etc"] if (p := sandbox_tree / "etc").exists() else []), + *(["--bind", str(p), "/var/log"] if (p := sandbox_tree / "var/log").exists() else []), + ] + return sandbox_cmd( network=network, devices=devices, @@ -1789,7 +1798,7 @@ class Config: relaxed=relaxed, scripts=scripts, tools=self.tools() if tools else Path("/"), - usroverlaydirs=usroverlaydirs, + usroverlaydirs=[sandbox_tree / "usr"] if sandbox_tree and (sandbox_tree / "usr").exists() else [], options=opt, setup=setup, ) diff --git a/mkosi/context.py b/mkosi/context.py index 22ed6d1ae..5f2ae1222 100644 --- a/mkosi/context.py +++ b/mkosi/context.py @@ -76,13 +76,6 @@ class Context: devices=devices, vartmp=vartmp, scripts=scripts, - usroverlaydirs=[self.sandbox_tree / "usr"] if (self.sandbox_tree / "usr").exists() else [], - options=[ - *options, - # This mount is writable so we can create extra directories or symlinks inside of it as needed. - # This isn't a problem as the package manager directory is created by mkosi and thrown away when the - # build finishes. - "--bind", self.sandbox_tree / "etc", "/etc", - "--bind", self.sandbox_tree / "var/log", "/var/log", - ], + sandbox_tree=self.sandbox_tree, + options=options, )