[virt-tools-list] [libosinfo v2 1/3] differenciate between expected/output script name

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Fri Oct 5 12:34:35 UTC 2012


On Thu, Oct 4, 2012 at 8:06 AM, Fabiano Fidêncio <fabiano at fidencio.org> wrote:
> 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;
>  }

With this approach output_prefix will never get initialized unless app
sets a prefix.

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124




More information about the virt-tools-list mailing list