This handles the case where a user adds ~/.local/bin to the PATH.
Let's make sure we use that even when running with a tools tree.
This might not work for binaries that are built against libraries
from the user's host /usr but there's lots of tools that will either
be statically compiled or written in an interpreted language like
python that will still work even when we switch out /usr from underneath
them.
need to acquire some files for the build process place them somewhere
sensible within `$BUILDROOT` so that they can be cached when building
incrementally.
+- When using a tools tree and we use a relaxed sandbox to run a command
+ (qemu, nspawn, ...), we now keep $PATH entries inside the user's home
+ intact. Note that this may cause issues if a PATH entry in your home contains
+ binaries linked against libraries in `/usr` from the host.
## v24
if network and Path("/etc/resolv.conf").exists():
cmdline += ["--ro-bind", "/etc/resolv.conf", "/etc/resolv.conf"]
+ home = None
+
cmdline += [
"--setenv",
"PATH",
- f"/scripts:{'/usr/bin:/usr/sbin' if tools != Path('/') else os.environ['PATH']}",
+ ":".join(
+ [
+ *(["/scripts"] if scripts else []),
+ "/usr/bin",
+ "/usr/sbin",
+ *(
+ [s for s in os.environ["PATH"].split(":") if home and s.startswith(os.fspath(home))]
+ if tools != Path("/")
+ else [os.environ["PATH"]]
+ ),
+ ]
+ ),
]
if scripts: