This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch jbilleter/digest-environment in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 2c601fa54d478983b6ae16178c7d4da12b0a9d91 Author: Jürg Billeter <[email protected]> AuthorDate: Fri Aug 8 14:30:03 2025 +0200 wip: env --- src/buildstream/element.py | 4 ++-- src/buildstream/sandbox/sandbox.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/buildstream/element.py b/src/buildstream/element.py index ee05ce423..85a0d36fb 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -1699,7 +1699,7 @@ class Element(Plugin): self.__configure_sandbox(sandbox) # Print the environment at the beginning of the log file. - env_dump = _yaml.roundtrip_dump_string(sandbox._get_environment()) + env_dump = _yaml.roundtrip_dump_string(sandbox._get_configured_environment() or self.get_environment()) self.log("Build environment for element {}".format(self.name), detail=env_dump) # Step 2 - Stage @@ -2046,7 +2046,7 @@ class Element(Plugin): def _shell(self, scope=None, *, mounts=None, isolate=False, prompt=None, command=None, usebuildtree=False): with self._prepare_sandbox(scope, shell=True, usebuildtree=usebuildtree) as sandbox: - environment = self.get_environment() + environment = sandbox._get_configured_environment() or self.get_environment() environment = copy.copy(environment) flags = _SandboxFlags.INTERACTIVE | _SandboxFlags.ROOT_READ_ONLY diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py index 821f14254..308583584 100644 --- a/src/buildstream/sandbox/sandbox.py +++ b/src/buildstream/sandbox/sandbox.py @@ -432,7 +432,7 @@ class Sandbox: def _get_environment(self, *, cwd=None, env=None): cwd = self._get_work_directory(cwd=cwd) if env is None: - env = self.__env or {} + env = self.__env # Naive getcwd implementations can break when bind-mounts to different # paths on the same filesystem are present. Letting the command know @@ -443,6 +443,9 @@ class Sandbox: return env + def _get_configured_environment(self): + return self.__env + # _get_work_directory() # # Fetches the working directory for running commands
