You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:05:06 UTC

[buildstream] 02/12: Sandbox.py: Rename __root to _root to allow its use by subclasses.

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch jmac/virtual_directories_pre_rebase
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 59fb91526e45a7fc6c25846d60e9684d15df8dfc
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Tue May 8 16:14:37 2018 +0100

    Sandbox.py: Rename __root to _root to allow its use by subclasses.
    
    Since access to get_directories is now blocked for some plugins,
    and the subclasses of Sandbox do not have configuration defined
    by YAML files, they need another way to get at the root directory.
    
    NB Could this be done just with get_virtual_directory and .external_directory?
---
 buildstream/sandbox/_sandboxchroot.py | 2 +-
 buildstream/sandbox/sandbox.py        | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/buildstream/sandbox/_sandboxchroot.py b/buildstream/sandbox/_sandboxchroot.py
index 8788c30..de4eb46 100644
--- a/buildstream/sandbox/_sandboxchroot.py
+++ b/buildstream/sandbox/_sandboxchroot.py
@@ -90,7 +90,7 @@ class SandboxChroot(Sandbox):
             # Nonetheless a better solution could perhaps be found.
 
             rootfs = stack.enter_context(utils._tempdir(dir='/var/run/buildstream'))
-            stack.enter_context(self.create_devices(self.get_directory(), flags))
+            stack.enter_context(self.create_devices(self._root, flags))
             stack.enter_context(self.mount_dirs(rootfs, flags, stdout, stderr))
 
             if flags & SandboxFlags.INTERACTIVE:
diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py
index 7e73e0d..90b80af 100644
--- a/buildstream/sandbox/sandbox.py
+++ b/buildstream/sandbox/sandbox.py
@@ -97,11 +97,12 @@ class Sandbox():
         self.__stdout = kwargs['stdout']
         self.__stderr = kwargs['stderr']
 
-        # Setup the directories
+        # Setup the directories. Root should be available to subclasses, hence
+        # being single-underscore. The others are private to this class.
+        self._root = os.path.join(directory, 'root')
         self.__directory = directory
-        self.__root = os.path.join(self.__directory, 'root')
         self.__scratch = os.path.join(self.__directory, 'scratch')
-        for directory_ in [self.__root, self.__scratch]:
+        for directory_ in [self._root, self.__scratch]:
             os.makedirs(directory_, exist_ok=True)
 
     def get_directory(self):
@@ -116,7 +117,7 @@ class Sandbox():
 
         """
         if self.__allow_real_directory:
-            return self.__root
+            return self._root
         else:
             raise BstError("You can't use get_directory")