[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [libosinfo v5 03/12] Allow apps to specify target disk



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

---
 data/install-scripts/fedora.xml           | 84 +++++++++++++++++--------------
 data/install-scripts/windows-cmd.xml      | 14 +++++-
 data/install-scripts/windows-unattend.xml | 32 ++++++++++--
 osinfo/libosinfo.syms                     |  3 ++
 osinfo/osinfo_install_config.c            | 40 ++++++++++++---
 osinfo/osinfo_install_config.h            |  7 ++-
 6 files changed, 130 insertions(+), 50 deletions(-)

diff --git a/data/install-scripts/fedora.xml b/data/install-scripts/fedora.xml
index 734875a..5199b88 100644
--- a/data/install-scripts/fedora.xml
+++ b/data/install-scripts/fedora.xml
@@ -7,6 +7,7 @@
       <param name="l10n-keyboard" policy="optional"/>
       <param name="l10n-language" policy="optional"/>
       <param name="l10n-timezone" policy="optional"/>
+      <param name="target-disk" policy="optional"/>
     </config>
     <template filename="fedora.ks">
       <xsl:stylesheet
@@ -15,22 +16,25 @@
 
         <xsl:output method="text"/>
 
-	<xsl:template name="disk">
-	  <xsl:choose>
-	    <xsl:when test="os/version &gt; 9">
-	      <!-- virtio -->
-	      <xsl:text>vda</xsl:text>
-	    </xsl:when>
-	    <xsl:when test="os/version &gt; 6">
-	      <!-- libata IDE -->
-	      <xsl:text>sda</xsl:text>
-	    </xsl:when>
-	    <xsl:otherwise>
-	      <!-- IDE -->
-	      <xsl:text>hda</xsl:text>
-	    </xsl:otherwise>
-	  </xsl:choose>
-	</xsl:template>
+        <xsl:template name="target-disk">
+          <xsl:choose>
+            <xsl:when test="config/target-disk != ''">
+              <xsl:value-of select="config/target-disk"/>
+            </xsl:when>
+            <xsl:when test="os/version &gt; 9">
+              <!-- virtio -->
+              <xsl:text>vda</xsl:text>
+            </xsl:when>
+            <xsl:when test="os/version &gt; 6">
+              <!-- libata IDE -->
+              <xsl:text>sda</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>
+              <!-- IDE -->
+              <xsl:text>hda</xsl:text>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:template>
 
 	<xsl:template name="rootfs">
 	  <xsl:choose>
@@ -76,13 +80,13 @@ timezone --utc <xsl:value-of select="config/l10n-timezone"/>
 bootloader --location=mbr
 zerombr <xsl:if test="os/version &lt; 14">yes</xsl:if>
 
-clearpart --all --drives=<xsl:call-template name="disk"/>
+clearpart --all --drives=<xsl:call-template name="target-disk"/>
 
 <xsl:if test="os/version &gt; 15">
 part biosboot --fstype=biosboot --size=1
 </xsl:if>
-part /boot --fstype <xsl:call-template name="bootfs"/> --size=200 --ondisk=<xsl:call-template name="disk"/>
-part pv.2 --size=1 --grow --ondisk=<xsl:call-template name="disk"/>
+part /boot --fstype <xsl:call-template name="bootfs"/> --size=200 --ondisk=<xsl:call-template name="target-disk"/>
+part pv.2 --size=1 --grow --ondisk=<xsl:call-template name="target-disk"/>
 volgroup VolGroup00 --pesize=32768 pv.2
 logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=768 --grow --maxsize=1536
 logvol / --fstype <xsl:call-template name="rootfs"/> --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
@@ -114,6 +118,7 @@ reboot
         <param name="admin-password" policy="required"/>
         <param name="avatar-location" policy="optional"/>
         <param name="avatar-disk" policy="optional"/>
+        <param name="target-disk" policy="optional"/>
     </config>
     <template filename="fedora.ks">
       <xsl:stylesheet
@@ -122,22 +127,25 @@ reboot
 
         <xsl:output method="text"/>
 
-	<xsl:template name="disk">
-	  <xsl:choose>
-	    <xsl:when test="os/version &gt; 9">
-	      <!-- virtio -->
-	      <xsl:text>vda</xsl:text>
-	    </xsl:when>
-	    <xsl:when test="os/version &gt; 6">
-	      <!-- libata IDE -->
-	      <xsl:text>sda</xsl:text>
-	    </xsl:when>
-	    <xsl:otherwise>
-	      <!-- IDE -->
-	      <xsl:text>hda</xsl:text>
-	    </xsl:otherwise>
-	  </xsl:choose>
-	</xsl:template>
+        <xsl:template name="target-disk">
+          <xsl:choose>
+            <xsl:when test="config/target-disk != ''">
+              <xsl:value-of select="config/target-disk"/>
+            </xsl:when>
+            <xsl:when test="os/version &gt; 9">
+              <!-- virtio -->
+              <xsl:text>vda</xsl:text>
+            </xsl:when>
+            <xsl:when test="os/version &gt; 6">
+              <!-- libata IDE -->
+              <xsl:text>sda</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>
+              <!-- IDE -->
+              <xsl:text>hda</xsl:text>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:template>
 
 	<xsl:template name="rootfs">
 	  <xsl:choose>
@@ -174,13 +182,13 @@ timezone --utc <xsl:value-of select="config/l10n-timezone"/>
 bootloader --location=mbr
 zerombr
 
-clearpart --all --drives=<xsl:call-template name="disk"/>
+clearpart --all --drives=<xsl:call-template name="target-disk"/>
 
 firstboot --disable
 
 part biosboot --fstype=biosboot --size=1
-part /boot --fstype <xsl:call-template name="bootfs"/> --recommended --ondisk=<xsl:call-template name="disk"/>
-part pv.2 --size=1 --grow --ondisk=<xsl:call-template name="disk"/>
+part /boot --fstype <xsl:call-template name="bootfs"/> --recommended --ondisk=<xsl:call-template name="target-disk"/>
+part pv.2 --size=1 --grow --ondisk=<xsl:call-template name="target-disk"/>
 volgroup VolGroup00 --pesize=32768 pv.2
 logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=768 --grow --maxsize=1536
 logvol / --fstype <xsl:call-template name="rootfs"/> --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
diff --git a/data/install-scripts/windows-cmd.xml b/data/install-scripts/windows-cmd.xml
index f07c983..91f7716 100644
--- a/data/install-scripts/windows-cmd.xml
+++ b/data/install-scripts/windows-cmd.xml
@@ -8,6 +8,7 @@
       <param name="user-realname" policy="required"/>
       <param name="avatar-location" policy="optional"/>
       <param name="avatar-disk" policy="optional"/>
+      <param name="target-disk" policy="optional"/>
     </config>
     <template filename="windows.cmd">
       <xsl:stylesheet
@@ -15,12 +16,23 @@
         version="1.0">
         <xsl:output method="text"/>
 
+        <xsl:template name="target-disk">
+          <xsl:choose>
+            <xsl:when test="config/target-disk != ''">
+              <xsl:value-of select="config/target-disk"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:text>C</xsl:text>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:template>
+
 	<xsl:template match="/install-script-config">
 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
-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"
+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:call-template name="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
 EXIT
 	</xsl:template>
diff --git a/data/install-scripts/windows-unattend.xml b/data/install-scripts/windows-unattend.xml
index 4f0d91d..509f18a 100644
--- a/data/install-scripts/windows-unattend.xml
+++ b/data/install-scripts/windows-unattend.xml
@@ -10,6 +10,7 @@
       <param name="user-password" policy="optional"/>
       <param name="user-realname" policy="optional"/>
       <param name="reg-product-key" policy="required"/>
+      <param name="target-disk" policy="optional"/>
     </config>
     <template filename="autounattend.xml">
       <xsl:stylesheet
@@ -18,6 +19,17 @@
 
         <xsl:output method="xml" indent="yes"/>
 
+        <xsl:template name="target-disk">
+          <xsl:choose>
+            <xsl:when test="config/target-disk != ''">
+              <xsl:value-of select="config/target-disk"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:text>C</xsl:text>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:template>
+
 	<xsl:template name="arch">
 	  <xsl:choose>
 	    <xsl:when test="count(config/hardware-arch) &gt; 0">
@@ -53,8 +65,8 @@
 			<Active>true</Active>
 			<Extend>true</Extend>
 			<Format>NTFS</Format>
-			<Label>C drive</Label>
-			<Letter>C</Letter>
+                        <Label><xsl:call-template name="target-disk"/> drive</Label>
+                        <Letter><xsl:call-template name="target-disk"/></Letter>
 			<Order>1</Order>
 			<PartitionID>1</PartitionID>
 		      </ModifyPartition>
@@ -176,6 +188,7 @@
     <param name="user-password" policy="optional"/>
     <param name="user-realname" policy="optional"/>
     <param name="hostname" policy="required"/>
+    <param name="target-disk" policy="optional"/>
    </config>
     <template filename="autounattend.xml">
      <xsl:stylesheet
@@ -184,6 +197,17 @@
 
       <xsl:output method="xml" indent="yes"/>
 
+      <xsl:template name="target-disk">
+        <xsl:choose>
+          <xsl:when test="config/target-disk != ''">
+            <xsl:value-of select="config/target-disk"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text>C</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:template>
+
       <xsl:template name="arch">
        <xsl:choose>
         <xsl:when test="config/hardware-arch = 'x86_64'">
@@ -222,8 +246,8 @@
              <Active>true</Active>
              <Extend>true</Extend>
              <Format>NTFS</Format>
-             <Label>C drive</Label>
-             <Letter>C</Letter>
+             <Label><xsl:call-template name="target-disk"/> drive</Label>
+             <Letter><xsl:call-template name="target-disk"/></Letter>
              <Order>1</Order>
              <PartitionID>1</PartitionID>
             </ModifyPartition>
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 0427a88..c67235e 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -330,6 +330,9 @@ LIBOSINFO_0.2.2 {
 	osinfo_install_config_get_avatar_disk;
 	osinfo_install_config_set_avatar_disk;
 
+	osinfo_install_config_get_target_disk;
+	osinfo_install_config_set_target_disk;
+
 	osinfo_install_script_get_path_format;
 } LIBOSINFO_0.2.1;
 
diff --git a/osinfo/osinfo_install_config.c b/osinfo/osinfo_install_config.c
index 0e1f838..b1874ef 100644
--- a/osinfo/osinfo_install_config.c
+++ b/osinfo/osinfo_install_config.c
@@ -330,6 +330,38 @@ const gchar *osinfo_install_config_get_hostname(OsinfoInstallConfig *config)
 }
 
 /**
+ * osinfo_install_config_set_target_disk:
+ *
+ * Sets the #OSINFO_INSTALL_CONFIG_PROP_TARGET_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_target_disk(OsinfoInstallConfig *config,
+                                           const gchar *disk)
+{
+    osinfo_entity_set_param(OSINFO_ENTITY(config),
+                            OSINFO_INSTALL_CONFIG_PROP_TARGET_DISK,
+                            disk);
+}
+
+/**
+ * osinfo_install_config_get_target_disk:
+ *
+ * Returns: The value of #OSINFO_INSTALL_CONFIG_PROP_TARGET_DISK parameter,
+ *          or NULL.
+ */
+const gchar *osinfo_install_config_get_target_disk(OsinfoInstallConfig *config)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(config),
+                                         OSINFO_INSTALL_CONFIG_PROP_TARGET_DISK);
+}
+
+/**
  * osinfo_install_config_set_avatar_location:
  *
  * Sets the #OSINFO_INSTALL_CONFIG_PROP_AVATAR_LOCATION parameter.
@@ -361,12 +393,8 @@ const gchar *osinfo_install_config_get_avatar_location(OsinfoInstallConfig *conf
  *
  * 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".
+ * Please read documentation on #osinfo_install_config_set_target_disk() for
+ * explanation on the format of @disk string.
  */
 void osinfo_install_config_set_avatar_disk(OsinfoInstallConfig *config,
                                            const gchar *disk)
diff --git a/osinfo/osinfo_install_config.h b/osinfo/osinfo_install_config.h
index 2fd49ab..cf5b455 100644
--- a/osinfo/osinfo_install_config.h
+++ b/osinfo/osinfo_install_config.h
@@ -54,7 +54,8 @@
 #define OSINFO_INSTALL_CONFIG_PROP_REG_PASSWORD   "reg-password"
 #define OSINFO_INSTALL_CONFIG_PROP_REG_PRODUCTKEY "reg-product-key"
 
-#define OSINFO_INSTALL_CONFIG_PROP_HOSTNAME "hostname"
+#define OSINFO_INSTALL_CONFIG_PROP_HOSTNAME    "hostname"
+#define OSINFO_INSTALL_CONFIG_PROP_TARGET_DISK "target-disk"
 
 #define OSINFO_INSTALL_CONFIG_PROP_AVATAR_LOCATION "avatar-location"
 #define OSINFO_INSTALL_CONFIG_PROP_AVATAR_DISK     "avatar-disk"
@@ -154,6 +155,10 @@ 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_target_disk(OsinfoInstallConfig *config,
+                                           const gchar *disk);
+const gchar *osinfo_install_config_get_target_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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]