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-29 16:49:15 +0200
commitf4d4a7c6f73a4a705c91d0628bf62916eace0541 (patch)
tree735258f5b730d83be3dde235bcb59a2261052c52
parentb794f058c0ff2709ae6a382fff5744a98da97c76 (diff)
downloadbuildstream-f4d4a7c6f73a4a705c91d0628bf62916eace0541.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')