diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2018-11-08 16:57:08 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2018-11-14 13:30:34 +0000 |
commit | da735e56e77846f6ea6e80809fc0bd5de7b3b657 (patch) | |
tree | 556777b873b50421ff6fca28f2cbe98d571321b3 | |
parent | 264a57f6c0f232b957a3953ca336fe3976037097 (diff) | |
download | buildstream-da735e56e77846f6ea6e80809fc0bd5de7b3b657.tar.gz |
_platform/linux.py: Move get_bwrap_version into _site.py
It's inconvenient to have to create a Linux platform to parse the bwrap version
and we want to get the version in a consistent manner.
-rw-r--r-- | buildstream/_platform/linux.py | 22 | ||||
-rw-r--r-- | buildstream/_site.py | 21 |
2 files changed, 23 insertions, 20 deletions
diff --git a/buildstream/_platform/linux.py b/buildstream/_platform/linux.py index afdf81c79..be1e9d933 100644 --- a/buildstream/_platform/linux.py +++ b/buildstream/_platform/linux.py @@ -18,9 +18,9 @@ # Tristan Maat <tristan.maat@codethink.co.uk> import os -import shutil import subprocess +from .. import _site from .. import utils from ..sandbox import SandboxDummy @@ -38,7 +38,7 @@ class Linux(Platform): self._have_fuse = os.path.exists("/dev/fuse") - bwrap_version = self._get_bwrap_version() + bwrap_version = _site.get_bwrap_version() if bwrap_version is None: self._bwrap_exists = False @@ -119,21 +119,3 @@ class Linux(Platform): output = '' return output == 'root' - - def _get_bwrap_version(self): - # Get the current bwrap version - # - # returns None if no bwrap was found - # otherwise returns a tuple of 3 int: major, minor, patch - bwrap_path = shutil.which('bwrap') - - if not bwrap_path: - return None - - cmd = [bwrap_path, "--version"] - try: - version = str(subprocess.check_output(cmd).split()[1], "utf-8") - except subprocess.CalledProcessError: - return None - - return tuple(int(x) for x in version.split(".")) diff --git a/buildstream/_site.py b/buildstream/_site.py index d64390b5d..8940fa34a 100644 --- a/buildstream/_site.py +++ b/buildstream/_site.py @@ -18,6 +18,8 @@ # Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> import os +import shutil +import subprocess # # Private module declaring some info about where the buildstream @@ -44,3 +46,22 @@ build_all_template = os.path.join(root, 'data', 'build-all.sh.in') # Module building script template build_module_template = os.path.join(root, 'data', 'build-module.sh.in') + + +def get_bwrap_version(): + # Get the current bwrap version + # + # returns None if no bwrap was found + # otherwise returns a tuple of 3 int: major, minor, patch + bwrap_path = shutil.which('bwrap') + + if not bwrap_path: + return None + + cmd = [bwrap_path, "--version"] + try: + version = str(subprocess.check_output(cmd).split()[1], "utf-8") + except subprocess.CalledProcessError: + return None + + return tuple(int(x) for x in version.split(".")) |