[elbe-devel] [PATCH 1/6] contrib: add script to modify initvm repositories during ci

Thomas Weißschuh thomas.weissschuh at linutronix.de
Thu Feb 22 14:22:08 CET 2024


Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 contrib/replace-initvm-repository.py | 38 ++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100755 contrib/replace-initvm-repository.py

diff --git a/contrib/replace-initvm-repository.py b/contrib/replace-initvm-repository.py
new file mode 100755
index 000000000000..48cfdbc1d528
--- /dev/null
+++ b/contrib/replace-initvm-repository.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+
+import argparse
+import xml.etree.ElementTree as ET
+
+
+def replace_repo(doc, old_repo_url, new_repo_url, key):
+    for url in doc.findall('./initvm/mirror/url-list/url'):
+        binary = url.find('binary')
+        if binary.text.strip() != old_repo_url:
+            continue
+        binary.text = new_repo_url
+        url.find('source').text = new_repo_url
+        url.find('raw-key').text = '\n' + key + '\n'
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser()
+    parser.add_argument('xml')
+    parser.add_argument('old-repo-url')
+    parser.add_argument('new-repo-url')
+    parser.add_argument('keyfile')
+
+    args = parser.parse_args()
+
+    with open(args.keyfile, 'r') as keyfile:
+        key = keyfile.read()
+
+    doc = ET.parse(args.xml)
+
+    replace_repo(
+            doc,
+            vars(args)['old-repo-url'],
+            vars(args)['new-repo-url'],
+            key,
+    )
+
+    ET.dump(doc)
-- 
2.43.2



More information about the elbe-devel mailing list