diff options
author | milloni <milloni@milloni.org> | 2018-04-01 18:24:40 +0100 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-20 19:50:06 +0900 |
commit | 1b7b51ac2505f7dbc5936e2cdad16b5155122e87 (patch) | |
tree | 8c2b78a7d24c6315f8ea11cd8403b687943c223e /setup.py | |
parent | 5f378fea5d770a5b3730c032d5adca8d5663350c (diff) | |
download | buildstream-1b7b51ac2505f7dbc5936e2cdad16b5155122e87.tar.gz |
setup.py: Assert Bubblewrap version
The required version is 0.1.2 based on the fact that we're using
--hostname and --remount-ro.
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 39 |
1 files changed, 35 insertions, 4 deletions
@@ -20,6 +20,7 @@ import os import shutil +import subprocess import sys if sys.version_info[0] != 3 or sys.version_info[1] < 4: @@ -39,15 +40,45 @@ except ImportError: ################################################################## # Bubblewrap requirements ################################################################## +REQUIRED_BWRAP_MAJOR = 0 +REQUIRED_BWRAP_MINOR = 1 +REQUIRED_BWRAP_PATCH = 2 + + +def exit_bwrap(reason): + print(reason + + "\nBuildStream requires Bubblewrap (bwrap) for" + " sandboxing the build environment. Install it using your package manager" + " (usually bwrap or bubblewrap)") + sys.exit(1) + + +def bwrap_too_old(major, minor, patch): + if major < REQUIRED_BWRAP_MAJOR: + return True + elif major == REQUIRED_BWRAP_MAJOR: + if minor < REQUIRED_BWRAP_MINOR: + return True + elif minor == REQUIRED_BWRAP_MINOR: + return patch < REQUIRED_BWRAP_PATCH + else: + return False + else: + return False + + def assert_bwrap(): platform = os.environ.get('BST_FORCE_BACKEND', '') or sys.platform if platform.startswith('linux'): bwrap_path = shutil.which('bwrap') if not bwrap_path: - print("Bubblewrap not found: BuildStream requires Bubblewrap (bwrap) for" - " sandboxing the build environment. Install it using your package manager" - " (usually bwrap or bubblewrap)") - sys.exit(1) + exit_bwrap("Bubblewrap not found") + + version_bytes = subprocess.check_output([bwrap_path, "--version"]).split()[1] + version_string = str(version_bytes, "utf-8") + major, minor, patch = map(int, version_string.split(".")) + if bwrap_too_old(major, minor, patch): + exit_bwrap("Bubblewrap too old") ################################################################## |