summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-08-29 16:22:40 +0200
committerJürg Billeter <j@bitron.ch>2019-08-30 08:16:12 +0000
commitf2c3f8eb0db188caac6991632c4453c39b42e84c (patch)
treef9c43f5dd6e1cfe8f1beaa892e93f65906e9954c
parent67f1dff40ca96d983fee631c59594797d20366d1 (diff)
downloadbuildstream-f2c3f8eb0db188caac6991632c4453c39b42e84c.tar.gz
_context.py: Ensure paths in user configuration are absolute
Relative paths don't make sense in user configuration. The exception is workspacedir where `.` is useful as it will be combined with the name specified on the command line.
-rw-r--r--src/buildstream/_context.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index c6cde4003..b70f80d73 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -242,6 +242,12 @@ class Context():
path = os.path.normpath(path)
setattr(self, directory, path)
+ # Relative paths don't make sense in user configuration. The exception is
+ # workspacedir where `.` is useful as it will be combined with the name
+ # specified on the command line.
+ if not os.path.isabs(path) and not (directory == 'workspacedir' and path == '.'):
+ raise LoadError("{} must be an absolute path".format(directory), LoadErrorReason.INVALID_DATA)
+
# add directories not set by users
self.tmpdir = os.path.join(self.cachedir, 'tmp')
self.casdir = os.path.join(self.cachedir, 'cas')