Phillip Smyth pushed to branch mac_fixes at BuildStream / buildstream
Commits:
-
f6e413f7
by knownexus at 2018-09-13T09:12:40Z
5 changed files:
- buildstream/_platform/darwin.py
- buildstream/_platform/linux.py
- buildstream/_platform/platform.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,10 @@ 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 |
+ if os.path.exists('/dev/fuse'):
|
|
42 |
+ return SandboxChroot(*args, **kwargs)
|
|
43 |
+ else:
|
|
44 |
+ DummySandbox.run()
|
|
42 | 45 |
|
43 | 46 |
def get_cpu_count(self, cap=None):
|
44 | 47 |
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 (os.path.exists(utils.get_host_tool('bwrap')) and os.path.exists('/dev/fuse')):
|
|
52 |
+ DummySandbox.run()
|
|
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 #
|
... | ... | @@ -54,6 +54,8 @@ class Platform(): |
54 | 54 |
backend = 'linux'
|
55 | 55 |
elif sys.platform.startswith('darwin'):
|
56 | 56 |
backend = 'darwin'
|
57 |
+ elif not (os.path.exists(utils.get_host_tool('bwrap')) and os.path.exists('/dev/fuse')):
|
|
58 |
+ backend = 'no_local'
|
|
57 | 59 |
else:
|
58 | 60 |
backend = 'unix'
|
59 | 61 |
|
... | ... | @@ -63,6 +65,8 @@ class Platform(): |
63 | 65 |
from .darwin import Darwin as PlatformImpl
|
64 | 66 |
elif backend == 'unix':
|
65 | 67 |
from .unix import Unix as PlatformImpl
|
68 |
+ elif backend == 'no_local':
|
|
69 |
+ from .nolocal import Nolocal as PlatformImpl
|
|
66 | 70 |
else:
|
67 | 71 |
raise PlatformError("No such platform: '{}'".format(backend))
|
68 | 72 |
|
... | ... | @@ -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) 2018 Codethink Limited
|
|
3 |
+# Copyright (C) 2018 Bloomberg Finance LP
|
|
4 |
+#
|
|
5 |
+# This program is free software; you can redistribute it and/or
|
|
6 |
+# modify it under the terms of the GNU Lesser General Public
|
|
7 |
+# License as published by the Free Software Foundation; either
|
|
8 |
+# version 2 of the License, or (at your option) any later version.
|
|
9 |
+#
|
|
10 |
+# This library is distributed in the hope that it will be useful,
|
|
11 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13 |
+# Lesser General Public License for more details.
|
|
14 |
+#
|
|
15 |
+# You should have received a copy of the GNU Lesser General Public
|
|
16 |
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
+ |
|
18 |
+from . import Sandbox
|
|
19 |
+from .._exceptions import SandboxError
|
|
20 |
+ |
|
21 |
+ |
|
22 |
+class DummySandbox(Sandbox):
|
|
23 |
+ def __init__(self, *args, **kwargs):
|
|
24 |
+ super().__init__(*args, **kwargs)
|
|
25 |
+ |
|
26 |
+ def run(self):
|
|
27 |
+ raise SandboxError("Sandboxes are not supported on this platform")
|