[Notes] [Git][BuildStream/buildstream][danielsilverstone-ct/bwrap-check-runtime-only] 4 commits: sandbox/_sandboxdummy.py: Take a reason for use



Title: GitLab

Daniel pushed to branch danielsilverstone-ct/bwrap-check-runtime-only at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/_platform/darwin.py
    ... ... @@ -34,6 +34,9 @@ class Darwin(Platform):
    34 34
             super().__init__()
    
    35 35
     
    
    36 36
         def create_sandbox(self, *args, **kwargs):
    
    37
    +        kwargs['dummy_reason'] = \
    
    38
    +            "OSXFUSE is not supported and there are no supported sandbox" + \
    
    39
    +            "technologies for OSX at this time"
    
    37 40
             return SandboxDummy(*args, **kwargs)
    
    38 41
     
    
    39 42
         def check_sandbox_config(self, config):
    

  • buildstream/_platform/linux.py
    ... ... @@ -37,15 +37,29 @@ class Linux(Platform):
    37 37
             self._uid = os.geteuid()
    
    38 38
             self._gid = os.getegid()
    
    39 39
     
    
    40
    +        self._have_fuse = os.path.exists("/dev/fuse")
    
    41
    +        self._bwrap_exists = _site.check_bwrap_version(0, 0, 0)
    
    42
    +        self._have_good_bwrap = _site.check_bwrap_version(0, 1, 2)
    
    43
    +
    
    40 44
             self._die_with_parent_available = _site.check_bwrap_version(0, 1, 8)
    
    41 45
     
    
    42
    -        if self._local_sandbox_available():
    
    46
    +        if self._have_fuse and self._have_good_bwrap:
    
    43 47
                 self._user_ns_available = self._check_user_ns_available()
    
    44 48
             else:
    
    45 49
                 self._user_ns_available = False
    
    46 50
     
    
    47 51
         def create_sandbox(self, *args, **kwargs):
    
    48
    -        if not self._local_sandbox_available():
    
    52
    +        if not (self._have_fuse and self._have_good_bwrap):
    
    53
    +            reasons = []
    
    54
    +            if not self._have_fuse:
    
    55
    +                reasons.append("FUSE is unavailable")
    
    56
    +            if not self._have_good_bwrap:
    
    57
    +                if self._bwrap_exists:
    
    58
    +                    reasons.append("`bwrap` is too old (bst needs at least 0.1.2)")
    
    59
    +                else:
    
    60
    +                    reasons.append("`bwrap` executable not found")
    
    61
    +
    
    62
    +            kwargs['dummy_reason'] = " and ".join(reasons)
    
    49 63
                 return SandboxDummy(*args, **kwargs)
    
    50 64
             else:
    
    51 65
                 from ..sandbox._sandboxbwrap import SandboxBwrap
    
    ... ... @@ -66,11 +80,6 @@ class Linux(Platform):
    66 80
         ################################################
    
    67 81
         #              Private Methods                 #
    
    68 82
         ################################################
    
    69
    -    def _local_sandbox_available(self):
    
    70
    -        try:
    
    71
    -            return os.path.exists(utils.get_host_tool('bwrap')) and os.path.exists('/dev/fuse')
    
    72
    -        except utils.ProgramNotFoundError:
    
    73
    -            return False
    
    74 83
     
    
    75 84
         def _check_user_ns_available(self):
    
    76 85
             # Here, lets check if bwrap is able to create user namespaces,
    

  • buildstream/_site.py
    ... ... @@ -78,7 +78,11 @@ def check_bwrap_version(major, minor, patch):
    78 78
             if not bwrap_path:
    
    79 79
                 return False
    
    80 80
             cmd = [bwrap_path, "--version"]
    
    81
    -        version = str(subprocess.check_output(cmd).split()[1], "utf-8")
    
    81
    +        try:
    
    82
    +            version = str(subprocess.check_output(cmd).split()[1], "utf-8")
    
    83
    +        except subprocess.CalledProcessError:
    
    84
    +            # Failure trying to run bubblewrap
    
    85
    +            return False
    
    82 86
             _bwrap_major, _bwrap_minor, _bwrap_patch = map(int, version.split("."))
    
    83 87
     
    
    84 88
         # Check whether the installed version meets the requirements
    

  • buildstream/sandbox/_sandboxdummy.py
    ... ... @@ -23,6 +23,7 @@ from . import Sandbox
    23 23
     class SandboxDummy(Sandbox):
    
    24 24
         def __init__(self, *args, **kwargs):
    
    25 25
             super().__init__(*args, **kwargs)
    
    26
    +        self._reason = kwargs.get("dummy_reason", "no reason given")
    
    26 27
     
    
    27 28
         def run(self, command, flags, *, cwd=None, env=None):
    
    28 29
     
    
    ... ... @@ -37,4 +38,4 @@ class SandboxDummy(Sandbox):
    37 38
                                    "'{}'".format(command[0]),
    
    38 39
                                    reason='missing-command')
    
    39 40
     
    
    40
    -        raise SandboxError("This platform does not support local builds")
    41
    +        raise SandboxError("This platform does not support local builds: {}".format(self._reason))



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