summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormilloni <milloni@milloni.org>2018-04-01 18:24:40 +0100
committermilloni <milloni@milloni.org>2018-04-11 08:05:58 +0100
commitb38f241be6821ba8154179e7659e8a0ec125fc7d (patch)
treee04430c6ee85634ab86b76985afd6bcb635996ca
parent37d9741401b6c59657c3745f21b468eea1122e62 (diff)
downloadbuildstream-b38f241be6821ba8154179e7659e8a0ec125fc7d.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.
-rwxr-xr-xsetup.py39
1 files changed, 35 insertions, 4 deletions
diff --git a/setup.py b/setup.py
index 8a674b2e0..585443a32 100755
--- a/setup.py
+++ b/setup.py
@@ -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")
##################################################################