diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-05 15:27:23 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-05 15:35:20 +0900 |
commit | b8c68284f5bf1fcfd0f826d341088a98ec2e33c1 (patch) | |
tree | 8a51800209fed426f2d252bdc5d48a0a324ccb91 /buildstream/_platform | |
parent | 8c8b1c541baa905c53fb31244739dad710a1ae99 (diff) | |
download | buildstream-b8c68284f5bf1fcfd0f826d341088a98ec2e33c1.tar.gz |
_platform package: Adhere to policy on private symbols
This is a part of issue #285
Diffstat (limited to 'buildstream/_platform')
-rw-r--r-- | buildstream/_platform/linux.py | 42 | ||||
-rw-r--r-- | buildstream/_platform/platform.py | 2 |
2 files changed, 22 insertions, 22 deletions
diff --git a/buildstream/_platform/linux.py b/buildstream/_platform/linux.py index 9a2bcd356..3b179f34d 100644 --- a/buildstream/_platform/linux.py +++ b/buildstream/_platform/linux.py @@ -34,14 +34,24 @@ class Linux(Platform): super().__init__(context, project) - self._user_ns_available = False - self.check_user_ns_available(context) + self._user_ns_available = self._check_user_ns_available(context) + self._die_with_parent_available = self._check_die_with_parent_available(context) + self._artifact_cache = OSTreeCache(context, enable_push=self._user_ns_available) - self.check_die_with_parent_available(context) + @property + def artifactcache(self): + return self._artifact_cache - self._artifact_cache = OSTreeCache(context, enable_push=self._user_ns_available) + def create_sandbox(self, *args, **kwargs): + # Inform the bubblewrap sandbox as to whether it can use user namespaces or not + kwargs['user_ns_available'] = self._user_ns_available + kwargs['die_with_parent_available'] = self._die_with_parent_available + return SandboxBwrap(*args, **kwargs) - def check_user_ns_available(self, context): + ################################################ + # Private Methods # + ################################################ + def _check_user_ns_available(self, context): # Here, lets check if bwrap is able to create user namespaces, # issue a warning if it's not available, and save the state @@ -62,17 +72,17 @@ class Linux(Platform): output = '' if output == 'root': - self._user_ns_available = True + return True - # Issue a warning - if not self._user_ns_available: + else: context._message( Message(None, MessageType.WARN, "Unable to create user namespaces with bubblewrap, resorting to fallback", detail="Some builds may not function due to lack of uid / gid 0, " + "artifacts created will not be trusted for push purposes.")) + return False - def check_die_with_parent_available(self, context): + def _check_die_with_parent_available(self, context): # bwrap supports --die-with-parent since 0.1.8. # Let's check whether the host bwrap supports it. @@ -85,16 +95,6 @@ class Linux(Platform): '--die-with-parent', 'true' ], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - self._die_with_parent_available = True + return True except subprocess.CalledProcessError: - self._die_with_parent_available = False - - @property - def artifactcache(self): - return self._artifact_cache - - def create_sandbox(self, *args, **kwargs): - # Inform the bubblewrap sandbox as to whether it can use user namespaces or not - kwargs['user_ns_available'] = self._user_ns_available - kwargs['die_with_parent_available'] = self._die_with_parent_available - return SandboxBwrap(*args, **kwargs) + return False diff --git a/buildstream/_platform/platform.py b/buildstream/_platform/platform.py index 304aa4bba..fc6a74bdd 100644 --- a/buildstream/_platform/platform.py +++ b/buildstream/_platform/platform.py @@ -41,7 +41,7 @@ class Platform(): self.project = project @classmethod - def _create_instance(cls, *args, **kwargs): + def create_instance(cls, *args, **kwargs): if sys.platform.startswith('linux'): backend = 'linux' else: |