summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2014-03-06 16:22:47 +0100
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>2014-03-06 21:38:12 +0000
commit4a8aaa752776ff18d85ae1ebc9bf0e35cbe91387 (patch)
treedc91d82f0228495ca37709fd9885176e70e1646a
parent036b1fcfc8d7899344c8c4bdd6b79eda7aed2221 (diff)
downloadlibosinfo-4a8aaa752776ff18d85ae1ebc9bf0e35cbe91387.tar.gz
installer: Add get_injection_methods()
The API allows applications to query the available methods to inject the script to the installation process. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r--data/schemas/libosinfo.rng11
-rw-r--r--osinfo/libosinfo.syms5
-rw-r--r--osinfo/osinfo_install_script.c19
-rw-r--r--osinfo/osinfo_install_script.h27
-rw-r--r--osinfo/osinfo_loader.c23
5 files changed, 81 insertions, 4 deletions
diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng
index 0675217..4f4edac 100644
--- a/data/schemas/libosinfo.rng
+++ b/data/schemas/libosinfo.rng
@@ -616,6 +616,9 @@
<ref name='driver-signing-reqs'/>
</element>
</optional>
+ <zeroOrMore>
+ <ref name='injection-method'/>
+ </zeroOrMore>
<element name='template'>
<choice>
<group>
@@ -770,4 +773,12 @@
</data>
</element>
</define>
+
+ <define name='injection-method'>
+ <element name='injection-method'>
+ <data type="string">
+ <param name="pattern">cdrom|disk|floppy|initrd|web</param>
+ </data>
+ </element>
+ </define>
</grammar>
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index c3b967c..abcc8bb 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -495,6 +495,11 @@ LIBOSINFO_0.2.9 {
osinfo_release_status_get_type;
} LIBOSINFO_0.2.8;
+LIBOSINFO_0.2.10 {
+ osinfo_install_script_get_injection_methods;
+ osinfo_install_script_injection_method_get_type;
+} LIBOSINFO_0.2.9;
+
/* Symbols in next release...
LIBOSINFO_0.0.2 {
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index 7444c8d..1a0b579 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -1,7 +1,7 @@
/*
* libosinfo:
*
- * Copyright (C) 2009-2012 Red Hat, Inc.
+ * Copyright (C) 2009-2012, 2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1309,6 +1309,23 @@ int osinfo_install_script_get_post_install_drivers_signing_req(OsinfoInstallScri
OSINFO_DEVICE_DRIVER_SIGNING_REQ_NONE);
}
+/**
+ * osinfo_install_script_get_injection_methods:
+ * @script: the install script
+ *
+ * Retrieve the supported method to inject the script in to the installation process.
+ *
+ * Returns: (type OsinfoInstallScriptInjectionMethod): bitwise-or of
+ * supported methods for install script injection.
+ */
+unsigned int osinfo_install_script_get_injection_methods(OsinfoInstallScript *script)
+{
+ return osinfo_entity_get_param_value_int64_with_default
+ (OSINFO_ENTITY(script),
+ OSINFO_INSTALL_SCRIPT_PROP_INJECTION_METHOD,
+ 0);
+}
+
/*
* Local variables:
diff --git a/osinfo/osinfo_install_script.h b/osinfo/osinfo_install_script.h
index c39b786..d328a96 100644
--- a/osinfo/osinfo_install_script.h
+++ b/osinfo/osinfo_install_script.h
@@ -1,7 +1,7 @@
/*
* libosinfo: OS installation script
*
- * Copyright (C) 2009-2012 Red Hat, Inc.
+ * Copyright (C) 2009-2012, 2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -57,6 +57,7 @@ typedef struct _OsinfoInstallScriptPrivate OsinfoInstallScriptPrivate;
#define OSINFO_INSTALL_SCRIPT_PROP_CAN_POST_INSTALL_DRIVERS "can-post-install-drivers"
#define OSINFO_INSTALL_SCRIPT_PROP_PRE_INSTALL_DRIVERS_SIGNING_REQ "pre-install-drivers-signing-req"
#define OSINFO_INSTALL_SCRIPT_PROP_POST_INSTALL_DRIVERS_SIGNING_REQ "post-install-drivers-signing-req"
+#define OSINFO_INSTALL_SCRIPT_PROP_INJECTION_METHOD "injection-method"
/* object */
struct _OsinfoInstallScript
@@ -113,6 +114,28 @@ typedef enum {
OSINFO_DEVICE_DRIVER_SIGNING_REQ_WARN
} OsinfoDeviceDriverSigningReq;
+/**
+ * OsinfoInstallScriptInjectionMethod:
+ *
+ * @OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_CDROM: Support injection of the
+ * installation script trough a CD-ROM.
+ * @OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_DISK: Support injection of the
+ * installation script trough a disk.
+ * @OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_FLOPPY: Support injection of the
+ * installation script trough a floppy disk.
+ * @OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_INITRD: Support injection of the
+ * installation script trough the initrd.
+ * @OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_WEB: Support injection of the
+ * installation script from the web.
+ */
+typedef enum {
+ OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_CDROM = 1 << 0,
+ OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_DISK = 1 << 1,
+ OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_FLOPPY = 1 << 2,
+ OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_INITRD = 1 << 3,
+ OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_WEB = 1 << 4,
+} OsinfoInstallScriptInjectionMethod;
+
GType osinfo_install_script_get_type(void);
OsinfoInstallScript *osinfo_install_script_new(const gchar *id);
@@ -195,6 +218,8 @@ gboolean osinfo_install_script_get_can_post_install_drivers(OsinfoInstallScript
int osinfo_install_script_get_pre_install_drivers_signing_req(OsinfoInstallScript *script);
int osinfo_install_script_get_post_install_drivers_signing_req(OsinfoInstallScript *script);
+unsigned int osinfo_install_script_get_injection_methods(OsinfoInstallScript *script);
+
#endif /* __OSINFO_INSTALL_SCRIPT_H__ */
/*
* Local variables:
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index e9ce8e1..aa5e48f 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -1,7 +1,7 @@
/*
* libosinfo:
*
- * Copyright (C) 2009-2012 Red Hat, Inc.
+ * Copyright (C) 2009-2012, 2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -777,7 +777,9 @@ static void osinfo_loader_install_script(OsinfoLoader *loader,
};
gchar *value = NULL;
xmlNodePtr *nodes = NULL;
- int nnodes;
+ int i, nnodes;
+ unsigned int injection_methods = 0;
+ GFlagsClass *flags_class;
if (!id) {
OSINFO_ERROR(err, _("Missing install script id property"));
@@ -835,6 +837,23 @@ static void osinfo_loader_install_script(OsinfoLoader *loader,
}
g_free(nodes);
+ nnodes = osinfo_loader_nodeset("./injection-method", ctxt, &nodes, err);
+ if (error_is_set(err))
+ goto error;
+
+ flags_class = g_type_class_ref(OSINFO_TYPE_INSTALL_SCRIPT_INJECTION_METHOD);
+ for (i = 0 ; i < nnodes ; i++) {
+ const gchar *nick = (const gchar *) nodes[i]->children->content;
+ injection_methods |= g_flags_get_value_by_nick(flags_class, nick)->value;
+ }
+ osinfo_entity_set_param_int64(OSINFO_ENTITY(installScript),
+ OSINFO_INSTALL_SCRIPT_PROP_INJECTION_METHOD,
+ injection_methods);
+
+ g_type_class_unref(flags_class);
+ g_free(nodes);
+
+
osinfo_db_add_install_script(loader->priv->db, installScript);
return;