Phillip Smyth pushed to branch mac_fixes at BuildStream / buildstream
Commits:
-
6cb11e68
by knownexus at 2018-09-14T12:39:41Z
4 changed files:
- buildstream/_platform/darwin.py
- buildstream/_platform/linux.py
- buildstream/sandbox/__init__.py
- + buildstream/sandbox/_dummysandbox.py
Changes:
| ... | ... | @@ -19,7 +19,7 @@ import os |
| 19 | 19 |
import resource
|
| 20 | 20 |
|
| 21 | 21 |
from .._exceptions import PlatformError
|
| 22 |
-from ..sandbox import SandboxChroot
|
|
| 22 |
+from ..sandbox import SandboxChroot, DummySandbox
|
|
| 23 | 23 |
|
| 24 | 24 |
from . import Platform
|
| 25 | 25 |
|
| ... | ... | @@ -38,7 +38,7 @@ class Darwin(Platform): |
| 38 | 38 |
return self._artifact_cache
|
| 39 | 39 |
|
| 40 | 40 |
def create_sandbox(self, *args, **kwargs):
|
| 41 |
- return SandboxChroot(*args, **kwargs)
|
|
| 41 |
+ return DummySandbox(*args, **kwargs)
|
|
| 42 | 42 |
|
| 43 | 43 |
def get_cpu_count(self, cap=None):
|
| 44 | 44 |
if cap < os.cpu_count():
|
| ... | ... | @@ -24,7 +24,7 @@ from .. import _site |
| 24 | 24 |
from .. import utils
|
| 25 | 25 |
from .._artifactcache.cascache import CASCache
|
| 26 | 26 |
from .._message import Message, MessageType
|
| 27 |
-from ..sandbox import SandboxBwrap
|
|
| 27 |
+from ..sandbox import SandboxBwrap, DummySandbox
|
|
| 28 | 28 |
|
| 29 | 29 |
from . import Platform
|
| 30 | 30 |
|
| ... | ... | @@ -48,10 +48,13 @@ class Linux(Platform): |
| 48 | 48 |
return self._artifact_cache
|
| 49 | 49 |
|
| 50 | 50 |
def create_sandbox(self, *args, **kwargs):
|
| 51 |
- # Inform the bubblewrap sandbox as to whether it can use user namespaces or not
|
|
| 52 |
- kwargs['user_ns_available'] = self._user_ns_available
|
|
| 53 |
- kwargs['die_with_parent_available'] = self._die_with_parent_available
|
|
| 54 |
- return SandboxBwrap(*args, **kwargs)
|
|
| 51 |
+ if not self._local_sandbox_available():
|
|
| 52 |
+ return DummySandbox(*args, **kwargs)
|
|
| 53 |
+ else:
|
|
| 54 |
+ # Inform the bubblewrap sandbox as to whether it can use user namespaces or not
|
|
| 55 |
+ kwargs['user_ns_available'] = self._user_ns_available
|
|
| 56 |
+ kwargs['die_with_parent_available'] = self._die_with_parent_available
|
|
| 57 |
+ return SandboxBwrap(*args, **kwargs)
|
|
| 55 | 58 |
|
| 56 | 59 |
################################################
|
| 57 | 60 |
# Private Methods #
|
| ... | ... | @@ -21,3 +21,4 @@ from .sandbox import Sandbox, SandboxFlags |
| 21 | 21 |
from ._sandboxchroot import SandboxChroot
|
| 22 | 22 |
from ._sandboxbwrap import SandboxBwrap
|
| 23 | 23 |
from ._sandboxremote import SandboxRemote
|
| 24 |
+from ._dummysandbox import DummySandbox
|
| 1 |
+#
|
|
| 2 |
+# Copyright (C) 2017 Codethink Limited
|
|
| 3 |
+#
|
|
| 4 |
+# This program is free software; you can redistribute it and/or
|
|
| 5 |
+# modify it under the terms of the GNU Lesser General Public
|
|
| 6 |
+# License as published by the Free Software Foundation; either
|
|
| 7 |
+# version 2 of the License, or (at your option) any later version.
|
|
| 8 |
+#
|
|
| 9 |
+# This library is distributed in the hope that it will be useful,
|
|
| 10 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 11 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
| 12 |
+# Lesser General Public License for more details.
|
|
| 13 |
+#
|
|
| 14 |
+# You should have received a copy of the GNU Lesser General Public
|
|
| 15 |
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
| 16 |
+#
|
|
| 17 |
+# Authors:
|
|
| 18 |
+ |
|
| 19 |
+from .._exceptions import SandboxError
|
|
| 20 |
+from . import Sandbox
|
|
| 21 |
+ |
|
| 22 |
+ |
|
| 23 |
+class DummySandbox(Sandbox):
|
|
| 24 |
+ def __init__(self, *args, **kwargs):
|
|
| 25 |
+ super().__init__(*args, **kwargs)
|
|
| 26 |
+ |
|
| 27 |
+ def run(self, command, flags, *, cwd=None, env=None):
|
|
| 28 |
+ |
|
| 29 |
+ # Default settings
|
|
| 30 |
+ if cwd is None:
|
|
| 31 |
+ cwd = self._get_work_directory()
|
|
| 32 |
+ |
|
| 33 |
+ if cwd is None:
|
|
| 34 |
+ cwd = '/'
|
|
| 35 |
+ |
|
| 36 |
+ if env is None:
|
|
| 37 |
+ env = self._get_environment()
|
|
| 38 |
+ |
|
| 39 |
+ # Naive getcwd implementations can break when bind-mounts to different
|
|
| 40 |
+ # paths on the same filesystem are present. Letting the command know
|
|
| 41 |
+ # what directory it is in makes it unnecessary to call the faulty
|
|
| 42 |
+ # getcwd.
|
|
| 43 |
+ env['PWD'] = cwd
|
|
| 44 |
+ |
|
| 45 |
+ if not self._has_command(command[0], env):
|
|
| 46 |
+ raise SandboxError("Staged artifacts do not provide command "
|
|
| 47 |
+ "'{}'".format(command[0]),
|
|
| 48 |
+ reason='missing-command')
|
|
| 49 |
+ |
|
| 50 |
+ raise SandboxError("This platform does not support local builds")
|
