[gnome-runtime-images/rewrite-manifest: 3/3] add script to rewrite flatpak manifest
- From: Abderrahim Kitouni <akitouni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-runtime-images/rewrite-manifest: 3/3] add script to rewrite flatpak manifest
- Date: Sun, 15 Mar 2020 10:48:36 +0000 (UTC)
commit dd6cc8f3011f9ce164da113d00998d62325e4c9f
Author: Abderrahim Kitouni <akitouni gnome org>
Date: Sun Mar 15 11:05:38 2020 +0100
add script to rewrite flatpak manifest
base | 4 ++++
rewrite-flatpak-manifest | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
---
diff --git a/base b/base
index 23d6045..cdb064d 100644
--- a/base
+++ b/base
@@ -27,6 +27,10 @@ RUN dnf -y update && \
dconf dbus-daemon git bzr xorg-x11-server-Xvfb dbus-x11 && \
dnf clean all
+RUN pip install ruamel.yaml
+
+COPY rewrite-flatpak-manifest /usr/local/bin/rewrite-flatpak-manifest
+
USER build
RUN flatpak remote-add --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo && \
diff --git a/rewrite-flatpak-manifest b/rewrite-flatpak-manifest
new file mode 100755
index 0000000..d29b98d
--- /dev/null
+++ b/rewrite-flatpak-manifest
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+
+import json
+from ruamel import yaml
+import os, sys
+
+from contextlib import contextmanager
+
+@contextmanager
+def rewrite_manifest(filename):
+ with open(filename) as f:
+ if filename.endswith('.json'):
+ data = json.load(f)
+ else:
+ data = yaml.round_trip_load(f, preserve_quotes=True)
+
+ yield data
+
+ with open(filename, 'w') as f:
+ if filename.endswith('.json'):
+ json.dump(data, f, indent=4, separators=(',', ' : '))
+ else:
+ yaml.round_trip_dump(data, f)
+
+if __name__ == '__main__':
+ try:
+ manifestfile, modulename = sys.argv[1:]
+ except ValueError:
+ print("usage: {} flatpak_manifest module_name".format(sys.argv[0]))
+ sys.exit(1)
+
+ with rewrite_manifest(manifestfile) as data:
+ for mod in data['modules']:
+ if not isinstance(mod, dict):
+ continue
+
+ if mod['name'] == modulename:
+ assert len(mod['sources']) == 1
+ path = os.path.relpath('.', os.path.dirname(jsonfile))
+ mod['sources'] = [{'type': 'dir', 'path': path}]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]