Jim MacArthur pushed to branch master at BuildStream / buildstream
Commits:
-
2df7d140
by Jim MacArthur at 2018-09-25T10:36:37Z
-
62f59382
by Jim MacArthur at 2018-09-25T10:36:37Z
-
8cea7b17
by Jim MacArthur at 2018-09-25T10:58:40Z
2 changed files:
Changes:
... | ... | @@ -1532,8 +1532,6 @@ class Element(Plugin): |
1532 | 1532 |
with _signals.terminator(cleanup_rootdir), \
|
1533 | 1533 |
self.__sandbox(rootdir, output_file, output_file, self.__sandbox_config) as sandbox: # nopep8
|
1534 | 1534 |
|
1535 |
- sandbox_vroot = sandbox.get_virtual_directory()
|
|
1536 |
- |
|
1537 | 1535 |
# By default, the dynamic public data is the same as the static public data.
|
1538 | 1536 |
# The plugin's assemble() method may modify this, though.
|
1539 | 1537 |
self.__dynamic_public = _yaml.node_copy(self.__public)
|
... | ... | @@ -1581,7 +1579,6 @@ class Element(Plugin): |
1581 | 1579 |
finally:
|
1582 | 1580 |
if collect is not None:
|
1583 | 1581 |
try:
|
1584 |
- # Sandbox will probably have replaced its virtual directory, so get it again
|
|
1585 | 1582 |
sandbox_vroot = sandbox.get_virtual_directory()
|
1586 | 1583 |
collectvdir = sandbox_vroot.descend(collect.lstrip(os.sep).split(os.sep))
|
1587 | 1584 |
except VirtualDirectoryError:
|
... | ... | @@ -1606,6 +1603,7 @@ class Element(Plugin): |
1606 | 1603 |
collectvdir.export_files(filesdir, can_link=True)
|
1607 | 1604 |
|
1608 | 1605 |
try:
|
1606 |
+ sandbox_vroot = sandbox.get_virtual_directory()
|
|
1609 | 1607 |
sandbox_build_dir = sandbox_vroot.descend(
|
1610 | 1608 |
self.get_variable('build-root').lstrip(os.sep).split(os.sep))
|
1611 | 1609 |
# Hard link files from build-root dir to buildtreedir directory
|
... | ... | @@ -110,6 +110,10 @@ class Sandbox(): |
110 | 110 |
os.makedirs(directory_, exist_ok=True)
|
111 | 111 |
self._vdir = None
|
112 | 112 |
|
113 |
+ # This is set if anyone requests access to the underlying
|
|
114 |
+ # directory via get_directory.
|
|
115 |
+ self._never_cache_vdirs = False
|
|
116 |
+ |
|
113 | 117 |
def get_directory(self):
|
114 | 118 |
"""Fetches the sandbox root directory
|
115 | 119 |
|
... | ... | @@ -122,24 +126,28 @@ class Sandbox(): |
122 | 126 |
|
123 | 127 |
"""
|
124 | 128 |
if self.__allow_real_directory:
|
129 |
+ self._never_cache_vdirs = True
|
|
125 | 130 |
return self._root
|
126 | 131 |
else:
|
127 | 132 |
raise BstError("You can't use get_directory")
|
128 | 133 |
|
129 | 134 |
def get_virtual_directory(self):
|
130 |
- """Fetches the sandbox root directory
|
|
135 |
+ """Fetches the sandbox root directory as a virtual Directory.
|
|
131 | 136 |
|
132 | 137 |
The root directory is where artifacts for the base
|
133 |
- runtime environment should be staged. Only works if
|
|
134 |
- BST_VIRTUAL_DIRECTORY is not set.
|
|
138 |
+ runtime environment should be staged.
|
|
139 |
+ |
|
140 |
+ Use caution if you use get_directory and
|
|
141 |
+ get_virtual_directory. If you alter the contents of the
|
|
142 |
+ directory returned by get_directory, all objects returned by
|
|
143 |
+ get_virtual_directory or derived from them are invalid and you
|
|
144 |
+ must call get_virtual_directory again to get a new copy.
|
|
135 | 145 |
|
136 | 146 |
Returns:
|
137 |
- (str): The sandbox root directory
|
|
147 |
+ (Directory): The sandbox root directory
|
|
138 | 148 |
|
139 | 149 |
"""
|
140 |
- if not self._vdir:
|
|
141 |
- # BST_CAS_DIRECTORIES is a deliberately hidden environment variable which
|
|
142 |
- # can be used to switch on CAS-based directories for testing.
|
|
150 |
+ if self._vdir is None or self._never_cache_vdirs:
|
|
143 | 151 |
if 'BST_CAS_DIRECTORIES' in os.environ:
|
144 | 152 |
self._vdir = CasBasedDirectory(self.__context, ref=None)
|
145 | 153 |
else:
|