[gnome-build-meta/abderrahim/ostree-checksum] plugins/flatpak_repo.py: generate sha256 sum of files during build (fork of bst-external)
- From: Abderrahim Kitouni <akitouni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-build-meta/abderrahim/ostree-checksum] plugins/flatpak_repo.py: generate sha256 sum of files during build (fork of bst-external)
- Date: Sun, 31 Jan 2021 19:04:00 +0000 (UTC)
commit faa53d6a97b268172bd62043ec8746b08470892c
Author: Abderrahim Kitouni <akitouni gnome org>
Date: Sun Jan 31 20:03:42 2021 +0100
plugins/flatpak_repo.py: generate sha256 sum of files during build (fork of bst-external)
This should help pinpoint where files are getting corrupted
plugins/flatpak_repo.py | 104 ++++++++++++++++++++++++++++++++++++++++++++++
plugins/flatpak_repo.yaml | 10 +++++
project.conf | 2 +-
3 files changed, 115 insertions(+), 1 deletion(-)
---
diff --git a/plugins/flatpak_repo.py b/plugins/flatpak_repo.py
new file mode 100644
index 00000000..8d4dfa3e
--- /dev/null
+++ b/plugins/flatpak_repo.py
@@ -0,0 +1,104 @@
+# Copyright (C) 2018 Abderrahim Kitouni
+#
+# 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:
+# Abderrahim Kitouni <akitouni gnome org>
+
+"""flatpak repository element
+
+A :mod:`ScriptElement <buildstream.scriptelement>` implementation for exporting
+a flatpak repository from a set of `flatpak_image`s.
+
+The flatpak_repo default configuration:
+ .. literalinclude:: ../../../bst_external/elements/flatpak_repo.yaml
+ :language: yaml
+"""
+
+from buildstream import ScriptElement, Scope, ElementError
+
+class FlatpakRepoElement(ScriptElement):
+ BST_ARTIFACT_VERSION = 1
+
+ def configure(self, node):
+ self.node_validate(node, ['environment', 'copy-refs', 'repo-mode', 'arch', 'branch'])
+
+ self._env = self.node_get_member(node, list, 'environment')
+
+ self._copy_refs = []
+ for subnode in self.node_get_member(node, list, 'copy-refs'):
+ self.node_validate(subnode, ['src', 'dest'])
+ self._copy_refs.append((self.node_subst_member(subnode, 'src'),
+ self.node_subst_member(subnode, 'dest')))
+
+ self._arch = self.node_subst_member(node, 'arch')
+ self._branch = self.node_subst_member(node, 'branch')
+
+ self.set_work_dir()
+ self.set_root_read_only(True)
+
+ self._repo_mode = self.node_subst_member(node, 'repo-mode')
+ self.set_install_root('/buildstream/repo')
+ self.add_commands('init repository',
+ ['ostree init --repo=/buildstream/repo --mode={}'.format(self._repo_mode)])
+
+ def _layout_flatpaks(self, elements):
+ def staging_dir(elt):
+ return '/buildstream/input/{}'.format(elt.name)
+
+ def export_command(elt):
+ return 'flatpak build-export --files=files --arch={} /buildstream/repo {} {}'\
+ .format(self._arch, staging_dir(elt), self._branch)
+
+ for elt in elements:
+ if elt.get_kind() == 'flatpak_image':
+ self.layout_add(elt.name, staging_dir(elt))
+ self.add_commands('export {}'.format(elt.name), [export_command(elt)])
+ elif elt.get_kind() == 'stack':
+ self._layout_flatpaks(elt.dependencies(Scope.RUN, recurse=False))
+ else:
+ raise ElementError('Dependency {} is not of kind flatpak_image'.format(elt.name))
+
+ def stage(self, sandbox):
+ env = [self.search(Scope.BUILD, elt) for elt in self._env]
+ flatpaks = [elt for elt in self.dependencies(Scope.BUILD, recurse=False) if elt not in env]
+
+ for elt in env:
+ self.layout_add(elt.name, '/')
+
+ self._layout_flatpaks(flatpaks)
+
+ for src, dest in self._copy_refs:
+ self.add_commands('copy ref {} -> {}'.format(src, dest),
+ ['flatpak build-commit-from --src-ref={} /buildstream/repo {}'.format(src,
dest)])
+
+ self.add_commands('generating sha256sum', [
+ 'sh -c "find /buildstream/repo -type f | xargs sha256sum"'
+ ])
+
+ super(FlatpakRepoElement, self).stage(sandbox)
+
+ def get_unique_key(self):
+ return {
+ 'environment': self._env,
+ 'copy-refs': self._copy_refs,
+ 'repo-mode': self._repo_mode,
+ 'arch': self._arch,
+ 'branch': self._branch
+ }
+
+
+# Plugin entry point
+def setup():
+ return FlatpakRepoElement
diff --git a/plugins/flatpak_repo.yaml b/plugins/flatpak_repo.yaml
new file mode 100644
index 00000000..a6c9e315
--- /dev/null
+++ b/plugins/flatpak_repo.yaml
@@ -0,0 +1,10 @@
+config:
+ # elements (from the build dependencies) that should be staged in /
+ environment: []
+ # refs of which a copy is to be made using flatpak build-commit-from
+ # a list of mappings containing keys `src` and `dest`
+ copy-refs: []
+ # the mode of the ostree repo (one of archive, bare, bare-user, bare-user-only)
+ repo-mode: 'archive'
+ arch: '%{arch}'
+ branch: '%{branch}'
diff --git a/project.conf b/project.conf
index 7b4c9df3..8f44b5ba 100644
--- a/project.conf
+++ b/project.conf
@@ -252,7 +252,6 @@ plugins:
package-name: buildstream-external
elements:
flatpak_image: 0
- flatpak_repo: 0
collect_manifest: 0
x86image: 0
sources:
@@ -263,3 +262,4 @@ plugins:
elements:
collect_initial_scripts: 0
ostree: 0
+ flatpak_repo: 0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]