[elbe-devel] [PATCH 2/3] Automatically replace debootstrapvariant

Daniel Braunwarth daniel.braunwarth at kuka.com
Thu Sep 9 14:02:16 CEST 2021


This patch automatically replaces old debootstrapvariant configurations
with the new debootstrap configuration.

Signed-off-by: Daniel Braunwarth <daniel.braunwarth at kuka.com>
---
 elbepack/xmlpreprocess.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
index b330f1033..dc66280b8 100644
--- a/elbepack/xmlpreprocess.py
+++ b/elbepack/xmlpreprocess.py
@@ -53,6 +53,28 @@ def preprocess_pgp_key(xml):
             raise XMLPreprocessError("Problem with PGP Key URL in <key> tag: %s" %
                                      keyurl)
 
+def preprocess_bootstrap(xml):
+    "Replaces a maybe existing debootstrapvariant element with debootstrap"
+
+    old_node = xml.find(".//debootstrapvariant")
+    if old_node is None:
+        return
+
+    print("[WARN] <debootstrapvariant> is deprecated. Use <debootstrap> instead.")
+
+    bootstrap = Element("debootstrap")
+
+    bootstrap_variant = Element("variant")
+    bootstrap_variant.text = old_node.text
+    bootstrap.append(bootstrap_variant)
+
+    old_includepkgs = old_node.get("includepkgs")
+    if old_includepkgs:
+        bootstrap_include = Element("include")
+        bootstrap_include.text = old_includepkgs
+        bootstrap.append(bootstrap_include)
+
+    old_node.getparent().replace(old_node, bootstrap)
 
 def preprocess_iso_option(xml):
 
@@ -303,6 +325,9 @@ def xmlpreprocess(fname, output, variants=None, proxy=None):
         # Change public PGP url key to raw key
         preprocess_pgp_key(xml)
 
+        # Replace old debootstrapvariant with debootstrap
+        preprocess_bootstrap(xml)
+
         preprocess_iso_option(xml)
 
         preprocess_initvm_ports(xml)
-- 
2.33.0



More information about the elbe-devel mailing list