summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan van Berkom <tristan.vanberkom@codethink.co.uk>2020-05-28 16:10:21 +0900
committerbst-marge-bot <marge-bot@buildstream.build>2020-05-29 16:43:52 +0000
commitf5c9a4ed5f9ebc579250c1a35aca77b0afb47e2d (patch)
tree34c2a8b65122ec8dc789e7a9c891b2ca511182b7
parente0716d781920886ac0493577442667e0ce495bcb (diff)
downloadbuildstream-f5c9a4ed5f9ebc579250c1a35aca77b0afb47e2d.tar.gz
_context.py: Support parallel installations of BuildStream
Allow users to keep separate buildstream.conf files in their XDG_CONFIG_HOME for separate BuildStream versions, in case they have BuildStream 1 and 2 installed. Like other major version safeguards and warnings, this new addition also supports future major versions if they should appear.
-rw-r--r--src/buildstream/_context.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index 090b3e0bc..19e0781c1 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -219,9 +219,17 @@ class Context:
# a $XDG_CONFIG_HOME/buildstream.conf file
#
if not config:
- default_config = os.path.join(os.environ["XDG_CONFIG_HOME"], "buildstream.conf")
- if os.path.exists(default_config):
- config = default_config
+ #
+ # Support parallel installations of BuildStream by first
+ # trying a (major point) version specific configuration file
+ # and then falling back to buildstream.conf.
+ #
+ major_version, _ = utils._get_bst_api_version()
+ for config_filename in ("buildstream{}.conf".format(major_version), "buildstream.conf"):
+ default_config = os.path.join(os.environ["XDG_CONFIG_HOME"], config_filename)
+ if os.path.exists(default_config):
+ config = default_config
+ break
# Load default config
#