[virt-tools-list] [libosinfo 4/4] Don't assume install script disk

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Sun Nov 11 19:14:58 UTC 2012


From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>

Instead of hardcoding install script disk, lets get this info from app.
---
 data/install-scripts/windows-cmd.xml |  3 ++-
 data/install-scripts/windows-sif.xml |  2 +-
 osinfo/libosinfo.syms                |  3 +++
 osinfo/osinfo_install_config.c       | 28 ++++++++++++++++++++++++++++
 osinfo/osinfo_install_config.h       |  5 +++++
 5 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/data/install-scripts/windows-cmd.xml b/data/install-scripts/windows-cmd.xml
index f376b6f..b45da56 100644
--- a/data/install-scripts/windows-cmd.xml
+++ b/data/install-scripts/windows-cmd.xml
@@ -8,6 +8,7 @@
       <param name="avatar-location" policy="optional"/>
       <param name="avatar-disk" policy="optional"/>
       <param name="target-disk" policy="required"/>
+      <param name="script-disk" policy="required"/>
     </config>
     <template filename="windows.cmd" path-format="dos">
       <xsl:stylesheet
@@ -21,7 +22,7 @@ net user <xsl:value-of select="config/user-realname"/> <xsl:text> </xsl:text> <x
 net localgroup administrators <xsl:value-of select="config/user-realname"/> /add
 net accounts /maxpwage:unlimited
 if not "<xsl:value-of select="config/avatar-location"/>"=="" copy "<xsl:value-of select="config/avatar-disk"/>:\<xsl:value-of select="config/avatar-location"/>" "<xsl:value-of select="config/target-disk"/>:\Documents and Settings\All Users\Application Data\Microsoft\User Account Pictures\<xsl:value-of select="config/user-realname"/>.bmp"
-REGEDIT /S a:\windows.reg
+REGEDIT /S <xsl:value-of select="config/script-disk"/>:\windows.reg
 EXIT
 	</xsl:template>
       </xsl:stylesheet>
diff --git a/data/install-scripts/windows-sif.xml b/data/install-scripts/windows-sif.xml
index ee9adc4..5cf5894 100644
--- a/data/install-scripts/windows-sif.xml
+++ b/data/install-scripts/windows-sif.xml
@@ -174,7 +174,7 @@
 
 <xsl:if test="os/version > 5.0">
 [SetupParams]
-    UserExecute = "a:\windows.cmd"
+    UserExecute = "<xsl:value-of select="config/script-disk"/>:\windows.cmd"
 
 [WindowsFirewall]
     Profiles = WindowsFirewall.TurnOffFirewall
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 0892a61..62ebb9e 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -334,6 +334,9 @@ LIBOSINFO_0.2.2 {
 
 	osinfo_install_config_get_target_disk;
 	osinfo_install_config_set_target_disk;
+
+	osinfo_install_config_get_script_disk;
+	osinfo_install_config_set_script_disk;
 } LIBOSINFO_0.2.1;
 
 
diff --git a/osinfo/osinfo_install_config.c b/osinfo/osinfo_install_config.c
index 0dffb28..22654f9 100644
--- a/osinfo/osinfo_install_config.c
+++ b/osinfo/osinfo_install_config.c
@@ -362,6 +362,34 @@ const gchar *osinfo_install_config_get_target_disk(OsinfoInstallConfig *config)
 }
 
 /**
+ * osinfo_install_config_set_script_disk:
+ *
+ * Sets the #OSINFO_INSTALL_CONFIG_PROP_SCRIPT_DISK parameter.
+ *
+ * Please read documentation on #osinfo_install_config_set_target_disk() for
+ * explanation on the format of @disk string.
+ */
+void osinfo_install_config_set_script_disk(OsinfoInstallConfig *config,
+                                           const gchar *disk)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_SCRIPT_DISK,
+                            disk);
+}
+
+/**
+ * osinfo_install_config_get_script_disk:
+ *
+ * Returns: The value of #OSINFO_INSTALL_CONFIG_PROP_SCRIPT_DISK parameter,
+ *          or NULL.
+ */
+const gchar *osinfo_install_config_get_script_disk(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_SCRIPT_DISK);
+}
+
+/**
  * osinfo_install_config_set_avatar_location:
  *
  * Sets the #OSINFO_INSTALL_CONFIG_PROP_AVATAR_LOCATION parameter.
diff --git a/osinfo/osinfo_install_config.h b/osinfo/osinfo_install_config.h
index cf5b455..788d464 100644
--- a/osinfo/osinfo_install_config.h
+++ b/osinfo/osinfo_install_config.h
@@ -56,6 +56,7 @@
 
 #define OSINFO_INSTALL_CONFIG_PROP_HOSTNAME    "hostname"
 #define OSINFO_INSTALL_CONFIG_PROP_TARGET_DISK "target-disk"
+#define OSINFO_INSTALL_CONFIG_PROP_SCRIPT_DISK "script-disk"
 
 #define OSINFO_INSTALL_CONFIG_PROP_AVATAR_LOCATION "avatar-location"
 #define OSINFO_INSTALL_CONFIG_PROP_AVATAR_DISK     "avatar-disk"
@@ -159,6 +160,10 @@ void osinfo_install_config_set_target_disk(OsinfoInstallConfig *config,
                                            const gchar *disk);
 const gchar *osinfo_install_config_get_target_disk(OsinfoInstallConfig *config);
 
+void osinfo_install_config_set_script_disk(OsinfoInstallConfig *config,
+                                           const gchar *disk);
+const gchar *osinfo_install_config_get_script_disk(OsinfoInstallConfig *config);
+
 void osinfo_install_config_set_avatar_location(OsinfoInstallConfig *config,
                                                const gchar *location);
 const gchar *osinfo_install_config_get_avatar_location(OsinfoInstallConfig *config);
-- 
1.8.0




More information about the virt-tools-list mailing list