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

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Mon Nov 19 22:10:55 UTC 2012


On Mon, Nov 19, 2012 at 7:02 PM, Michal Privoznik <mprivozn at redhat.com> wrote:
> 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?

I think because of the parent patch introduces a redundant newline.
I'll try to fix that before pushing.

>> +
>> +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 ...

Many APIs are missing docs so I generally just added it where I think
user can't live without and hope someday I'll add all missing docs in
one go. I know thats the wrong approach but I'm lazy. :( I'll add here
though.

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124




More information about the virt-tools-list mailing list