[Notes] [Git][BuildStream/buildstream][mac_fixes] Adding Dummy sandbox and nolocal platform



Title: GitLab

Phillip Smyth pushed to branch mac_fixes at BuildStream / buildstream

Commits:

7 changed files:

Changes:

  • buildstream/_platform/darwin.py
    ... ... @@ -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():
    

  • buildstream/_platform/linux.py
    ... ... @@ -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                 #
    

  • buildstream/_platform/platform.py
    ... ... @@ -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
     
    

  • buildstream/sandbox/__init__.py
    ... ... @@ -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

  • buildstream/sandbox/_dummysandbox.py
    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 .._exceptions import SandboxError
    
    19
    +
    
    20
    +
    
    21
    +class DummySandbox():
    
    22
    +    def run(self):
    
    23
    +        raise SandboxError("Sandboxes are not supported on this platform")

  • tests/artifactcache/cache_size.py
    ... ... @@ -5,6 +5,7 @@ from buildstream import _yaml
    5 5
     from buildstream._artifactcache import CACHE_SIZE_FILE
    
    6 6
     
    
    7 7
     from tests.testutils import cli, create_element_size
    
    8
    +from tests.testutils.site import HAS_FUSE
    
    8 9
     
    
    9 10
     # XXX: Currently lacking:
    
    10 11
     #      * A way to check whether it's faster to read cache size on
    
    ... ... @@ -21,7 +22,7 @@ def create_project(project_dir):
    21 22
         element_name = "test.bst"
    
    22 23
         create_element_size(element_name, project_dir, ".", [], 1024)
    
    23 24
     
    
    24
    -
    
    25
    +@pytest.mark.skipif(not HAS_FUSE, reason='Only available on systems with FUSE')
    
    25 26
     def test_cache_size_roundtrip(cli, tmpdir):
    
    26 27
         # Builds (to put files in the cache), then invokes buildstream again
    
    27 28
         # to check nothing breaks
    

  • tests/testutils/site.py
    ... ... @@ -49,3 +49,4 @@ except ImportError:
    49 49
         HAVE_ARPY = False
    
    50 50
     
    
    51 51
     IS_LINUX = os.getenv('BST_FORCE_BACKEND', sys.platform).startswith('linux')
    
    52
    +HAS_FUSE = os.path.exists('/dev/fuse')



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]