Loading buildstream/buildelement.py +12 −0 Original line number Original line Diff line number Diff line Loading @@ -195,6 +195,18 @@ class BuildElement(Element): if exitcode != 0: if exitcode != 0: raise ElementError("Command '{}' failed with exitcode {}".format(cmd, exitcode)) raise ElementError("Command '{}' failed with exitcode {}".format(cmd, exitcode)) # %{install-root}/%{build-root} should normally not be written # to - indicates a potential error, especially with a later # `git clone`. staged_build = os.path.join(self.get_variable('install-root'), self.get_variable('build-root')) if os.path.isdir(staged_build) and os.listdir(staged_build): self.warn("Writing to %{install-root}/%{build-root}.", detail="Writing to this directory may cause " + "issues, especially when subsequent elements " + "have git sources.") # Return the payload, this is configurable but is generally # Return the payload, this is configurable but is generally # always the /buildstream/install directory # always the /buildstream/install directory return self.get_variable('install-root') return self.get_variable('install-root') Loading buildstream/element.py +18 −1 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import re import stat import stat import copy import copy import inspect import inspect import pathlib from collections import Mapping from collections import Mapping from contextlib import contextmanager from contextlib import contextmanager from enum import Enum from enum import Enum Loading Loading @@ -383,7 +384,23 @@ class Element(Plugin): if path is None \ if path is None \ else os.path.join(basedir, path.lstrip(os.sep)) else os.path.join(basedir, path.lstrip(os.sep)) files = self.__compute_splits(include, exclude, orphans) files = list(self.__compute_splits(include, exclude, orphans)) # Check and warn if files are written to build-root or # install-root, since this could cause issues further down # the line (git will fail to checkout into build-root, for # example). paths = [pathlib.PurePath(self.get_variable('build-root').lstrip(os.sep)), pathlib.PurePath(self.get_variable('install-root').lstrip(os.sep))] for f in files: for p in paths: if p != pathlib.PurePath('.') and p in pathlib.PurePath(f).parents: self.warn("{} wrote to {}.".format(self.name, p)) break else: continue break result = utils.link_files(artifact, stagedir, files=files) result = utils.link_files(artifact, stagedir, files=files) return result return result Loading tests/frontend/buildcheckout.py +11 −0 Original line number Original line Diff line number Diff line Loading @@ -87,3 +87,14 @@ def test_fetch_build_checkout(cli, tmpdir, datafiles, strict, kind): # Check that the pony.h include from files/dev-files exists # Check that the pony.h include from files/dev-files exists filename = os.path.join(checkout, 'usr', 'include', 'pony.h') filename = os.path.join(checkout, 'usr', 'include', 'pony.h') assert os.path.exists(filename) assert os.path.exists(filename) @pytest.mark.datafiles(DATA_DIR) def test_install_to_build(cli, tmpdir, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename) element = 'installed-to-build.bst' result = cli.run(project=project, args=strict_args(['build', element], True)) assert result.exit_code == 0 assert "WARNING install-to-build.bst wrote to buildstream/build." in result.output tests/frontend/project/elements/install-to-build.bst 0 → 100644 +4 −0 Original line number Original line Diff line number Diff line kind: import sources: - kind: local path: files/build-files tests/frontend/project/elements/installed-to-build.bst 0 → 100644 +8 −0 Original line number Original line Diff line number Diff line kind: compose depends: - filename: install-to-build.bst type: build config: integrate: False Loading
buildstream/buildelement.py +12 −0 Original line number Original line Diff line number Diff line Loading @@ -195,6 +195,18 @@ class BuildElement(Element): if exitcode != 0: if exitcode != 0: raise ElementError("Command '{}' failed with exitcode {}".format(cmd, exitcode)) raise ElementError("Command '{}' failed with exitcode {}".format(cmd, exitcode)) # %{install-root}/%{build-root} should normally not be written # to - indicates a potential error, especially with a later # `git clone`. staged_build = os.path.join(self.get_variable('install-root'), self.get_variable('build-root')) if os.path.isdir(staged_build) and os.listdir(staged_build): self.warn("Writing to %{install-root}/%{build-root}.", detail="Writing to this directory may cause " + "issues, especially when subsequent elements " + "have git sources.") # Return the payload, this is configurable but is generally # Return the payload, this is configurable but is generally # always the /buildstream/install directory # always the /buildstream/install directory return self.get_variable('install-root') return self.get_variable('install-root') Loading
buildstream/element.py +18 −1 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import re import stat import stat import copy import copy import inspect import inspect import pathlib from collections import Mapping from collections import Mapping from contextlib import contextmanager from contextlib import contextmanager from enum import Enum from enum import Enum Loading Loading @@ -383,7 +384,23 @@ class Element(Plugin): if path is None \ if path is None \ else os.path.join(basedir, path.lstrip(os.sep)) else os.path.join(basedir, path.lstrip(os.sep)) files = self.__compute_splits(include, exclude, orphans) files = list(self.__compute_splits(include, exclude, orphans)) # Check and warn if files are written to build-root or # install-root, since this could cause issues further down # the line (git will fail to checkout into build-root, for # example). paths = [pathlib.PurePath(self.get_variable('build-root').lstrip(os.sep)), pathlib.PurePath(self.get_variable('install-root').lstrip(os.sep))] for f in files: for p in paths: if p != pathlib.PurePath('.') and p in pathlib.PurePath(f).parents: self.warn("{} wrote to {}.".format(self.name, p)) break else: continue break result = utils.link_files(artifact, stagedir, files=files) result = utils.link_files(artifact, stagedir, files=files) return result return result Loading
tests/frontend/buildcheckout.py +11 −0 Original line number Original line Diff line number Diff line Loading @@ -87,3 +87,14 @@ def test_fetch_build_checkout(cli, tmpdir, datafiles, strict, kind): # Check that the pony.h include from files/dev-files exists # Check that the pony.h include from files/dev-files exists filename = os.path.join(checkout, 'usr', 'include', 'pony.h') filename = os.path.join(checkout, 'usr', 'include', 'pony.h') assert os.path.exists(filename) assert os.path.exists(filename) @pytest.mark.datafiles(DATA_DIR) def test_install_to_build(cli, tmpdir, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename) element = 'installed-to-build.bst' result = cli.run(project=project, args=strict_args(['build', element], True)) assert result.exit_code == 0 assert "WARNING install-to-build.bst wrote to buildstream/build." in result.output
tests/frontend/project/elements/install-to-build.bst 0 → 100644 +4 −0 Original line number Original line Diff line number Diff line kind: import sources: - kind: local path: files/build-files
tests/frontend/project/elements/installed-to-build.bst 0 → 100644 +8 −0 Original line number Original line Diff line number Diff line kind: compose depends: - filename: install-to-build.bst type: build config: integrate: False