summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-02-27 18:38:19 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-02-28 00:05:53 +0900
commit63eb06bc762b98b34d06b22aac32bf54c78cac26 (patch)
tree1fd5faa03eef1677eff334d77b58da1f45e23a5a
parent1b74422ad9d150f2a6fa6473da5abd0f38949088 (diff)
downloadbuildstream-63eb06bc762b98b34d06b22aac32bf54c78cac26.tar.gz
_project.py: Added 'host-files' shell configuration
A shell configuration allowing one to bind mount files into the shell sandbox. This bumps the BST_FORMAT_VERSION to 2. This is related to #223, and solves #241 (name resolution problems) by making it possible to specify a bind mount for `/etc/resolv.conf` in the project configuration.
-rw-r--r--buildstream/_project.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/buildstream/_project.py b/buildstream/_project.py
index dd5862a3e..dd2183021 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -39,7 +39,7 @@ from ._sourcefactory import SourceFactory
# This version is bumped whenever enhancements are made
# to the `project.conf` format or the core element format.
#
-BST_FORMAT_VERSION = 1
+BST_FORMAT_VERSION = 2
# The separator we use for user specified aliases
_ALIAS_SEPARATOR = ':'
@@ -82,6 +82,7 @@ class Project():
# Shell options
self._shell_command = [] # The default interactive shell command
self._shell_env_inherit = [] # Environment vars to inherit when non-isolated
+ self._shell_host_files = {} # Mapping of sandbox paths to host paths
profile_start(Topics.LOAD_PROJECT, self.directory.replace(os.sep, '-'))
self._load()
@@ -275,12 +276,25 @@ class Project():
# Parse shell options
shell_options = _yaml.node_get(config, Mapping, 'shell', default_value={})
- _yaml.node_validate(shell_options, ['command', 'environment-inherit'])
+ _yaml.node_validate(shell_options, ['command', 'environment-inherit', 'host-files'])
self._shell_command = _yaml.node_get(shell_options, list, 'command',
default_value=['sh', '-i'])
self._shell_env_inherit = _yaml.node_get(shell_options, list, 'environment-inherit',
default_value=[])
+ # Host files is parsed as a list for convenience
+ host_files = _yaml.node_get(shell_options, list, 'host-files', default_value=[])
+ for host_file in host_files:
+ if isinstance(host_file, str):
+ self._shell_host_files[host_file] = host_file
+ else:
+ index = host_files.index(host_file)
+ host_file_desc = _yaml.node_get(shell_options, Mapping, 'host-files', indices=[index])
+ _yaml.node_validate(host_file_desc, ['host', 'sandbox'])
+ host_path = _yaml.node_get(host_file_desc, str, 'host')
+ sandbox_path = _yaml.node_get(host_file_desc, str, 'sandbox')
+ self._shell_host_files[sandbox_path] = host_path
+
# _store_origin()
#
# Helper function to store plugin origins