From da735e56e77846f6ea6e80809fc0bd5de7b3b657 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 8 Nov 2018 16:57:08 +0000 Subject: _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. --- buildstream/_platform/linux.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'buildstream/_platform') 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 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(".")) -- cgit v1.2.1