You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:19:09 UTC
[buildstream] 10/21: WIP: sandboxnone: use initial SandboxNone
This is an automated email from the ASF dual-hosted git repository.
tvb pushed a commit to branch aevri/win32
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 63dc3edf411996e812363f507b4f81b7e9f2ff90
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Wed Apr 10 18:06:06 2019 +0100
WIP: sandboxnone: use initial SandboxNone
---
src/buildstream/_platform/darwin.py | 4 +-
src/buildstream/sandbox/__init__.py | 1 +
src/buildstream/sandbox/_sandboxnone.py | 67 +++++++++++++++++++++++++++++++++
3 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/src/buildstream/_platform/darwin.py b/src/buildstream/_platform/darwin.py
index 8e08685..2bbd205 100644
--- a/src/buildstream/_platform/darwin.py
+++ b/src/buildstream/_platform/darwin.py
@@ -17,7 +17,7 @@
import os
-from ..sandbox import SandboxDummy
+from ..sandbox import SandboxNone
from .platform import Platform
@@ -31,7 +31,7 @@ class Darwin(Platform):
kwargs['dummy_reason'] = \
"OSXFUSE is not supported and there are no supported sandbox " + \
"technologies for MacOS at this time"
- return SandboxDummy(*args, **kwargs)
+ return SandboxNone(*args, **kwargs)
def check_sandbox_config(self, config):
# Accept all sandbox configs as it's irrelevant with the dummy sandbox (no Sandbox.run).
diff --git a/src/buildstream/sandbox/__init__.py b/src/buildstream/sandbox/__init__.py
index 5966d19..6544348 100644
--- a/src/buildstream/sandbox/__init__.py
+++ b/src/buildstream/sandbox/__init__.py
@@ -20,3 +20,4 @@
from .sandbox import Sandbox, SandboxFlags, SandboxCommandError
from ._sandboxremote import SandboxRemote
from ._sandboxdummy import SandboxDummy
+from ._sandboxnone import SandboxNone
diff --git a/src/buildstream/sandbox/_sandboxnone.py b/src/buildstream/sandbox/_sandboxnone.py
new file mode 100644
index 0000000..e95a7b9
--- /dev/null
+++ b/src/buildstream/sandbox/_sandboxnone.py
@@ -0,0 +1,67 @@
+#
+# Copyright (C) 2019 Bloomberg Finance LP
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+#
+# Authors:
+# Angelos Evripiotis <je...@bloomberg.net>
+
+import pathlib
+import pprint
+import subprocess
+
+from .._exceptions import SandboxError
+from .sandbox import Sandbox
+
+
+class SandboxNone(Sandbox):
+
+ def __init__(self, *args, **kwargs):
+ # TODO: don't require a dict copy.
+ kwargs = kwargs.copy()
+ kwargs['allow_real_directory'] = True
+
+ super().__init__(*args, **kwargs)
+
+ uid = self._get_config().build_uid
+ gid = self._get_config().build_gid
+ if uid != 0 or gid != 0:
+ raise SandboxError("Chroot sandboxes cannot specify a non-root uid/gid "
+ "({},{} were supplied via config)".format(uid, gid))
+
+ self.mount_map = None
+
+ def _run(self, command, flags, *, cwd, env):
+
+ install_path = pathlib.Path(self.get_directory()) / 'buildstream-install'
+
+ env = env.copy()
+ env['BST_INSTALLPATH'] = str(install_path)
+
+ # TODO: figure out what to do with 'flags'.
+
+ # TODO: do this in a robust way.
+ if cwd.startswith("/"):
+ cwd = cwd[1:]
+
+ # pprint.pprint(env)
+
+ path = pathlib.Path(self.get_directory()) / cwd
+ print('run', command, 'in', path)
+ result = subprocess.run(command, cwd=path, env=env)
+
+ # out = pathlib.Path(self.get_directory()) / 'buildstream-install'
+ # out.mkdir(exist_ok=True)
+
+ return result.returncode