]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make sure PATH is correct when using --tools-tree
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 3 Jul 2023 13:58:20 +0000 (15:58 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 3 Jul 2023 19:34:20 +0000 (21:34 +0200)
mkosi.md
mkosi/run.py

index 2fb893738f06115cf6ccb8b78fd27c21fd43156a..e76fc0a728704e67ce671b4659b16564c2d30d22 100644 (file)
--- a/mkosi.md
+++ b/mkosi.md
@@ -1033,7 +1033,9 @@ they should be specified with a boolean argument: either "1", "yes", or "true" t
   (aside from a few exceptions). Use this option to make image builds more reproducible by always using the
   same versions of programs to build the final image instead of whatever version is installed on the host
   system. If this option is not used, but the `mkosi.tools/` directory is found in the local directory it is
-  automatically used for this purpose with the root directory as target.
+  automatically used for this purpose with the root directory as target. Note that when looking up binaries
+  in `--tools-tree=`, only `/usr/bin` and `/usr/sbin` are considered. Specifically, paths specified by
+  `--extra-search-path=` are ignored when looking up binaries in the given tools tree.
 
 ### Commandline-only Options
 
index cdad973c5cd6ab4c89bdf886e18ef0541758f57a..6a6548e8cf17ed95fc79f1d03fe8b13632867b1f 100644 (file)
@@ -366,6 +366,13 @@ def bwrap(
     **kwargs: Any,
 ) -> CompletedProcess:
     with bwrap_cmd(root=root, apivfs=apivfs) as bwrap:
+        if root:
+            # If a root is specified, we should ignore any local modifications made to PATH as any of those
+            # tools might not work anymore when /usr is replaced wholesale. We also make sure that both
+            # /usr/bin and /usr/sbin/ are searched so that e.g. if the host is Arch and the root is Debian we
+            # don't ignore the binaries from /usr/sbin in the Debian root.
+            env = dict(PATH="/usr/bin:/usr/sbin") | env
+
         try:
             result = run([*bwrap, *cmd], text=True, env=env, log=False, **kwargs)
         except subprocess.CalledProcessError as e: