[virt-tools-list] [libosinfo v5 02/12] Don't assume avatar location and disk

Michal Privoznik mprivozn at redhat.com
Mon Nov 19 17:02:20 UTC 2012


On 14.11.2012 03:40, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
> 
> Instead of hardcoding avatar path and disk, lets get those from
> application.
> ---
>  data/install-scripts/fedora.xml      | 26 +++++-----------
>  data/install-scripts/windows-cmd.xml |  4 ++-
>  osinfo/libosinfo.syms                |  6 +++-
>  osinfo/osinfo_install_config.c       | 58 ++++++++++++++++++++++++++++++++++++
>  osinfo/osinfo_install_config.h       |  9 ++++++
>  5 files changed, 82 insertions(+), 21 deletions(-)
> 
> diff --git a/data/install-scripts/fedora.xml b/data/install-scripts/fedora.xml
> index eef4f4a..734875a 100644
> --- a/data/install-scripts/fedora.xml
> +++ b/data/install-scripts/fedora.xml
> @@ -112,6 +112,8 @@ reboot
>          <param name="user-login" policy="required"/>
>          <param name="user-password" policy="required"/>
>          <param name="admin-password" policy="required"/>
> +        <param name="avatar-location" policy="optional"/>
> +        <param name="avatar-disk" policy="optional"/>
>      </config>
>      <template filename="fedora.ks">
>        <xsl:stylesheet
> @@ -137,23 +139,6 @@ reboot
>  	  </xsl:choose>
>  	</xsl:template>
>  
> -	<xsl:template name="avatar-disk">
> -	  <xsl:choose>
> -	    <xsl:when test="os/version > 9">
> -	      <!-- virtio -->
> -	      <xsl:text>sda</xsl:text>
> -	    </xsl:when>
> -	    <xsl:when test="os/version > 6">
> -	      <!-- libata IDE -->
> -	      <xsl:text>hda</xsl:text>
> -	    </xsl:when>
> -	    <xsl:otherwise>
> -	      <!-- IDE -->
> -	      <xsl:text>hdb</xsl:text>
> -	    </xsl:otherwise>
> -	  </xsl:choose>
> -	</xsl:template>
> -
>  	<xsl:template name="rootfs">
>  	  <xsl:choose>
>  	    <xsl:when test="os/version > 10">
> @@ -229,10 +214,13 @@ else
>  fi
>  
>  # Set user avatar
> +if test -n <xsl:value-of select="config/avatar-location"/>; then
>  mkdir /mnt/unattended-media
> -mount /dev/<xsl:call-template name='avatar-disk'/> /mnt/unattended-media
> -cp /mnt/unattended-media/<xsl:value-of select="config/user-login"/> /var/lib/AccountsService/icons/
> +mount <xsl:value-of select='config/avatar-disk'/> /mnt/unattended-media
> +cp /mnt/unattended-media<xsl:value-of select="config/avatar-location"/> /var/lib/AccountsService/icons/<xsl:value-of select="config/user-login"/>
>  umount /mnt/unattended-media
> +fi
> +
>  echo "
>  [User]
>  Language=
> diff --git a/data/install-scripts/windows-cmd.xml b/data/install-scripts/windows-cmd.xml
> index 175fcf5..f07c983 100644
> --- a/data/install-scripts/windows-cmd.xml
> +++ b/data/install-scripts/windows-cmd.xml
> @@ -6,6 +6,8 @@
>      <config>
>        <param name="admin-password" policy="optional"/>
>        <param name="user-realname" policy="required"/>
> +      <param name="avatar-location" policy="optional"/>
> +      <param name="avatar-disk" policy="optional"/>
>      </config>
>      <template filename="windows.cmd">
>        <xsl:stylesheet
> @@ -18,7 +20,7 @@ sc config TlntSvr start= auto
>  net user <xsl:value-of select="config/user-realname"/> <xsl:text> </xsl:text> <xsl:value-of select="config/admin-password"/> /add /passwordreq:no
>  net localgroup administrators <xsl:value-of select="config/user-realname"/> /add
>  net accounts /maxpwage:unlimited
> -copy a:\<xsl:value-of select="config/user-realname"/>.bmp "c:\Documents and Settings\All Users\Application Data\Microsoft\User Account Pictures"
> +if not "<xsl:value-of select="config/avatar-location"/>"=="" copy "<xsl:value-of select="config/avatar-disk"/>:\<xsl:value-of select="config/avatar-location"/>" "c:\Documents and Settings\All Users\Application Data\Microsoft\User Account Pictures\<xsl:value-of select="config/user-realname"/>.bmp"
>  REGEDIT /S a:\windows.reg
>  EXIT
>  	</xsl:template>
> diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
> index 093f540..0427a88 100644
> --- a/osinfo/libosinfo.syms
> +++ b/osinfo/libosinfo.syms
> @@ -325,8 +325,12 @@ LIBOSINFO_0.2.2 {
>  	osinfo_entity_get_param_value_enum;
>  	osinfo_entity_set_param_enum;
>  
> -	osinfo_install_script_get_path_format;
> +	osinfo_install_config_get_avatar_location;
> +	osinfo_install_config_set_avatar_location;
> +	osinfo_install_config_get_avatar_disk;
> +	osinfo_install_config_set_avatar_disk;
>  
> +	osinfo_install_script_get_path_format;
>  } LIBOSINFO_0.2.1;
>  

Honestly, I don't understand why diff formatted it this way, but doesn't
really matter, does it?

>  
> diff --git a/osinfo/osinfo_install_config.c b/osinfo/osinfo_install_config.c
> index 0ce8da7..0e1f838 100644
> --- a/osinfo/osinfo_install_config.c
> +++ b/osinfo/osinfo_install_config.c
> @@ -329,6 +329,64 @@ const gchar *osinfo_install_config_get_hostname(OsinfoInstallConfig *config)
>                                           OSINFO_INSTALL_CONFIG_PROP_HOSTNAME);
>  }
>  
> +/**
> + * osinfo_install_config_set_avatar_location:
> + *
> + * Sets the #OSINFO_INSTALL_CONFIG_PROP_AVATAR_LOCATION parameter.
> + *
> + * Note that the format of this string is dependent on the installer script
> + * @config is going to be used with. You can use
> + * #osinfo_install_script_get_path_format() to find out which format
> + * does the script expects this string to be in.
> + *
> + * Also note that in case of #OSINFO_PATH_FORMAT_DOS, the drive/disk letter
> + * and the leading ':' must not be included in the path.
> + */
> +void osinfo_install_config_set_avatar_location(OsinfoInstallConfig *config,
> +                                               const gchar *location)
> +{
> +    osinfo_entity_set_param(OSINFO_ENTITY(config),
> +                            OSINFO_INSTALL_CONFIG_PROP_AVATAR_LOCATION,
> +                            location);
> +}
> +
> +const gchar *osinfo_install_config_get_avatar_location(OsinfoInstallConfig *config)
> +{
> +    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
> +                                         OSINFO_INSTALL_CONFIG_PROP_AVATAR_LOCATION);
> +}

Documentation missing ...

> +
> +/**
> + * osinfo_install_config_set_avatar_disk:
> + *
> + * Sets the #OSINFO_INSTALL_CONFIG_PROP_AVATAR_DISK parameter.
> + *
> + * Note that the format of this string is dependent on the installer script
> + * @config is going to be used with. You can use
> + * #osinfo_install_script_get_path_format() to find out which format
> + * does the script expects this string to be in. In case of
> + * #OSINFO_PATH_FORMAT_UNIX unix device node names are expected, e.g "/dev/fd0".
> + * In case of #OSINFO_PATH_FORMAT_DOS drive letters are expected, e.g "A".
> + */
> +void osinfo_install_config_set_avatar_disk(OsinfoInstallConfig *config,
> +                                           const gchar *disk)
> +{
> +    osinfo_entity_set_param(OSINFO_ENTITY(config),
> +                            OSINFO_INSTALL_CONFIG_PROP_AVATAR_DISK,
> +                            disk);
> +}
> +
> +/**
> + * osinfo_install_config_get_avatar_disk:
> + *
> + * Returns: The value of #OSINFO_INSTALL_CONFIG_PROP_AVATAR_DISK parameter,
> + *          or NULL.
> + */
> +const gchar *osinfo_install_config_get_avatar_disk(OsinfoInstallConfig *config)
> +{
> +    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
> +                                         OSINFO_INSTALL_CONFIG_PROP_AVATAR_DISK);
> +}
>  
>  /*
>   * Local variables:
> diff --git a/osinfo/osinfo_install_config.h b/osinfo/osinfo_install_config.h
> index 32fe370..2fd49ab 100644
> --- a/osinfo/osinfo_install_config.h
> +++ b/osinfo/osinfo_install_config.h
> @@ -56,6 +56,8 @@
>  
>  #define OSINFO_INSTALL_CONFIG_PROP_HOSTNAME "hostname"
>  
> +#define OSINFO_INSTALL_CONFIG_PROP_AVATAR_LOCATION "avatar-location"
> +#define OSINFO_INSTALL_CONFIG_PROP_AVATAR_DISK     "avatar-disk"
>  
>  typedef struct _OsinfoInstallConfig        OsinfoInstallConfig;
>  typedef struct _OsinfoInstallConfigClass   OsinfoInstallConfigClass;
> @@ -152,6 +154,13 @@ void osinfo_install_config_set_hostname(OsinfoInstallConfig *config,
>                                          const gchar *hostname);
>  const gchar *osinfo_install_config_get_hostname(OsinfoInstallConfig *config);
>  
> +void osinfo_install_config_set_avatar_location(OsinfoInstallConfig *config,
> +                                               const gchar *location);
> +const gchar *osinfo_install_config_get_avatar_location(OsinfoInstallConfig *config);
> +
> +void osinfo_install_config_set_avatar_disk(OsinfoInstallConfig *config,
> +                                           const gchar *disk);
> +const gchar *osinfo_install_config_get_avatar_disk(OsinfoInstallConfig *config);
>  
>  #endif /* __OSINFO_INSTALL_CONFIG_H__ */
>  /*
> 

ACK if you add missing doc.

Michal




More information about the virt-tools-list mailing list