[Libosinfo] [PATCHv4 10/11] Set OsinfoInstallConfig:config-params in osinfo_install_script_apply_template

Christophe Fergeau cfergeau at redhat.com
Mon Dec 17 21:07:53 UTC 2012


This allows translation of generic config to OS-specific config if
the install script XML specified some datamaps to transform these
parameters.
---
 osinfo/osinfo_install_script.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index 8dbef9e..e106eca 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -768,6 +768,33 @@ static gchar *osinfo_install_script_apply_xslt(xsltStylesheetPtr ss,
 }
 
 
+static OsinfoInstallConfig *create_config_for_script(OsinfoInstallScript *script, OsinfoInstallConfig *config)
+{
+    OsinfoInstallConfig *os_config;
+    GList *params;
+    GList *param;
+    const gchar *id;
+
+    id = osinfo_entity_get_id(OSINFO_ENTITY(config));
+    os_config = osinfo_install_config_new_for_script(id, script);
+    params = osinfo_entity_get_param_keys(OSINFO_ENTITY(config));
+    for (param = params; param != NULL; param = param->next) {
+        GList *values;
+        GList *value;
+
+        osinfo_entity_clear_param(OSINFO_ENTITY(os_config), param->data);
+        values = osinfo_entity_get_param_value_list(OSINFO_ENTITY(config), param->data);
+        for (value = values; value != NULL; value = value->next) {
+            osinfo_entity_add_param(OSINFO_ENTITY(os_config), param->data, value->data);
+        }
+        g_list_free(values);
+    }
+    g_list_free(params);
+
+    return os_config;
+}
+
+
 static gboolean osinfo_install_script_apply_template(OsinfoInstallScript *script,
                                                      OsinfoOs *os,
                                                      const gchar *templateUri,
@@ -777,8 +804,10 @@ static gboolean osinfo_install_script_apply_template(OsinfoInstallScript *script
                                                      GError **error)
 {
     gboolean ret = FALSE;
+    OsinfoInstallConfig *os_config = create_config_for_script(script, config);
     xsltStylesheetPtr templateXsl = osinfo_install_script_load_template(templateUri, template, error);
-    xmlDocPtr configXml = osinfo_install_script_generate_config_xml(script, os, config, error);
+    xmlDocPtr configXml = osinfo_install_script_generate_config_xml(script, os, os_config, error);
+    g_object_unref(G_OBJECT(os_config));
 
     if (!templateXsl || !configXml)
         goto cleanup;
-- 
1.8.0.2




More information about the Libosinfo mailing list