[Libosinfo] [libosinfo PATCH 5/7] install-script: Add _{get|set}_installation_source()

Fabiano Fidêncio fidencio at redhat.com
Mon Dec 3 09:11:50 UTC 2018


As install-scripts may behave differently depending on their
installation source, let's add two new methods to properly set what's
the installation source being used with the script and then decide what
we should do depending on the installation-source value.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 osinfo/libosinfo.syms          |  3 ++
 osinfo/osinfo_install_script.c | 58 +++++++++++++++++++++++++++++++++-
 osinfo/osinfo_install_script.h | 11 +++++++
 3 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 26298df..e744c11 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -536,7 +536,10 @@ LIBOSINFO_1.3.0 {
 
 	osinfo_error_quark;
 
+	osinfo_install_script_get_installation_source;
 	osinfo_install_script_get_preferred_injection_method;
+	osinfo_install_script_installation_source_get_type;
+	osinfo_install_script_set_installation_source;
 	osinfo_install_script_set_preferred_injection_method;
 
 	osinfo_os_add_maximum_resources;
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index 10cb5f3..140cdf5 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -64,7 +64,8 @@ enum {
     PROP_PRODUCT_KEY_FORMAT,
     PROP_PATH_FORMAT,
     PROP_AVATAR_FORMAT,
-    PROP_PREFERRED_INJECTION_METHOD
+    PROP_PREFERRED_INJECTION_METHOD,
+    PROP_INSTALLATION_SOURCE
 };
 
 typedef struct _OsinfoInstallScriptGenerateData OsinfoInstallScriptGenerateData;
@@ -111,6 +112,11 @@ osinfo_install_script_set_property(GObject    *object,
                                                              g_value_get_flags(value));
         break;
 
+    case PROP_INSTALLATION_SOURCE:
+        osinfo_install_script_set_installation_source(script,
+                                                      g_value_get_enum(value));
+        break;
+
     default:
         /* We don't have any other property... */
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
@@ -162,6 +168,11 @@ osinfo_install_script_get_property(GObject    *object,
                           osinfo_install_script_get_preferred_injection_method(script));
         break;
 
+    case PROP_INSTALLATION_SOURCE:
+        g_value_set_enum(value,
+                         osinfo_install_script_get_installation_source(script));
+        break;
+
     default:
         /* We don't have any other property... */
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
@@ -276,6 +287,17 @@ osinfo_install_script_class_init(OsinfoInstallScriptClass *klass)
                                     PROP_PREFERRED_INJECTION_METHOD,
                                     pspec);
 
+    pspec = g_param_spec_enum("installation-source",
+                              "Installation Source",
+                              _("The installation source to be used"),
+                              OSINFO_TYPE_INSTALL_SCRIPT_INSTALLATION_SOURCE,
+                              OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_MEDIA,
+                              G_PARAM_READABLE |
+                              G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(g_klass,
+                                    PROP_INSTALLATION_SOURCE,
+                                    pspec);
+
     g_type_class_add_private(klass, sizeof(OsinfoInstallScriptPrivate));
 }
 
@@ -1845,6 +1867,40 @@ osinfo_install_script_get_preferred_injection_method(OsinfoInstallScript *script
          default_preferred);
 }
 
+/**
+ * osinfo_install_script_set_installation_source:
+ * @script: the install script
+ * @source: one of the installation sources:
+ * OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_MEDIA,
+ * OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_NETWORK
+ *
+ * Set the installation source to be used with the @script.
+ */
+void osinfo_install_script_set_installation_source(OsinfoInstallScript *script,
+                                                   OsinfoInstallScriptInstallationSource source)
+{
+    osinfo_entity_set_param_enum(OSINFO_ENTITY(script),
+            OSINFO_INSTALL_SCRIPT_PROP_INSTALLATION_SOURCE,
+            source,
+            OSINFO_TYPE_INSTALL_SCRIPT_INSTALLATION_SOURCE);
+}
+
+/**
+ * osinfo_install_script_get_installation_source:
+ * @script: the install script
+ *
+ * Returns: the installation source to be used with the script. If none is set, it defaults to
+ * OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_MEDIA.
+ */
+OsinfoInstallScriptInstallationSource
+osinfo_install_script_get_installation_source(OsinfoInstallScript *script)
+{
+    return osinfo_entity_get_param_value_enum(OSINFO_ENTITY(script),
+            OSINFO_INSTALL_SCRIPT_PROP_INSTALLATION_SOURCE,
+            OSINFO_TYPE_INSTALL_SCRIPT_INSTALLATION_SOURCE,
+            OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_MEDIA);
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: nil
diff --git a/osinfo/osinfo_install_script.h b/osinfo/osinfo_install_script.h
index ed634db..3e513e6 100644
--- a/osinfo/osinfo_install_script.h
+++ b/osinfo/osinfo_install_script.h
@@ -61,6 +61,7 @@ typedef struct _OsinfoInstallScriptPrivate OsinfoInstallScriptPrivate;
 #define OSINFO_INSTALL_SCRIPT_PROP_POST_INSTALL_DRIVERS_SIGNING_REQ "post-install-drivers-signing-req"
 #define OSINFO_INSTALL_SCRIPT_PROP_INJECTION_METHOD "injection-method"
 #define OSINFO_INSTALL_SCRIPT_PROP_PREFERRED_INJECTION_METHOD "preferred-injection-method"
+#define OSINFO_INSTALL_SCRIPT_PROP_INSTALLATION_SOURCE "installation-source"
 
 /* object */
 struct _OsinfoInstallScript
@@ -135,6 +136,11 @@ typedef enum {
     OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_WEB    = 1 << 4,
 } OsinfoInstallScriptInjectionMethod;
 
+typedef enum {
+    OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_MEDIA,
+    OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_NETWORK
+} OsinfoInstallScriptInstallationSource;
+
 GType osinfo_install_script_get_type(void);
 
 OsinfoInstallScript *osinfo_install_script_new(const gchar *id);
@@ -259,6 +265,11 @@ gboolean osinfo_install_script_get_needs_internet(OsinfoInstallScript *script);
 void osinfo_install_script_set_preferred_injection_method(OsinfoInstallScript *script,
                                                           OsinfoInstallScriptInjectionMethod method);
 OsinfoInstallScriptInjectionMethod osinfo_install_script_get_preferred_injection_method(OsinfoInstallScript *script);
+
+void osinfo_install_script_set_installation_source(OsinfoInstallScript *script,
+                                                   OsinfoInstallScriptInstallationSource installer);
+OsinfoInstallScriptInstallationSource osinfo_install_script_get_installation_source(OsinfoInstallScript *script);
+
 #endif /* __OSINFO_INSTALL_SCRIPT_H__ */
 /*
  * Local variables:
-- 
2.19.1




More information about the Libosinfo mailing list