diff options
author | Jürg Billeter <j@bitron.ch> | 2020-06-03 11:59:55 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2020-06-03 13:49:39 +0200 |
commit | cbf490426112dabe18f0dca3af00863235eb1e3f (patch) | |
tree | 8ba148a0ba1461d8a6cf254136ba5eba5e08d7ef | |
parent | 07275d01416b204bd578c1c3617fcbed8b6e30ed (diff) | |
download | buildstream-cbf490426112dabe18f0dca3af00863235eb1e3f.tar.gz |
Drop Platform subclasses and BST_FORCE_BACKENDjuerg/sandbox-drop-bwrap
With the use of buildbox-run on all platforms, there is no longer any
platform-specific code in the Platform subclasses.
-rw-r--r-- | src/buildstream/_platform/darwin.py | 36 | ||||
-rw-r--r-- | src/buildstream/_platform/fallback.py | 37 | ||||
-rw-r--r-- | src/buildstream/_platform/linux.py | 45 | ||||
-rw-r--r-- | src/buildstream/_platform/platform.py | 46 | ||||
-rw-r--r-- | src/buildstream/_platform/win32.py | 35 | ||||
-rw-r--r-- | src/buildstream/testing/_utils/site.py | 2 | ||||
-rw-r--r-- | tox.ini | 1 |
7 files changed, 18 insertions, 184 deletions
diff --git a/src/buildstream/_platform/darwin.py b/src/buildstream/_platform/darwin.py deleted file mode 100644 index 00bca2c4c..000000000 --- a/src/buildstream/_platform/darwin.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright (C) 2017 Codethink Limited -# Copyright (C) 2018 Bloomberg Finance LP -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library. If not, see <http://www.gnu.org/licenses/>. - -from ..sandbox import SandboxDummy - -from .platform import Platform - - -class Darwin(Platform): - @staticmethod - def _check_dummy_sandbox_config(config): - pass - - @staticmethod - def _create_dummy_sandbox(*args, **kwargs): - kwargs["dummy_reason"] = "There are no supported sandbox technologies for MacOS at this time" - return SandboxDummy(*args, **kwargs) - - def _setup_dummy_sandbox(self): - self.check_sandbox_config = Darwin._check_dummy_sandbox_config - self.create_sandbox = Darwin._create_dummy_sandbox - return True diff --git a/src/buildstream/_platform/fallback.py b/src/buildstream/_platform/fallback.py deleted file mode 100644 index d80ac8fde..000000000 --- a/src/buildstream/_platform/fallback.py +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright (C) 2018 Bloomberg Finance LP -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library. If not, see <http://www.gnu.org/licenses/>. - -from ..sandbox import SandboxDummy - -from .platform import Platform - - -class Fallback(Platform): - def _check_dummy_sandbox_config(self, config): - pass - - def _create_dummy_sandbox(self, *args, **kwargs): - kwargs["dummy_reason"] = ( - "FallBack platform only implements dummy sandbox, " - "Buildstream may be having issues correctly detecting your platform, " - "platform can be forced with BST_FORCE_BACKEND" - ) - return SandboxDummy(*args, **kwargs) - - def _setup_dummy_sandbox(self): - self.check_sandbox_config = self._check_dummy_sandbox_config - self.create_sandbox = self._create_dummy_sandbox - return True diff --git a/src/buildstream/_platform/linux.py b/src/buildstream/_platform/linux.py deleted file mode 100644 index c6065b416..000000000 --- a/src/buildstream/_platform/linux.py +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (C) 2017 Codethink Limited -# Copyright (C) 2018 Bloomberg Finance LP -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library. If not, see <http://www.gnu.org/licenses/>. -# -# Authors: -# Tristan Maat <tristan.maat@codethink.co.uk> - -from ..sandbox import SandboxDummy - -from .platform import Platform - - -class Linux(Platform): - - ################################################ - # Private Methods # - ################################################ - - # Dummy sandbox methods - @staticmethod - def _check_dummy_sandbox_config(config): - return True - - def _create_dummy_sandbox(self, *args, **kwargs): - dummy_reasons = " and ".join(self.dummy_reasons) - kwargs["dummy_reason"] = dummy_reasons - return SandboxDummy(*args, **kwargs) - - def _setup_dummy_sandbox(self): - self.check_sandbox_config = Linux._check_dummy_sandbox_config - self.create_sandbox = self._create_dummy_sandbox - return True diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py index 8a1794cbf..f46043cbf 100644 --- a/src/buildstream/_platform/platform.py +++ b/src/buildstream/_platform/platform.py @@ -21,11 +21,11 @@ import multiprocessing import os import platform -import sys import psutil from .._exceptions import PlatformError, ImplError, SandboxError +from ..sandbox import SandboxDummy from .. import utils @@ -58,29 +58,7 @@ class Platform: @classmethod def create_instance(cls): - if os.getenv("BST_FORCE_BACKEND"): - backend = os.getenv("BST_FORCE_BACKEND") - elif sys.platform.startswith("darwin"): - backend = "darwin" - elif sys.platform.startswith("linux"): - backend = "linux" - elif sys.platform == "win32": - backend = "win32" - else: - backend = "fallback" - - if backend == "linux": - from .linux import Linux as PlatformImpl # pylint: disable=cyclic-import - elif backend == "darwin": - from .darwin import Darwin as PlatformImpl # pylint: disable=cyclic-import - elif backend == "win32": - from .win32 import Win32 as PlatformImpl # pylint: disable=cyclic-import - elif backend == "fallback": - from .fallback import Fallback as PlatformImpl # pylint: disable=cyclic-import - else: - raise PlatformError("No such platform: '{}'".format(backend)) - - return PlatformImpl() + return Platform() def get_cpu_count(self, cap=None): # `psutil.Process.cpu_affinity()` is not available on all platforms. @@ -204,11 +182,6 @@ class Platform: "Platform {platform} does not implement check_sandbox_config()".format(platform=type(self).__name__) ) - def _setup_dummy_sandbox(self): - raise ImplError( - "Platform {platform} does not implement _setup_dummy_sandbox()".format(platform=type(self).__name__) - ) - # Buildbox run sandbox methods def _check_sandbox_config_buildboxrun(self, config): from ..sandbox._sandboxbuildboxrun import SandboxBuildBoxRun # pylint: disable=cyclic-import @@ -228,3 +201,18 @@ class Platform: self.check_sandbox_config = self._check_sandbox_config_buildboxrun self.create_sandbox = self._create_buildboxrun_sandbox return True + + # Dummy sandbox methods + @staticmethod + def _check_dummy_sandbox_config(config): + pass + + def _create_dummy_sandbox(self, *args, **kwargs): + dummy_reasons = " and ".join(self.dummy_reasons) + kwargs["dummy_reason"] = dummy_reasons + return SandboxDummy(*args, **kwargs) + + def _setup_dummy_sandbox(self): + self.check_sandbox_config = Platform._check_dummy_sandbox_config + self.create_sandbox = self._create_dummy_sandbox + return True diff --git a/src/buildstream/_platform/win32.py b/src/buildstream/_platform/win32.py deleted file mode 100644 index 5045c9e3e..000000000 --- a/src/buildstream/_platform/win32.py +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (C) 2019 Bloomberg Finance LP -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library. If not, see <http://www.gnu.org/licenses/>. - -from ..sandbox import SandboxDummy - -from .platform import Platform - - -class Win32(Platform): - @staticmethod - def _check_dummy_sandbox_config(config): - pass - - @staticmethod - def _create_dummy_sandbox(*args, **kwargs): - kwargs["dummy_reason"] = "There are no supported sandbox technologies for Win32 at this time." - return SandboxDummy(*args, **kwargs) - - def _setup_dummy_sandbox(self): - self.check_sandbox_config = Win32._check_dummy_sandbox_config - self.create_sandbox = Win32._create_dummy_sandbox - return True diff --git a/src/buildstream/testing/_utils/site.py b/src/buildstream/testing/_utils/site.py index 577896fe5..d8ace859b 100644 --- a/src/buildstream/testing/_utils/site.py +++ b/src/buildstream/testing/_utils/site.py @@ -54,7 +54,7 @@ casd_path = utils.get_host_tool("buildbox-casd") CASD_SEPARATE_USER = bool(os.stat(casd_path).st_mode & stat.S_ISUID) del casd_path -IS_LINUX = os.getenv("BST_FORCE_BACKEND", sys.platform).startswith("linux") +IS_LINUX = sys.platform.startswith("linux") IS_WINDOWS = os.name == "nt" MACHINE_ARCH = Platform.get_host_arch() @@ -50,7 +50,6 @@ deps = passenv = ARTIFACT_CACHE_SERVICE BST_CAS_STAGING_ROOT - BST_FORCE_BACKEND BST_FORCE_START_METHOD GI_TYPELIB_PATH INTEGRATION_CACHE |