[Notes] [Git][BuildStream/buildstream][raoul/775-execution-environment-reqs] _platform: Add checks for os and architecture



Title: GitLab

Raoul Hidalgo Charman pushed to branch raoul/775-execution-environment-reqs at BuildStream / buildstream

Commits:

2 changed files:

Changes:

  • buildstream/_platform/linux.py
    ... ... @@ -25,6 +25,7 @@ from .. import utils
    25 25
     from ..sandbox import SandboxDummy
    
    26 26
     
    
    27 27
     from . import Platform
    
    28
    +from .._exceptions import PlatformError
    
    28 29
     
    
    29 30
     
    
    30 31
     class Linux(Platform):
    
    ... ... @@ -71,11 +72,19 @@ class Linux(Platform):
    71 72
     
    
    72 73
             if self._user_ns_available:
    
    73 74
                 # User namespace support allows arbitrary build UID/GID settings.
    
    74
    -            return True
    
    75
    -        else:
    
    75
    +            pass
    
    76
    +        elif (config.build_uid != self._uid or config.build_gid != self._gid):
    
    76 77
                 # Without user namespace support, the UID/GID in the sandbox
    
    77 78
                 # will match the host UID/GID.
    
    78
    -            return config.build_uid == self._uid and config.build_gid == self._gid
    
    79
    +            return False
    
    80
    +
    
    81
    +        # We can't do builds for another host or architecture
    
    82
    +        if config.build_os != self.get_host_os():
    
    83
    +            raise PlatformError("Configured OS and host OS don't match.")
    
    84
    +        elif config.build_arch != self.get_host_arch():
    
    85
    +            raise PlatformError("Configured architecture and host architecture don't match.")
    
    86
    +
    
    87
    +        return True
    
    79 88
     
    
    80 89
         ################################################
    
    81 90
         #              Private Methods                 #
    

  • buildstream/_platform/unix.py
    ... ... @@ -44,4 +44,13 @@ class Unix(Platform):
    44 44
         def check_sandbox_config(self, config):
    
    45 45
             # With the chroot sandbox, the UID/GID in the sandbox
    
    46 46
             # will match the host UID/GID (typically 0/0).
    
    47
    -        return config.build_uid == self._uid and config.build_gid == self._gid
    47
    +        if config.build_uid != self._uid or config.build_gid != self._gid:
    
    48
    +            return False
    
    49
    +
    
    50
    +        # Check host os and architecture match
    
    51
    +        if config.build_os != self.get_host_os():
    
    52
    +            raise PlatformError("Configure os and host os don't match.")
    
    53
    +        elif config.build_arch != self.get_host_arch():
    
    54
    +            raise PlatformError("Configured architecture and host architecture don't match.")
    
    55
    +
    
    56
    +        return True



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