From: Daan De Meyer Date: Mon, 3 Jul 2023 13:58:20 +0000 (+0200) Subject: Make sure PATH is correct when using --tools-tree X-Git-Tag: v15~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=675b877192e7189398ac1ecf0f162798dc15e7cb;p=thirdparty%2Fmkosi.git Make sure PATH is correct when using --tools-tree --- diff --git a/mkosi.md b/mkosi.md index 2fb893738..e76fc0a72 100644 --- 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 diff --git a/mkosi/run.py b/mkosi/run.py index cdad973c5..6a6548e8c 100644 --- a/mkosi/run.py +++ b/mkosi/run.py @@ -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: