[virt-tools-list] [libosinfo v5 01/12] Add InstallScript:path-format

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Wed Nov 14 02:40:40 UTC 2012


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

Inform the applications in which format the paths are expected by the
installer.
---
 data/install-scripts/windows-cmd.xml      |  1 +
 data/install-scripts/windows-reg.xml      |  1 +
 data/install-scripts/windows-sif.xml      |  2 ++
 data/install-scripts/windows-unattend.xml |  2 ++
 data/schemas/libosinfo.rng                | 11 +++++++++++
 osinfo/libosinfo.syms                     |  4 ++++
 osinfo/osinfo_install_script.c            | 28 ++++++++++++++++++++++++++++
 osinfo/osinfo_install_script.h            | 12 ++++++++++++
 osinfo/osinfo_loader.c                    |  1 +
 9 files changed, 62 insertions(+)

diff --git a/data/install-scripts/windows-cmd.xml b/data/install-scripts/windows-cmd.xml
index 750299b..175fcf5 100644
--- a/data/install-scripts/windows-cmd.xml
+++ b/data/install-scripts/windows-cmd.xml
@@ -2,6 +2,7 @@
   <!-- DESKTOP PROFILE -->
   <install-script id='http://microsoft.com/windows/cmd/desktop'>
     <profile>desktop</profile>
+    <path-format>dos</path-format>
     <config>
       <param name="admin-password" policy="optional"/>
       <param name="user-realname" policy="required"/>
diff --git a/data/install-scripts/windows-reg.xml b/data/install-scripts/windows-reg.xml
index afc285d..361f7ec 100644
--- a/data/install-scripts/windows-reg.xml
+++ b/data/install-scripts/windows-reg.xml
@@ -2,6 +2,7 @@
   <!-- DESKTOP PROFILE -->
   <install-script id='http://microsoft.com/windows/reg/desktop'>
     <profile>desktop</profile>
+    <path-format>dos</path-format>
     <config>
       <param name="admin-password" policy="optional"/>
       <param name="user-realname" policy="required"/>
diff --git a/data/install-scripts/windows-sif.xml b/data/install-scripts/windows-sif.xml
index 76f9baf..635620f 100644
--- a/data/install-scripts/windows-sif.xml
+++ b/data/install-scripts/windows-sif.xml
@@ -2,6 +2,7 @@
   <!-- JEOS PROFILE -->
   <install-script id='http://microsoft.com/windows/sif/jeos'>
     <profile>jeos</profile>
+    <path-format>dos</path-format>
     <config>
       <param name="admin-password" policy="optional"/>
       <param name="reg-product-key" policy="required"/>
@@ -64,6 +65,7 @@
   <!-- DESKTOP PROFILE -->
   <install-script id='http://microsoft.com/windows/sif/desktop'>
     <profile>desktop</profile>
+    <path-format>dos</path-format>
     <config>
       <param name="admin-password" policy="optional"/>
       <param name="reg-product-key" policy="required"/>
diff --git a/data/install-scripts/windows-unattend.xml b/data/install-scripts/windows-unattend.xml
index 766fdc2..4f0d91d 100644
--- a/data/install-scripts/windows-unattend.xml
+++ b/data/install-scripts/windows-unattend.xml
@@ -1,6 +1,7 @@
 <libosinfo version="0.0.1">
   <install-script id='http://microsoft.com/windows/unattend/jeos'>
     <profile>jeos</profile>
+    <path-format>dos</path-format>
     <config>
       <param name="admin-password" policy="optional"/>
       <param name="hardware-arch" policy="optional"/>
@@ -166,6 +167,7 @@
   <!-- DESKTOP PROFILE -->
   <install-script id='http://microsoft.com/windows/unattend/desktop'>
    <profile>desktop</profile>
+   <path-format>dos</path-format>
    <config>
     <param name="admin-password" policy="optional"/>
     <param name="hardware-arch" policy="required"/>
diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng
index 07a8fef..67bcdf8 100644
--- a/data/schemas/libosinfo.rng
+++ b/data/schemas/libosinfo.rng
@@ -468,6 +468,11 @@
       <element name='profile'>
         <text/>
       </element>
+      <optional>
+        <element name='path-format'>
+          <ref name='path-formats'/>
+        </element>
+      </optional>
       <element name='config'>
         <attribute name="name"/>
         <attribute name="policy">
@@ -549,4 +554,10 @@
       <param name="pattern">required|optional</param>
     </data>
   </define>
+
+  <define name='path-formats'>
+    <data type="string">
+      <param name="pattern">dos|unix</param>
+    </data>
+  </define>
 </grammar>
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index d291d7e..093f540 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -320,9 +320,13 @@ LIBOSINFO_0.2.2 {
 	osinfo_install_config_param_policy_get_type;
 	osinfo_media_error_get_type;
 	osinfo_product_relationship_get_type;
+	osinfo_path_format_get_type;
 
 	osinfo_entity_get_param_value_enum;
 	osinfo_entity_set_param_enum;
+
+	osinfo_install_script_get_path_format;
+
 } LIBOSINFO_0.2.1;
 
 
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index 2292aac..8c4f3e8 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -59,6 +59,7 @@ enum {
     PROP_TEMPLATE_DATA,
     PROP_PROFILE,
     PROP_PRODUCT_KEY_FORMAT,
+    PROP_PATH_FORMAT,
 };
 
 typedef struct _OsinfoInstallScriptGenerateData OsinfoInstallScriptGenerateData;
@@ -136,6 +137,11 @@ osinfo_os_get_property(GObject    *object,
                            osinfo_install_script_get_product_key_format(script));
         break;
 
+    case PROP_PATH_FORMAT:
+        g_value_set_enum(value,
+                         osinfo_install_script_get_path_format(script));
+        break;
+
     default:
         /* We don't have any other property... */
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -221,6 +227,19 @@ osinfo_install_script_class_init (OsinfoInstallScriptClass *klass)
                                     PROP_PRODUCT_KEY_FORMAT,
                                     pspec);
 
+    pspec = g_param_spec_enum("path-format",
+                              "Path Format",
+                              _("Expected path format"),
+                              OSINFO_TYPE_PATH_FORMAT,
+                              OSINFO_PATH_FORMAT_UNIX /* default value */,
+                              G_PARAM_READABLE |
+                              G_PARAM_STATIC_NAME |
+                              G_PARAM_STATIC_NICK |
+                              G_PARAM_STATIC_BLURB);
+    g_object_class_install_property(g_klass,
+                                    PROP_PATH_FORMAT,
+                                    pspec);
+
     g_type_class_add_private (klass, sizeof (OsinfoInstallScriptPrivate));
 }
 
@@ -1010,6 +1029,15 @@ GFile *osinfo_install_script_generate_output(OsinfoInstallScript *script,
     return data.file;
 }
 
+OsinfoPathFormat osinfo_install_script_get_path_format(OsinfoInstallScript *script)
+{
+    return osinfo_entity_get_param_value_enum
+        (OSINFO_ENTITY(script),
+         OSINFO_INSTALL_SCRIPT_PROP_PATH_FORMAT,
+         OSINFO_TYPE_PATH_FORMAT,
+         OSINFO_PATH_FORMAT_UNIX);
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: nil
diff --git a/osinfo/osinfo_install_script.h b/osinfo/osinfo_install_script.h
index 348dcdd..036b572 100644
--- a/osinfo/osinfo_install_script.h
+++ b/osinfo/osinfo_install_script.h
@@ -51,6 +51,7 @@ typedef struct _OsinfoInstallScriptPrivate OsinfoInstallScriptPrivate;
 #define OSINFO_INSTALL_SCRIPT_PROP_PROFILE            "profile"
 #define OSINFO_INSTALL_SCRIPT_PROP_PRODUCT_KEY_FORMAT "product-key-format"
 #define OSINFO_INSTALL_SCRIPT_PROP_EXPECTED_FILENAME  "expected-filename"
+#define OSINFO_INSTALL_SCRIPT_PROP_PATH_FORMAT        "path-format"
 
 /* object */
 struct _OsinfoInstallScript
@@ -71,6 +72,16 @@ struct _OsinfoInstallScriptClass
     /* class members */
 };
 
+/**
+ * OsinfoPathFormat:
+ * OSINFO_PATH_FORMAT_UNIX: Unix/Linux path format, e.g /home/foo/bar.txt
+ * OSINFO_PATH_FORMAT_DOS: DOS/Windows path format, e.g \My Documents\bar.txt
+ */
+typedef enum {
+    OSINFO_PATH_FORMAT_UNIX,
+    OSINFO_PATH_FORMAT_DOS
+} OsinfoPathFormat;
+
 GType osinfo_install_script_get_type(void);
 
 OsinfoInstallScript *osinfo_install_script_new(const gchar *id);
@@ -140,6 +151,7 @@ OsinfoInstallConfigParam *osinfo_install_script_get_config_param(const OsinfoIns
 void osinfo_install_script_add_config_param(OsinfoInstallScript *script, OsinfoInstallConfigParam *param);
 
 GList *osinfo_install_script_get_config_param_list(const OsinfoInstallScript *script);
+OsinfoPathFormat osinfo_install_script_get_path_format(OsinfoInstallScript *script);
 
 #endif /* __OSINFO_INSTALL_SCRIPT_H__ */
 /*
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index e7f2c71..eb09cd9 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -607,6 +607,7 @@ static void osinfo_loader_install_script(OsinfoLoader *loader,
     const gchar *const keys[] = {
         OSINFO_INSTALL_SCRIPT_PROP_PROFILE,
         OSINFO_INSTALL_SCRIPT_PROP_PRODUCT_KEY_FORMAT,
+        OSINFO_INSTALL_SCRIPT_PROP_PATH_FORMAT,
         NULL
     };
     gchar *value = NULL;
-- 
1.8.0




More information about the virt-tools-list mailing list