Commit da735e56 authored by richardmaw-codethink's avatar richardmaw-codethink

_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.
parent 264a57f6
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
# Tristan Maat <tristan.maat@codethink.co.uk> # Tristan Maat <tristan.maat@codethink.co.uk>
import os import os
import shutil
import subprocess import subprocess
from .. import _site
from .. import utils from .. import utils
from ..sandbox import SandboxDummy from ..sandbox import SandboxDummy
...@@ -38,7 +38,7 @@ class Linux(Platform): ...@@ -38,7 +38,7 @@ class Linux(Platform):
self._have_fuse = os.path.exists("/dev/fuse") 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: if bwrap_version is None:
self._bwrap_exists = False self._bwrap_exists = False
...@@ -119,21 +119,3 @@ class Linux(Platform): ...@@ -119,21 +119,3 @@ class Linux(Platform):
output = '' output = ''
return output == 'root' 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("."))
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> # Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
import os import os
import shutil
import subprocess
# #
# Private module declaring some info about where the buildstream # 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') ...@@ -44,3 +46,22 @@ build_all_template = os.path.join(root, 'data', 'build-all.sh.in')
# Module building script template # Module building script template
build_module_template = os.path.join(root, 'data', 'build-module.sh.in') 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("."))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment