[virt-tools-list] [libosinfo 1/4] Add InstallScript:expected-path-format

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Sun Nov 11 19:14:55 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      |  2 +-
 data/install-scripts/windows-reg.xml      |  2 +-
 data/install-scripts/windows-sif.xml      |  2 +-
 data/install-scripts/windows-unattend.xml |  4 ++--
 osinfo/libosinfo.syms                     |  4 ++++
 osinfo/osinfo_install_script.c            | 28 ++++++++++++++++++++++++++++
 osinfo/osinfo_install_script.h            | 22 +++++++++++++++++-----
 osinfo/osinfo_loader.c                    |  9 +++++++++
 8 files changed, 63 insertions(+), 10 deletions(-)

diff --git a/data/install-scripts/windows-cmd.xml b/data/install-scripts/windows-cmd.xml
index 750299b..ba30795 100644
--- a/data/install-scripts/windows-cmd.xml
+++ b/data/install-scripts/windows-cmd.xml
@@ -6,7 +6,7 @@
       <param name="admin-password" policy="optional"/>
       <param name="user-realname" policy="required"/>
     </config>
-    <template filename="windows.cmd">
+    <template filename="windows.cmd" path-format="dos">
       <xsl:stylesheet
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         version="1.0">
diff --git a/data/install-scripts/windows-reg.xml b/data/install-scripts/windows-reg.xml
index afc285d..fe893a7 100644
--- a/data/install-scripts/windows-reg.xml
+++ b/data/install-scripts/windows-reg.xml
@@ -6,7 +6,7 @@
       <param name="admin-password" policy="optional"/>
       <param name="user-realname" policy="required"/>
     </config>
-    <template filename="windows.reg">
+    <template filename="windows.reg" path-format="dos">
       <xsl:stylesheet
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         version="1.0">
diff --git a/data/install-scripts/windows-sif.xml b/data/install-scripts/windows-sif.xml
index 76f9baf..ee9adc4 100644
--- a/data/install-scripts/windows-sif.xml
+++ b/data/install-scripts/windows-sif.xml
@@ -7,7 +7,7 @@
       <param name="reg-product-key" policy="required"/>
       <param name="user-realname" policy="required"/>
     </config>
-    <template filename="winnt.sif">
+    <template filename="winnt.sif" path-format="dos">
       <xsl:stylesheet
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         version="1.0">
diff --git a/data/install-scripts/windows-unattend.xml b/data/install-scripts/windows-unattend.xml
index 766fdc2..f94aa64 100644
--- a/data/install-scripts/windows-unattend.xml
+++ b/data/install-scripts/windows-unattend.xml
@@ -10,7 +10,7 @@
       <param name="user-realname" policy="optional"/>
       <param name="reg-product-key" policy="required"/>
     </config>
-    <template filename="autounattend.xml">
+    <template filename="autounattend.xml" path-format="dos">
       <xsl:stylesheet
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         version="1.0">
@@ -175,7 +175,7 @@
     <param name="user-realname" policy="optional"/>
     <param name="hostname" policy="required"/>
    </config>
-    <template filename="autounattend.xml">
+    <template filename="autounattend.xml" path-format="dos">
      <xsl:stylesheet
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       version="1.0">
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index d291d7e..95b4be1 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_expected_path_format;
+
 } LIBOSINFO_0.2.1;
 
 
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index 2292aac..2133618 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_EXPECTED_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_EXPECTED_PATH_FORMAT:
+        g_value_set_enum(value,
+                         osinfo_install_script_get_expected_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("expected-path-format",
+                              "Expected 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_EXPECTED_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_expected_path_format(OsinfoInstallScript *script)
+{
+    return osinfo_entity_get_param_value_enum
+        (OSINFO_ENTITY(script),
+         OSINFO_INSTALL_SCRIPT_PROP_EXPECTED_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..eba8192 100644
--- a/osinfo/osinfo_install_script.h
+++ b/osinfo/osinfo_install_script.h
@@ -46,11 +46,12 @@ typedef struct _OsinfoInstallScriptPrivate OsinfoInstallScriptPrivate;
 #define OSINFO_INSTALL_SCRIPT_PROFILE_JEOS    "jeos"
 #define OSINFO_INSTALL_SCRIPT_PROFILE_DESKTOP "desktop"
 
-#define OSINFO_INSTALL_SCRIPT_PROP_TEMPLATE_URI       "template-uri"
-#define OSINFO_INSTALL_SCRIPT_PROP_TEMPLATE_DATA      "template-data"
-#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_TEMPLATE_URI         "template-uri"
+#define OSINFO_INSTALL_SCRIPT_PROP_TEMPLATE_DATA        "template-data"
+#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_EXPECTED_PATH_FORMAT "expected-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_expected_path_format(OsinfoInstallScript *script);
 
 #endif /* __OSINFO_INSTALL_SCRIPT_H__ */
 /*
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index e7f2c71..6d738cf 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -651,6 +651,15 @@ static void osinfo_loader_install_script(OsinfoLoader *loader,
                                 value);
     g_free(value);
 
+    value = osinfo_loader_string("string(./template/@path-format)", ctxt, err);
+    if (error_is_set(err))
+        goto error;
+    if (value)
+        osinfo_entity_set_param(OSINFO_ENTITY(installScript),
+                                OSINFO_INSTALL_SCRIPT_PROP_EXPECTED_PATH_FORMAT,
+                                value);
+    g_free(value);
+
     osinfo_loader_install_config_params(loader,
                                         OSINFO_ENTITY(installScript),
                                         "./config/*",
-- 
1.8.0




More information about the virt-tools-list mailing list