[Libosinfo] [PATCHv4 09/11] Set OsinfoInstallConfig:config-params in osinfo_install_script_apply_template
Christophe Fergeau
cfergeau at redhat.com
Thu Dec 20 16:45:12 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 | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index b82c0f9..0591708 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -30,6 +30,7 @@
#include <libxslt/xsltutils.h>
#include <libxslt/xsltInternals.h>
#include <glib/gi18n-lib.h>
+#include "osinfo_install_config_private.h"
#include "osinfo_install_script_private.h"
G_DEFINE_TYPE (OsinfoInstallScript, osinfo_install_script, OSINFO_TYPE_ENTITY);
@@ -758,6 +759,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,
@@ -767,8 +795,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