[gnome-build-meta/abderrahim/bst2: 3/9] plugins/collect_initial_scripts.py: port to buildstream 2
- From: Abderrahim Kitouni <akitouni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-build-meta/abderrahim/bst2: 3/9] plugins/collect_initial_scripts.py: port to buildstream 2
- Date: Tue, 5 Jul 2022 07:18:37 +0000 (UTC)
commit 7e3d300eb776d531736bd0ba7197b1f7aca5d2df
Author: Abderrahim Kitouni <akitouni gnome org>
Date: Fri Feb 14 08:23:31 2020 +0100
plugins/collect_initial_scripts.py: port to buildstream 2
copied from freedesktop-sdk
plugins/collect_initial_scripts.py | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
---
diff --git a/plugins/collect_initial_scripts.py b/plugins/collect_initial_scripts.py
index f0d8c413d..7654fb5ef 100644
--- a/plugins/collect_initial_scripts.py
+++ b/plugins/collect_initial_scripts.py
@@ -1,20 +1,17 @@
import os
import re
-from buildstream import Element, ElementError, Scope
+from buildstream import Element
class ExtractInitialScriptsElement(Element):
+
+ BST_MIN_VERSION = "2.0"
BST_FORBID_RDEPENDS = True
BST_FORBID_SOURCES = True
- BST_STRICT_REBUILD = True
- BST_ARTIFACT_VERSION = 1
-
def configure(self, node):
- self.node_validate(node, [
- 'path',
- ])
+ node.validate_keys(['path'])
- self.path = self.node_subst_member(node, 'path')
+ self.path = node.get_str('path')
def preflight(self):
pass
@@ -32,21 +29,22 @@ class ExtractInitialScriptsElement(Element):
pass
def assemble(self, sandbox):
- basedir = sandbox.get_directory()
- path = os.path.join(basedir, self.path.lstrip(os.sep))
+ basedir = sandbox.get_virtual_directory()
+ path_components = self.path.strip(os.sep).split(os.sep)
+
index = 0
- for dependency in self.dependencies(Scope.BUILD):
+ for dependency in self.dependencies():
public = dependency.get_public_data('initial-script')
if public and 'script' in public:
- script = self.node_subst_member(public, 'script')
+ script = self.node_subst_vars(public.get_scalar('script'))
index += 1
depname = re.sub('[^A-Za-z0-9]', '_', dependency.name)
basename = '{:03}-{}'.format(index, depname)
- filename = os.path.join(path, basename)
- os.makedirs(path, exist_ok=True)
- with open(filename, 'w') as f:
+
+ pathdir = basedir.descend(*path_components, create=True)
+ with pathdir.open_file(basename, mode='w') as f:
f.write(script)
- os.chmod(filename, 0o755)
+ os.chmod(f.fileno(), 0o755)
return os.sep
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]