summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2018-09-16 10:50:36 +0000
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-09-16 10:50:36 +0000
commit9b7b2a25ba785ac020d71d6042ecf25c160f2607 (patch)
tree7daa1de8a7384feca7ae6e39a9d321376724f0c8
parent662d22a9067eec47da1a5f37985e510a2c8ec792 (diff)
parenteb9481da88ecbcd823f6e75a4e1cccf2620bc0cc (diff)
downloadbuildstream-9b7b2a25ba785ac020d71d6042ecf25c160f2607.tar.gz
Merge branch 'richardmaw/subprocess-PWD' into 'master'
Address post-merge review of Ensure PWD is set in process environment See merge request BuildStream/buildstream!788
-rw-r--r--buildstream/_versions.py2
-rw-r--r--buildstream/sandbox/_sandboxbwrap.py16
-rw-r--r--buildstream/sandbox/_sandboxchroot.py20
-rw-r--r--buildstream/sandbox/sandbox.py26
-rw-r--r--tests/cachekey/project/elements/build1.expected2
-rw-r--r--tests/cachekey/project/elements/build2.expected2
-rw-r--r--tests/cachekey/project/elements/compose1.expected2
-rw-r--r--tests/cachekey/project/elements/compose2.expected2
-rw-r--r--tests/cachekey/project/elements/compose3.expected2
-rw-r--r--tests/cachekey/project/elements/compose4.expected2
-rw-r--r--tests/cachekey/project/elements/compose5.expected2
-rw-r--r--tests/cachekey/project/elements/import1.expected2
-rw-r--r--tests/cachekey/project/elements/import2.expected2
-rw-r--r--tests/cachekey/project/elements/import3.expected2
-rw-r--r--tests/cachekey/project/elements/script1.expected2
-rw-r--r--tests/cachekey/project/sources/bzr1.expected2
-rw-r--r--tests/cachekey/project/sources/git1.expected2
-rw-r--r--tests/cachekey/project/sources/git2.expected2
-rw-r--r--tests/cachekey/project/sources/local1.expected2
-rw-r--r--tests/cachekey/project/sources/local2.expected2
-rw-r--r--tests/cachekey/project/sources/ostree1.expected2
-rw-r--r--tests/cachekey/project/sources/patch1.expected2
-rw-r--r--tests/cachekey/project/sources/patch2.expected2
-rw-r--r--tests/cachekey/project/sources/patch3.expected2
-rw-r--r--tests/cachekey/project/sources/pip1.expected2
-rw-r--r--tests/cachekey/project/sources/remote1.expected2
-rw-r--r--tests/cachekey/project/sources/remote2.expected2
-rw-r--r--tests/cachekey/project/sources/tar1.expected2
-rw-r--r--tests/cachekey/project/sources/tar2.expected2
-rw-r--r--tests/cachekey/project/sources/zip1.expected2
-rw-r--r--tests/cachekey/project/sources/zip2.expected2
-rw-r--r--tests/cachekey/project/target.expected2
-rwxr-xr-xtests/cachekey/update.py2
33 files changed, 59 insertions, 63 deletions
diff --git a/buildstream/_versions.py b/buildstream/_versions.py
index 713cb9d67..9d9d270c5 100644
--- a/buildstream/_versions.py
+++ b/buildstream/_versions.py
@@ -33,4 +33,4 @@ BST_FORMAT_VERSION = 16
# or if buildstream was changed in a way which can cause
# the same cache key to produce something that is no longer
# the same.
-BST_CORE_ARTIFACT_VERSION = 5
+BST_CORE_ARTIFACT_VERSION = 6
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py
index 88b697dca..5effadf41 100644
--- a/buildstream/sandbox/_sandboxbwrap.py
+++ b/buildstream/sandbox/_sandboxbwrap.py
@@ -63,20 +63,8 @@ class SandboxBwrap(Sandbox):
# Fallback to the sandbox default settings for
# the cwd and env.
#
- if cwd is None:
- cwd = self._get_work_directory()
-
- if env is None:
- env = self._get_environment()
-
- if cwd is None:
- cwd = '/'
-
- # Naive getcwd implementations can break when bind-mounts to different
- # paths on the same filesystem are present. Letting the command know
- # what directory it is in makes it unnecessary to call the faulty
- # getcwd.
- env['PWD'] = cwd
+ cwd = self._get_work_directory(cwd=cwd)
+ env = self._get_environment(cwd=cwd, env=env)
if not self._has_command(command[0], env):
raise SandboxError("Staged artifacts do not provide command "
diff --git a/buildstream/sandbox/_sandboxchroot.py b/buildstream/sandbox/_sandboxchroot.py
index 1869468ce..64fb3c1bc 100644
--- a/buildstream/sandbox/_sandboxchroot.py
+++ b/buildstream/sandbox/_sandboxchroot.py
@@ -48,21 +48,11 @@ class SandboxChroot(Sandbox):
def run(self, command, flags, *, cwd=None, env=None):
- # Default settings
- if cwd is None:
- cwd = self._get_work_directory()
-
- if cwd is None:
- cwd = '/'
-
- if env is None:
- env = self._get_environment()
-
- # Naive getcwd implementations can break when bind-mounts to different
- # paths on the same filesystem are present. Letting the command know
- # what directory it is in makes it unnecessary to call the faulty
- # getcwd.
- env['PWD'] = cwd
+ # Fallback to the sandbox default settings for
+ # the cwd and env.
+ #
+ cwd = self._get_work_directory(cwd=cwd)
+ env = self._get_environment(cwd=cwd, env=env)
if not self._has_command(command[0], env):
raise SandboxError("Staged artifacts do not provide command "
diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py
index 9d34f0195..9d0b69b73 100644
--- a/buildstream/sandbox/sandbox.py
+++ b/buildstream/sandbox/sandbox.py
@@ -279,20 +279,38 @@ class Sandbox():
# Fetches the environment variables for running commands
# in the sandbox.
#
+ # Args:
+ # cwd (str): The working directory the command has been requested to run in, if any.
+ # env (str): The environment the command has been requested to run in, if any.
+ #
# Returns:
# (str): The sandbox work directory
- def _get_environment(self):
- return self.__env
+ def _get_environment(self, *, cwd=None, env=None):
+ cwd = self._get_work_directory(cwd=cwd)
+ if env is None:
+ env = self.__env
+
+ # Naive getcwd implementations can break when bind-mounts to different
+ # paths on the same filesystem are present. Letting the command know
+ # what directory it is in makes it unnecessary to call the faulty
+ # getcwd.
+ env = dict(env)
+ env['PWD'] = cwd
+
+ return env
# _get_work_directory()
#
# Fetches the working directory for running commands
# in the sandbox.
#
+ # Args:
+ # cwd (str): The working directory the command has been requested to run in, if any.
+ #
# Returns:
# (str): The sandbox work directory
- def _get_work_directory(self):
- return self.__cwd
+ def _get_work_directory(self, *, cwd=None):
+ return cwd or self.__cwd or '/'
# _get_scratch_directory()
#
diff --git a/tests/cachekey/project/elements/build1.expected b/tests/cachekey/project/elements/build1.expected
index 5b3a9ad71..42d0261e3 100644
--- a/tests/cachekey/project/elements/build1.expected
+++ b/tests/cachekey/project/elements/build1.expected
@@ -1 +1 @@
-05429485dff08bdb968f7d10c2cdda63be49c8a783d54863a0d4abce44bbebe9 \ No newline at end of file
+dd5e29baefb84f68eb4abac3a1befc332077ec4c97bb2572e57f3ca98ba46707 \ No newline at end of file
diff --git a/tests/cachekey/project/elements/build2.expected b/tests/cachekey/project/elements/build2.expected
index 9641bd05b..cc2026064 100644
--- a/tests/cachekey/project/elements/build2.expected
+++ b/tests/cachekey/project/elements/build2.expected
@@ -1 +1 @@
-4155c7bc836cdb092de3241fa92883bd8c7dd94c55affa406e559aeb6252c669 \ No newline at end of file
+99d80454cce44645597c885800edf0bf254d1c3606d869f2ccdd5043ec7685cb \ No newline at end of file
diff --git a/tests/cachekey/project/elements/compose1.expected b/tests/cachekey/project/elements/compose1.expected
index ee82ebb6a..a76ce029f 100644
--- a/tests/cachekey/project/elements/compose1.expected
+++ b/tests/cachekey/project/elements/compose1.expected
@@ -1 +1 @@
-4e4c719242aa45fed398cc2fb8936195a1fcae9326d808de7fee340ae48862ea \ No newline at end of file
+b63c517f604e8ca64e973476f687190d14a813a0bf77573b93a557f5fb7ae214 \ No newline at end of file
diff --git a/tests/cachekey/project/elements/compose2.expected b/tests/cachekey/project/elements/compose2.expected
index f7b2d396b..cc17908c7 100644
--- a/tests/cachekey/project/elements/compose2.expected
+++ b/tests/cachekey/project/elements/compose2.expected
@@ -1 +1 @@
-2fc1dd398f6c6f6e1d7ca48d88557e133d2130278882e14cd1105b15a600cd7a \ No newline at end of file
+6676f1cce86166eb66ab83254fe2deb43be93644967de110dd42713dea181508 \ No newline at end of file
diff --git a/tests/cachekey/project/elements/compose3.expected b/tests/cachekey/project/elements/compose3.expected
index e6339b175..cef7e620a 100644
--- a/tests/cachekey/project/elements/compose3.expected
+++ b/tests/cachekey/project/elements/compose3.expected
@@ -1 +1 @@
-4d7c9e2e1e8cfcc4b300a11693767f41f22c7829db9063dec10856328d03ccc3 \ No newline at end of file
+0f8f444566c097067f2dfa54f26100abff85cc49bf9acf0081129f53244bc144 \ No newline at end of file
diff --git a/tests/cachekey/project/elements/compose4.expected b/tests/cachekey/project/elements/compose4.expected
index de299e892..96cb1c4a0 100644
--- a/tests/cachekey/project/elements/compose4.expected
+++ b/tests/cachekey/project/elements/compose4.expected
@@ -1 +1 @@
-cad8f3b622f4a906f9fc3f5187a7703e2b17dfc550dd5a07479ca3ebffbd5c86 \ No newline at end of file
+aa72331d42f647e845243e8a77389febfb78acff09f70771a3545bdf0d4d70ad \ No newline at end of file
diff --git a/tests/cachekey/project/elements/compose5.expected b/tests/cachekey/project/elements/compose5.expected
index d7c4c3ef8..6fec106a3 100644
--- a/tests/cachekey/project/elements/compose5.expected
+++ b/tests/cachekey/project/elements/compose5.expected
@@ -1 +1 @@
-4fd21699827aa16da8d7a1525020f9fd45422f0431749510947ff472d76c1802 \ No newline at end of file
+37bb4486f42e04b8a1c9f9cb9358adfd0d4dae0bb3b2a4072e090848cd2b955d \ No newline at end of file
diff --git a/tests/cachekey/project/elements/import1.expected b/tests/cachekey/project/elements/import1.expected
index bc9c1c93f..8e3c582e7 100644
--- a/tests/cachekey/project/elements/import1.expected
+++ b/tests/cachekey/project/elements/import1.expected
@@ -1 +1 @@
-aa443ea4607d7dd5a0c99646a1b827e3165862772fc1b26e20195aadd2ab8885 \ No newline at end of file
+ce2dce59ad7fa810c945e7385cc25d4c8992adf71fbdc44336cf136330fe2b16 \ No newline at end of file
diff --git a/tests/cachekey/project/elements/import2.expected b/tests/cachekey/project/elements/import2.expected
index 1013f5826..5ad1b5816 100644
--- a/tests/cachekey/project/elements/import2.expected
+++ b/tests/cachekey/project/elements/import2.expected
@@ -1 +1 @@
-18ea6bbb968ca6945c8c2941650f447b8df58673be7270c967c8152730eff036 \ No newline at end of file
+4fd32ee29026ecbcee717c8f04a0b807934a7042d67b8786e0eb9326757c845d \ No newline at end of file
diff --git a/tests/cachekey/project/elements/import3.expected b/tests/cachekey/project/elements/import3.expected
index 9a8517728..c5d55728f 100644
--- a/tests/cachekey/project/elements/import3.expected
+++ b/tests/cachekey/project/elements/import3.expected
@@ -1 +1 @@
-34ce4816b0307f0691302460367ab24b4e1f86e61c0e307e68bcd6833946c1f1 \ No newline at end of file
+e24dd31bda628616138014391a94040490da0820a2c42ab10ec6dfad1b694df9 \ No newline at end of file
diff --git a/tests/cachekey/project/elements/script1.expected b/tests/cachekey/project/elements/script1.expected
index e36a3df70..83dbba964 100644
--- a/tests/cachekey/project/elements/script1.expected
+++ b/tests/cachekey/project/elements/script1.expected
@@ -1 +1 @@
-c48922b3d80d36e6d30bed7581aa1473a5e463321b3a19606b603c055d2b4be4 \ No newline at end of file
+a139b184c8dd6a6e08231822ca2d886688e5d7720dc2290f8876d485bdb920b5 \ No newline at end of file
diff --git a/tests/cachekey/project/sources/bzr1.expected b/tests/cachekey/project/sources/bzr1.expected
index fecc86c74..81bcac7ec 100644
--- a/tests/cachekey/project/sources/bzr1.expected
+++ b/tests/cachekey/project/sources/bzr1.expected
@@ -1 +1 @@
-ee271c8f469cd33330229d8dcc44e26f3480a9f47b55db46f42d1a396a94609e \ No newline at end of file
+d2aeb3715c5842461384bea6a9bcf452310d1626ae40b6e7a9f51adc66a270fd \ No newline at end of file
diff --git a/tests/cachekey/project/sources/git1.expected b/tests/cachekey/project/sources/git1.expected
index eab44b627..dca2d04f0 100644
--- a/tests/cachekey/project/sources/git1.expected
+++ b/tests/cachekey/project/sources/git1.expected
@@ -1 +1 @@
-39fdc83c2760589c2577fb859cc617a8fdd7ac4cf113f9d4e5c723d70cae3c09 \ No newline at end of file
+4e03d21335e578034b09191ebf4977f0f537425c3031805dfb2f835ff77925cd \ No newline at end of file
diff --git a/tests/cachekey/project/sources/git2.expected b/tests/cachekey/project/sources/git2.expected
index 868439c9b..d32c44557 100644
--- a/tests/cachekey/project/sources/git2.expected
+++ b/tests/cachekey/project/sources/git2.expected
@@ -1 +1 @@
-8bac8c7d3b8bbd264083db8e6f3aa8894625af5396bbe62589d1ab726a87cccd \ No newline at end of file
+75c96f6c8d3ca3ffe164cd51f42689287021e60ef524f56340539feadd5a9fb8 \ No newline at end of file
diff --git a/tests/cachekey/project/sources/local1.expected b/tests/cachekey/project/sources/local1.expected
index bc9c1c93f..8e3c582e7 100644
--- a/tests/cachekey/project/sources/local1.expected
+++ b/tests/cachekey/project/sources/local1.expected
@@ -1 +1 @@
-aa443ea4607d7dd5a0c99646a1b827e3165862772fc1b26e20195aadd2ab8885 \ No newline at end of file
+ce2dce59ad7fa810c945e7385cc25d4c8992adf71fbdc44336cf136330fe2b16 \ No newline at end of file
diff --git a/tests/cachekey/project/sources/local2.expected b/tests/cachekey/project/sources/local2.expected
index 610d3fe5d..ffa2c5d51 100644
--- a/tests/cachekey/project/sources/local2.expected
+++ b/tests/cachekey/project/sources/local2.expected
@@ -1 +1 @@
-51296c83a0d5989a67f40391afcbf420cbbd76c1e6c07aa43fe2aef2e88941e3 \ No newline at end of file
+de18b7d9ee2358d6924db5a9f72257e2e2a3d5f8450cb8891f8984bfd1101345 \ No newline at end of file
diff --git a/tests/cachekey/project/sources/ostree1.expected b/tests/cachekey/project/sources/ostree1.expected
index 891bea41b..f12da1ba1 100644
--- a/tests/cachekey/project/sources/ostree1.expected
+++ b/tests/cachekey/project/sources/ostree1.expected
@@ -1 +1 @@
-cd8b506c38c116d6bea8999720a82afb8844453d5ad05385302eabc7d858859c \ No newline at end of file
+b8414e0077057fcac4e10291d88d898d7132dc591e3b265afee1ad59831815ca \ No newline at end of file
diff --git a/tests/cachekey/project/sources/patch1.expected b/tests/cachekey/project/sources/patch1.expected
index 76c2a2a91..b193eca9f 100644
--- a/tests/cachekey/project/sources/patch1.expected
+++ b/tests/cachekey/project/sources/patch1.expected
@@ -1 +1 @@
-bf2fe787df6f263cfd7dbd4aa91909af4186e252da722c3d2e2383533fbc7057 \ No newline at end of file
+a426c94443da29b060af0aed3f2ffdd4470e1ce9cb0592d8696c55a767e448c1 \ No newline at end of file
diff --git a/tests/cachekey/project/sources/patch2.expected b/tests/cachekey/project/sources/patch2.expected
index ea97daf87..94e975ae2 100644
--- a/tests/cachekey/project/sources/patch2.expected
+++ b/tests/cachekey/project/sources/patch2.expected
@@ -1 +1 @@
-8f040542ebb9b1c690af99d2db4ffc0a54cb13868a364af4771d19615b9e3b02 \ No newline at end of file
+b884e246b61cc930f33216055e99a82a47dcf42435b860622039555a159fc255 \ No newline at end of file
diff --git a/tests/cachekey/project/sources/patch3.expected b/tests/cachekey/project/sources/patch3.expected
index 96e7d4a13..4e11c37ce 100644
--- a/tests/cachekey/project/sources/patch3.expected
+++ b/tests/cachekey/project/sources/patch3.expected
@@ -1 +1 @@
-fb3985a6527f2498974ffa418cc6832b716d9862c713d7b8dc1c22df45857ee5 \ No newline at end of file
+79e297df970b6faaa1cfd64e5a6b6c8b4611b9128a19a7f22a2ee051174fccc9 \ No newline at end of file
diff --git a/tests/cachekey/project/sources/pip1.expected b/tests/cachekey/project/sources/pip1.expected
index 11d7c5fae..1fe5a50c4 100644
--- a/tests/cachekey/project/sources/pip1.expected
+++ b/tests/cachekey/project/sources/pip1.expected
@@ -1 +1 @@
-880d0dc27d6683725cfd68d60156058115a9a53793b14b727fc6d0588a473763 \ No newline at end of file
+d8bdc8848e4d2e3d70a1267e73bf0e63afa778e4c905cad1a94308634176fb87 \ No newline at end of file
diff --git a/tests/cachekey/project/sources/remote1.expected b/tests/cachekey/project/sources/remote1.expected
index 84b807b42..751816322 100644
--- a/tests/cachekey/project/sources/remote1.expected
+++ b/tests/cachekey/project/sources/remote1.expected
@@ -1 +1 @@
-1fe04362ce6b1e65a0907749a8b11dd2838b2505d2f0c7fee01c005bd43cd63a \ No newline at end of file
+2ab4d2a2490dabafadfc44d95b78f690105e0f0d1cb58665a6a332920172741e \ No newline at end of file
diff --git a/tests/cachekey/project/sources/remote2.expected b/tests/cachekey/project/sources/remote2.expected
index 31e849a82..9b0428eb6 100644
--- a/tests/cachekey/project/sources/remote2.expected
+++ b/tests/cachekey/project/sources/remote2.expected
@@ -1 +1 @@
-105c814f5c88c72e2681a39e1b01a0f2009342afa2b1c1a21c1cc4a664eced29 \ No newline at end of file
+642cbafb3020ab80dae274a983ade81757cf3a1fa4fbba01f621599830be50fd \ No newline at end of file
diff --git a/tests/cachekey/project/sources/tar1.expected b/tests/cachekey/project/sources/tar1.expected
index 7df0789f7..64addbfe1 100644
--- a/tests/cachekey/project/sources/tar1.expected
+++ b/tests/cachekey/project/sources/tar1.expected
@@ -1 +1 @@
-29331729ccb0f67507f9b1a315410d794d62bda6d16ee1fabd927a39808265a7 \ No newline at end of file
+d32bf753f0507f07c8b660ed8fc4428434faf7d07049de92ee203256db0149a3 \ No newline at end of file
diff --git a/tests/cachekey/project/sources/tar2.expected b/tests/cachekey/project/sources/tar2.expected
index 044625e7d..9b4372330 100644
--- a/tests/cachekey/project/sources/tar2.expected
+++ b/tests/cachekey/project/sources/tar2.expected
@@ -1 +1 @@
-37e135a6a6270245ef0fcfda96cada821095f819b57e701f635e83a6d47b83a9 \ No newline at end of file
+41844c597dbffb4f3dcfaae2e5553836816b1b77744db01e47671ab14276795a \ No newline at end of file
diff --git a/tests/cachekey/project/sources/zip1.expected b/tests/cachekey/project/sources/zip1.expected
index c4aca98c4..ac53a32d5 100644
--- a/tests/cachekey/project/sources/zip1.expected
+++ b/tests/cachekey/project/sources/zip1.expected
@@ -1 +1 @@
-5834df0bd373aebd3e74fe57534dfbefbad02a0bfc391ea9b67a6c7c63823ba0 \ No newline at end of file
+a68328d4ad389a4cdc690103bc6b0bb4d2252eb4f738f6cd004645eb478fcf41 \ No newline at end of file
diff --git a/tests/cachekey/project/sources/zip2.expected b/tests/cachekey/project/sources/zip2.expected
index 220f321d9..3da5f68a7 100644
--- a/tests/cachekey/project/sources/zip2.expected
+++ b/tests/cachekey/project/sources/zip2.expected
@@ -1 +1 @@
-7f8bb32b8fd8526c1909fbb239706abd7d1ab96911f17eb9f6e96a6f55833c04 \ No newline at end of file
+30c104c539200d568f9157549dd3c8a15a157cb5c56632638b99986e4edf0576 \ No newline at end of file
diff --git a/tests/cachekey/project/target.expected b/tests/cachekey/project/target.expected
index 3e7cc81db..70dcca363 100644
--- a/tests/cachekey/project/target.expected
+++ b/tests/cachekey/project/target.expected
@@ -1 +1 @@
-f5affaacd3ac724f5415a7a8349c6dca6122841dd7f9769de4f9d6cb7185f9b8 \ No newline at end of file
+29a1252ec30dd6ae73c772381f0eb417e3874c75710d08be819f5715dcaa942b \ No newline at end of file
diff --git a/tests/cachekey/update.py b/tests/cachekey/update.py
index 8cbee444d..d574d07b3 100755
--- a/tests/cachekey/update.py
+++ b/tests/cachekey/update.py
@@ -5,7 +5,7 @@
#
# Simply run without any arguments, from anywhere, e.g.:
#
-# ./tests/cachekey/update.py
+# PYTHONPATH=. ./tests/cachekey/update.py
#
# After this, add any files which were newly created and commit
# the result in order to adjust the cache key test to changed