Phillip Smyth pushed to branch mac_fixes at BuildStream / buildstream
Commits:
-
c5dd2cb6
by knownexus at 2018-09-25T15:10:29Z
-
54e27fb3
by James Ennis at 2018-09-25T15:10:33Z
-
3d1595e1
by James Ennis at 2018-09-25T15:10:33Z
-
c6731a29
by Phillip Smyth at 2018-09-25T15:10:33Z
7 changed files:
- buildstream/_platform/darwin.py
- buildstream/_platform/linux.py
- buildstream/_platform/unix.py
- buildstream/_stream.py
- buildstream/sandbox/__init__.py
- buildstream/utils.py
- tests/frontend/cross_junction_workspace.py
Changes:
| ... | ... | @@ -19,7 +19,7 @@ import os |
| 19 | 19 |
import resource
|
| 20 | 20 |
|
| 21 | 21 |
from .._exceptions import PlatformError
|
| 22 |
-from ..sandbox import SandboxChroot, SandboxDummy
|
|
| 22 |
+from ..sandbox import SandboxDummy
|
|
| 23 | 23 |
|
| 24 | 24 |
from . import Platform
|
| 25 | 25 |
|
| ... | ... | @@ -24,7 +24,7 @@ from .. import _site |
| 24 | 24 |
from .. import utils
|
| 25 | 25 |
from .._artifactcache.cascache import CASCache
|
| 26 | 26 |
from .._message import Message, MessageType
|
| 27 |
-from ..sandbox import SandboxBwrap, SandboxDummy
|
|
| 27 |
+from ..sandbox import SandboxDummy
|
|
| 28 | 28 |
|
| 29 | 29 |
from . import Platform
|
| 30 | 30 |
|
| ... | ... | @@ -52,6 +52,7 @@ class Linux(Platform): |
| 52 | 52 |
if not self._local_sandbox_available():
|
| 53 | 53 |
return SandboxDummy(*args, **kwargs)
|
| 54 | 54 |
else:
|
| 55 |
+ from ..sandbox._sandboxbwrap import SandboxBwrap
|
|
| 55 | 56 |
# Inform the bubblewrap sandbox as to whether it can use user namespaces or not
|
| 56 | 57 |
kwargs['user_ns_available'] = self._user_ns_available
|
| 57 | 58 |
kwargs['die_with_parent_available'] = self._die_with_parent_available
|
| ... | ... | @@ -64,7 +65,10 @@ class Linux(Platform): |
| 64 | 65 |
# Private Methods #
|
| 65 | 66 |
################################################
|
| 66 | 67 |
def _local_sandbox_available(self):
|
| 67 |
- return os.path.exists(utils.get_host_tool('bwrap')) and os.path.exists('/dev/fuse')
|
|
| 68 |
+ try:
|
|
| 69 |
+ return os.path.exists(utils.get_host_tool('bwrap')) and os.path.exists('/dev/fuse')
|
|
| 70 |
+ except utils.ProgramNotFoundError:
|
|
| 71 |
+ return False
|
|
| 68 | 72 |
|
| 69 | 73 |
def _check_user_ns_available(self, context):
|
| 70 | 74 |
# Here, lets check if bwrap is able to create user namespaces,
|
| ... | ... | @@ -21,7 +21,6 @@ import os |
| 21 | 21 |
|
| 22 | 22 |
from .._artifactcache.cascache import CASCache
|
| 23 | 23 |
from .._exceptions import PlatformError
|
| 24 |
-from ..sandbox import SandboxChroot
|
|
| 25 | 24 |
|
| 26 | 25 |
from . import Platform
|
| 27 | 26 |
|
| ... | ... | @@ -41,4 +40,5 @@ class Unix(Platform): |
| 41 | 40 |
return self._artifact_cache
|
| 42 | 41 |
|
| 43 | 42 |
def create_sandbox(self, *args, **kwargs):
|
| 43 |
+ from ..sandbox._sandboxchroot import SandboxChroot
|
|
| 44 | 44 |
return SandboxChroot(*args, **kwargs)
|
| ... | ... | @@ -641,6 +641,9 @@ class Stream(): |
| 641 | 641 |
}
|
| 642 | 642 |
workspaces.append(workspace_detail)
|
| 643 | 643 |
|
| 644 |
+ if not workspaces:
|
|
| 645 |
+ workspaces = "No workspaces found"
|
|
| 646 |
+ |
|
| 644 | 647 |
_yaml.dump({
|
| 645 | 648 |
'workspaces': workspaces
|
| 646 | 649 |
})
|
| ... | ... | @@ -18,7 +18,5 @@ |
| 18 | 18 |
# Tristan Maat <tristan maat codethink co uk>
|
| 19 | 19 |
|
| 20 | 20 |
from .sandbox import Sandbox, SandboxFlags
|
| 21 |
-from ._sandboxchroot import SandboxChroot
|
|
| 22 |
-from ._sandboxbwrap import SandboxBwrap
|
|
| 23 | 21 |
from ._sandboxremote import SandboxRemote
|
| 24 | 22 |
from ._sandboxdummy import SandboxDummy
|
| ... | ... | @@ -35,6 +35,7 @@ import tempfile |
| 35 | 35 |
import itertools
|
| 36 | 36 |
import functools
|
| 37 | 37 |
from contextlib import contextmanager
|
| 38 |
+from stat import S_ISDIR
|
|
| 38 | 39 |
|
| 39 | 40 |
import psutil
|
| 40 | 41 |
|
| ... | ... | @@ -328,27 +329,25 @@ def safe_remove(path): |
| 328 | 329 |
Raises:
|
| 329 | 330 |
UtilError: In the case of unexpected system call failures
|
| 330 | 331 |
"""
|
| 331 |
- if os.path.lexists(path):
|
|
| 332 |
- |
|
| 333 |
- # Try to remove anything that is in the way, but issue
|
|
| 334 |
- # a warning instead if it removes a non empty directory
|
|
| 335 |
- try:
|
|
| 332 |
+ try:
|
|
| 333 |
+ if S_ISDIR(os.lstat(path).st_mode):
|
|
| 334 |
+ os.rmdir(path)
|
|
| 335 |
+ else:
|
|
| 336 | 336 |
os.unlink(path)
|
| 337 |
- except OSError as e:
|
|
| 338 |
- if e.errno != errno.EISDIR:
|
|
| 339 |
- raise UtilError("Failed to remove '{}': {}"
|
|
| 340 |
- .format(path, e))
|
|
| 341 |
- |
|
| 342 |
- try:
|
|
| 343 |
- os.rmdir(path)
|
|
| 344 |
- except OSError as e:
|
|
| 345 |
- if e.errno == errno.ENOTEMPTY:
|
|
| 346 |
- return False
|
|
| 347 |
- else:
|
|
| 348 |
- raise UtilError("Failed to remove '{}': {}"
|
|
| 349 |
- .format(path, e))
|
|
| 350 | 337 |
|
| 351 |
- return True
|
|
| 338 |
+ # File removed/unlinked successfully
|
|
| 339 |
+ return True
|
|
| 340 |
+ |
|
| 341 |
+ except OSError as e:
|
|
| 342 |
+ if e.errno == errno.ENOTEMPTY:
|
|
| 343 |
+ # Path is non-empty directory
|
|
| 344 |
+ return False
|
|
| 345 |
+ elif e.errno == errno.ENOENT:
|
|
| 346 |
+ # Path does not exist
|
|
| 347 |
+ return True
|
|
| 348 |
+ |
|
| 349 |
+ raise UtilError("Failed to remove '{}': {}"
|
|
| 350 |
+ .format(path, e))
|
|
| 352 | 351 |
|
| 353 | 352 |
|
| 354 | 353 |
def copy_files(src, dest, *, files=None, ignore_missing=False, report_written=False):
|
| ... | ... | @@ -93,9 +93,10 @@ def test_close_cross_junction(cli, tmpdir): |
| 93 | 93 |
result.assert_success()
|
| 94 | 94 |
|
| 95 | 95 |
loaded = _yaml.load_data(result.output)
|
| 96 |
- assert isinstance(loaded.get('workspaces'), list)
|
|
| 97 |
- workspaces = loaded['workspaces']
|
|
| 98 |
- assert len(workspaces) == 0
|
|
| 96 |
+ if not loaded['workspaces'] == "No workspaces found":
|
|
| 97 |
+ assert isinstance(loaded.get('workspaces'), list)
|
|
| 98 |
+ workspaces = loaded['workspaces']
|
|
| 99 |
+ assert len(workspaces) == 0
|
|
| 99 | 100 |
|
| 100 | 101 |
|
| 101 | 102 |
def test_close_all_cross_junction(cli, tmpdir):
|
| ... | ... | @@ -112,6 +113,7 @@ def test_close_all_cross_junction(cli, tmpdir): |
| 112 | 113 |
result.assert_success()
|
| 113 | 114 |
|
| 114 | 115 |
loaded = _yaml.load_data(result.output)
|
| 115 |
- assert isinstance(loaded.get('workspaces'), list)
|
|
| 116 |
- workspaces = loaded['workspaces']
|
|
| 117 |
- assert len(workspaces) == 0
|
|
| 116 |
+ if not loaded['workspaces'] == "No workspaces found":
|
|
| 117 |
+ assert isinstance(loaded.get('workspaces'), list)
|
|
| 118 |
+ workspaces = loaded['workspaces']
|
|
| 119 |
+ assert len(workspaces) == 0
|
