[Libosinfo] [PATCHv4 08/11] Add osinfo_install_config_new_for_script
Christophe Fergeau
cfergeau at redhat.com
Thu Dec 20 16:45:11 UTC 2012
In order to be able to automatically transform configuration parameters set
on OsinfoInstallConfig instances (ie translate from generic value to
OS-specific value), we need to have access to the
OsinfoInstallConfigParamList for the current OsinfoInstallScript as
this is where the OsinfoDatamaps needed to do the remapping are stored.
After the previous commits we can now associate an
OsinfoInstallConfigParamList with an OsinfoInstallConfig instance,
and we can get the OsinfoInstallConfigParamList corresponding to
an OsinfoInstallScript instance, so this commit just adds a new
osinfo_install_config_new_for_script which will create a new
OsinfoInstallConfig instance associated with the
OsinfoInstallConfigParamList for a given installation script.
---
osinfo/libosinfo.syms | 1 +
osinfo/osinfo_install_config.c | 36 +++++++++++++++++++++++++++++++++---
osinfo/osinfo_install_config.h | 4 ++++
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index a32a8b7..efea371 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -388,6 +388,7 @@ LIBOSINFO_0.2.3 {
osinfo_db_get_datamap_list;
osinfo_db_identify_media;
+ osinfo_install_config_new_for_script;
osinfo_install_config_get_config_params;
osinfo_install_config_paramlist_get_type;
diff --git a/osinfo/osinfo_install_config.c b/osinfo/osinfo_install_config.c
index 4c42746..e61bfb6 100644
--- a/osinfo/osinfo_install_config.c
+++ b/osinfo/osinfo_install_config.c
@@ -189,9 +189,39 @@ osinfo_install_config_init (OsinfoInstallConfig *config)
*/
OsinfoInstallConfig *osinfo_install_config_new(const gchar *id)
{
- return g_object_new(OSINFO_TYPE_INSTALL_CONFIG,
- "id", id,
- NULL);
+ return osinfo_install_config_new_for_script(id, NULL);
+}
+
+
+/**
+ * osinfo_install_config_new_for_script:
+ * @id: the unique identifier
+ * @script: the #OsinfoInstallScript we are creating the configuration for
+ *
+ * Construct a new install configuration associated with @script.
+ * OsinfoInstallConfig:config-params will contain the
+ * #OsinfoInstallConfigParamList describing the parameters that can be set
+ * on the config object when creating a configuration for @script. See
+ * osinfo_install_config_new() for a description of the default values that
+ * will be set on the newly created #OsinfoInstallConfig.
+ *
+ * Returns: (transfer full): an install configuration
+ */
+OsinfoInstallConfig *osinfo_install_config_new_for_script(const gchar *id,
+ OsinfoInstallScript *script)
+{
+ OsinfoInstallConfigParamList *params = NULL;
+ OsinfoInstallConfig *config;
+
+ if (script != NULL)
+ params = osinfo_install_script_get_config_params(script);
+
+ config = g_object_new(OSINFO_TYPE_INSTALL_CONFIG,
+ "id", id,
+ "config-params", params,
+ NULL);
+
+ return config;
}
void osinfo_install_config_set_hardware_arch(OsinfoInstallConfig *config,
diff --git a/osinfo/osinfo_install_config.h b/osinfo/osinfo_install_config.h
index caf5518..112860b 100644
--- a/osinfo/osinfo_install_config.h
+++ b/osinfo/osinfo_install_config.h
@@ -72,6 +72,8 @@ typedef struct _OsinfoInstallConfig OsinfoInstallConfig;
typedef struct _OsinfoInstallConfigClass OsinfoInstallConfigClass;
typedef struct _OsinfoInstallConfigPrivate OsinfoInstallConfigPrivate;
+#include <osinfo/osinfo_install_script.h>
+
/* object */
struct _OsinfoInstallConfig
{
@@ -95,6 +97,8 @@ struct _OsinfoInstallConfigClass
GType osinfo_install_config_get_type(void);
OsinfoInstallConfig *osinfo_install_config_new(const gchar *id);
+OsinfoInstallConfig *osinfo_install_config_new_for_script(const gchar *id,
+ OsinfoInstallScript *script);
void osinfo_install_config_set_hardware_arch(OsinfoInstallConfig *config,
const gchar *arch);
--
1.8.0.2
More information about the Libosinfo
mailing list