Phillip Smyth pushed to branch mac_fixes at BuildStream / buildstream
Commits:
-
42129830
by knownexus at 2018-09-11T14:37:16Z
3 changed files:
- + buildstream/_platform/nolocal.py
- buildstream/_platform/platform.py
- + buildstream/sandbox/_dummysandbox.py
Changes:
| 1 |
+#
|
|
| 2 |
+# Copyright (C) 2017 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 |
+import os
|
|
| 19 |
+import resource
|
|
| 20 |
+ |
|
| 21 |
+from .._exceptions import PlatformError
|
|
| 22 |
+from ..sandbox import DummySandbox
|
|
| 23 |
+ |
|
| 24 |
+from . import Platform
|
|
| 25 |
+ |
|
| 26 |
+ |
|
| 27 |
+class Nolocal(Platform):
|
|
| 28 |
+ |
|
| 29 |
+ if sys.platform.startswith('Darwin'):
|
|
| 30 |
+ # This value comes from OPEN_MAX in syslimits.h
|
|
| 31 |
+ OPEN_MAX = 10240
|
|
| 32 |
+ else:
|
|
| 33 |
+ OPEN_MAX = None
|
|
| 34 |
+ |
|
| 35 |
+ def __init__(self, context):
|
|
| 36 |
+ |
|
| 37 |
+ super().__init__(context)
|
|
| 38 |
+ |
|
| 39 |
+ @property
|
|
| 40 |
+ def artifactcache(self):
|
|
| 41 |
+ return self._artifact_cache
|
|
| 42 |
+ |
|
| 43 |
+ def create_sandbox(self, *args, **kwargs):
|
|
| 44 |
+ DummySandbox.run()
|
|
| 45 |
+ |
|
| 46 |
+ def get_cpu_count(self, cap=None):
|
|
| 47 |
+ if cap < os.cpu_count():
|
|
| 48 |
+ return cap
|
|
| 49 |
+ else:
|
|
| 50 |
+ return os.cpu_count()
|
|
| 51 |
+ |
|
| 52 |
+ def set_resources(self, soft_limit=OPEN_MAX, hard_limit=None):
|
|
| 53 |
+ super().set_resources(soft_limit)
|
| ... | ... | @@ -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 |
|
| 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 _sandboxchroot.py
|
|
| 19 |
+ |
|
| 20 |
+class DummySandbox(SandboxChroot)
|
|
| 21 |
+ def __init__(self, *args, **kwargs):
|
|
| 22 |
+ super().__init__(*args, **kwargs)
|
|
| 23 |
+ |
|
| 24 |
+ def run(self):
|
|
| 25 |
+ raise ImplError("This platform does not support Sandboxing"
|
