[virt-tools-list] [libosinfo v2 1/3] differenciate between expected/output script name
Fabiano Fidêncio
fabiano at fidencio.org
Thu Oct 4 05:06:05 UTC 2012
We need to differenciate between the expected filename and the output
filename. While former always remains the same (as some operating
systems expect it with a particular name), the latter is dependent on
the output prefix (set by application)
---
data/install-scripts/windows-sif.xml | 4 ++--
data/install-scripts/windows-unattend.xml | 4 ++--
osinfo/libosinfo.syms | 1 +
osinfo/osinfo_install_script.c | 39 +++++++++++++++++++++++++++++--
osinfo/osinfo_install_script.h | 4 +++-
osinfo/osinfo_loader.c | 2 +-
6 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/data/install-scripts/windows-sif.xml b/data/install-scripts/windows-sif.xml
index 52cca39..76f9baf 100644
--- a/data/install-scripts/windows-sif.xml
+++ b/data/install-scripts/windows-sif.xml
@@ -7,7 +7,7 @@
<param name="reg-product-key" policy="required"/>
<param name="user-realname" policy="required"/>
</config>
- <template filename="windows.sif">
+ <template filename="winnt.sif">
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
@@ -70,7 +70,7 @@
<param name="user-realname" policy="required"/>
<param name="hostname" policy="required"/>
</config>
- <template filename="windows.sif">
+ <template filename="winnt.sif">
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
diff --git a/data/install-scripts/windows-unattend.xml b/data/install-scripts/windows-unattend.xml
index 0695fa6..38fd9ab 100644
--- a/data/install-scripts/windows-unattend.xml
+++ b/data/install-scripts/windows-unattend.xml
@@ -10,7 +10,7 @@
<param name="user-realname" policy="optional"/>
<param name="reg-product-key" policy="required"/>
</config>
- <template filename="windows.xml">
+ <template filename="autounattend.xml">
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
@@ -175,7 +175,7 @@
<param name="user-realname" policy="optional"/>
<param name="hostname" policy="required"/>
</config>
- <template filename="windows.xml">
+ <template filename="autounattend.xml">
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 6676588..772e89c 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -308,6 +308,7 @@ LIBOSINFO_0.2.1 {
osinfo_entity_get_param_value_int64;
osinfo_entity_get_param_value_int64_with_default;
osinfo_entity_set_param_int64;
+ osinfo_install_script_get_expected_filename;
} LIBOSINFO_0.2.0;
/* Symbols in next release...
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index bb2c2eb..c9e2024 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -47,6 +47,7 @@ G_DEFINE_TYPE (OsinfoInstallScript, osinfo_install_script, OSINFO_TYPE_ENTITY);
struct _OsinfoInstallScriptPrivate
{
gchar *output_prefix;
+ gchar *output_filename;
GList *config_param_list;
};
@@ -147,6 +148,7 @@ osinfo_install_script_finalize (GObject *object)
{
OsinfoInstallScript *script = OSINFO_INSTALL_SCRIPT (object);
g_free(script->priv->output_prefix);
+ g_free(script->priv->output_filename);
g_list_free_full(script->priv->config_param_list, g_object_unref);
/* Chain up to the parent class */
@@ -344,8 +346,18 @@ const gchar *osinfo_install_script_get_product_key_format(OsinfoInstallScript *s
void osinfo_install_script_set_output_prefix(OsinfoInstallScript *script,
const gchar *prefix)
{
+ const char *output_filename =
+ osinfo_install_script_get_expected_filename(script);
+
g_free(script->priv->output_prefix);
script->priv->output_prefix = g_strdup(prefix);
+
+ /* update output_filename whenever output_prefix is changed */
+ g_free(script->priv->output_filename);
+ script->priv->output_filename = g_strjoin("-",
+ prefix,
+ output_filename,
+ NULL);
}
const gchar *osinfo_install_script_get_output_prefix(OsinfoInstallScript *script)
@@ -353,10 +365,33 @@ const gchar *osinfo_install_script_get_output_prefix(OsinfoInstallScript *script
return script->priv->output_prefix;
}
-const gchar *osinfo_install_script_get_output_filename(OsinfoInstallScript *script)
+/**
+ * osinfo_install_script_get_expected_filename:
+ *
+ * Some operating systems (as Windows) expect that script filename has
+ * particular name to work.
+ *
+ * Returns: (transfer none): the expected script filename
+ */
+const gchar *osinfo_install_script_get_expected_filename(OsinfoInstallScript *script)
{
return osinfo_entity_get_param_value(OSINFO_ENTITY(script),
- OSINFO_INSTALL_SCRIPT_PROP_OUTPUT_FILENAME);
+ OSINFO_INSTALL_SCRIPT_PROP_EXPECTED_FILENAME);
+}
+
+/**
+ * osinfo_install_script_get_output_filename:
+ *
+ * Some operating systems are able to use any script filename, allowing the
+ * application to set the filename as desired. libosinfo provides this
+ * functionality by set the expected filename's prefix using
+ * osinfo_install_script_set_output_prefix() function.
+ *
+ * Returns: (transfer none): the output script filename
+ */
+const gchar *osinfo_install_script_get_output_filename(OsinfoInstallScript *script)
+{
+ return script->priv->output_filename;
}
struct _OsinfoInstallScriptGenerateData {
diff --git a/osinfo/osinfo_install_script.h b/osinfo/osinfo_install_script.h
index cbfc517..4af62e0 100644
--- a/osinfo/osinfo_install_script.h
+++ b/osinfo/osinfo_install_script.h
@@ -50,7 +50,7 @@ typedef struct _OsinfoInstallScriptPrivate OsinfoInstallScriptPrivate;
#define OSINFO_INSTALL_SCRIPT_PROP_TEMPLATE_DATA "template-data"
#define OSINFO_INSTALL_SCRIPT_PROP_PROFILE "profile"
#define OSINFO_INSTALL_SCRIPT_PROP_PRODUCT_KEY_FORMAT "product-key-format"
-#define OSINFO_INSTALL_SCRIPT_PROP_OUTPUT_FILENAME "output-filename"
+#define OSINFO_INSTALL_SCRIPT_PROP_EXPECTED_FILENAME "expected-filename"
#define OSINFO_INSTALL_SCRIPT_PROP_CONFIG_REQUIRED "required"
#define OSINFO_INSTALL_SCRIPT_PROP_CONFIG_OPTIONAL "optional"
@@ -95,6 +95,8 @@ const gchar *osinfo_install_script_get_output_prefix(OsinfoInstallScript *script
const gchar *osinfo_install_script_get_output_filename(OsinfoInstallScript *script);
+const gchar *osinfo_install_script_get_expected_filename(OsinfoInstallScript *script);
+
void osinfo_install_script_generate_async(OsinfoInstallScript *script,
OsinfoOs *os,
OsinfoInstallConfig *config,
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index ab507da..13cbe5f 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -620,7 +620,7 @@ static void osinfo_loader_install_script(OsinfoLoader *loader,
goto error;
if (value)
osinfo_entity_set_param(OSINFO_ENTITY(installScript),
- OSINFO_INSTALL_SCRIPT_PROP_OUTPUT_FILENAME,
+ OSINFO_INSTALL_SCRIPT_PROP_EXPECTED_FILENAME,
value);
g_free(value);
--
1.7.12.1
More information about the virt-tools-list
mailing list