diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2018-11-08 12:06:13 +0100 |
---|---|---|
committer | Valentin David <valentin.david@codethink.co.uk> | 2018-11-08 12:08:28 +0100 |
commit | 9e398d8b38592afe70328594582a235fe954c49d (patch) | |
tree | 197e61d3ada900a15cf7d1cb033f211b26d2fe4a | |
parent | f116b9b7e4c804c04816ca3078e5849d1f0bd856 (diff) | |
download | buildstream-valentindavid/fix-script-install-root.tar.gz |
Fix bug with root mounted as non-artifact in script plugin.valentindavid/fix-script-install-root
The issue was introduced by 6ccfab0b1b25990e406446d5cbe5aee83a5e158a.
-rw-r--r-- | buildstream/scriptelement.py | 7 | ||||
-rw-r--r-- | tests/integration/project/elements/script/marked-tmpdir.bst | 12 | ||||
-rw-r--r-- | tests/integration/project/elements/script/no-tmpdir.bst | 12 | ||||
-rw-r--r-- | tests/integration/project/elements/script/tmpdir.bst | 10 | ||||
-rw-r--r-- | tests/integration/script.py | 9 |
5 files changed, 48 insertions, 2 deletions
diff --git a/buildstream/scriptelement.py b/buildstream/scriptelement.py index e9ad60c37..d2165ce32 100644 --- a/buildstream/scriptelement.py +++ b/buildstream/scriptelement.py @@ -202,7 +202,7 @@ class ScriptElement(Element): sandbox.set_environment(self.get_environment()) # Tell the sandbox to mount the install root - directories = {'/': False} + directories = {self.__install_root: False} # Mark the artifact directories in the layout for item in self.__layout: @@ -211,7 +211,10 @@ class ScriptElement(Element): directories[destination] = item['element'] or was_artifact for directory, artifact in directories.items(): - sandbox.mark_directory(directory, artifact=artifact) + # Root does not need to be marked as it is always mounted + # with artifact (unless explicitly marked non-artifact) + if directory != '/': + sandbox.mark_directory(directory, artifact=artifact) def stage(self, sandbox): diff --git a/tests/integration/project/elements/script/marked-tmpdir.bst b/tests/integration/project/elements/script/marked-tmpdir.bst new file mode 100644 index 000000000..506cdd5f4 --- /dev/null +++ b/tests/integration/project/elements/script/marked-tmpdir.bst @@ -0,0 +1,12 @@ +kind: compose + +depends: +- filename: base.bst + type: build + +public: + bst: + split-rules: + remove: + - "/tmp/**" + - "/tmp" diff --git a/tests/integration/project/elements/script/no-tmpdir.bst b/tests/integration/project/elements/script/no-tmpdir.bst new file mode 100644 index 000000000..5c24e3cff --- /dev/null +++ b/tests/integration/project/elements/script/no-tmpdir.bst @@ -0,0 +1,12 @@ +kind: filter + +depends: +- filename: script/marked-tmpdir.bst + type: build + +config: + exclude: + - remove + include-orphans: True + + diff --git a/tests/integration/project/elements/script/tmpdir.bst b/tests/integration/project/elements/script/tmpdir.bst new file mode 100644 index 000000000..685a694ea --- /dev/null +++ b/tests/integration/project/elements/script/tmpdir.bst @@ -0,0 +1,10 @@ +kind: script + +depends: +- filename: script/no-tmpdir.bst + type: build + +config: + commands: + - | + mkdir -p /tmp/blah diff --git a/tests/integration/script.py b/tests/integration/script.py index 67bdd9642..422cd8e2a 100644 --- a/tests/integration/script.py +++ b/tests/integration/script.py @@ -184,3 +184,12 @@ def test_regression_cache_corruption(cli, tmpdir, datafiles): with open(os.path.join(checkout_after, 'canary')) as f: assert f.read() == 'alive\n' + + +@pytest.mark.datafiles(DATA_DIR) +def test_regression_tmpdir(cli, tmpdir, datafiles): + project = str(datafiles) + element_name = 'script/tmpdir.bst' + + res = cli.run(project=project, args=['build', element_name]) + assert res.exit_code == 0 |