[PATCH 04/10] Add osinfo_install_script_generate_command_line_for_media()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add variant of osinfo_install_script_generate_command_line() that takes
(an identified) media instead of an OS. Currently no commandline
template needs access to media but lets add this to be future safe and
be consistent with other osinfo_install_script_generation*() API.
---
 osinfo/libosinfo.syms          |  2 ++
 osinfo/osinfo_install_script.c | 47 ++++++++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_install_script.h |  3 +++
 3 files changed, 52 insertions(+)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 3906f89..68d54ff 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -507,6 +507,8 @@ LIBOSINFO_0.2.11 {
 
 LIBOSINFO_0.2.12 {
     global:
+	osinfo_install_script_generate_command_line_for_media;
+
 	osinfo_install_script_generate_for_media;
 	osinfo_install_script_generate_for_media_async;
 	osinfo_install_script_generate_for_media_finish;
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index 009a473..9863633 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -1593,6 +1593,53 @@ gchar *osinfo_install_script_generate_command_line(OsinfoInstallScript *script,
     return output;
 }
 
+/**
+ * osinfo_install_script_generate_command_line_for_media:
+ * @script: the install script
+ * @media:  the media
+ * @config: the install script config
+ *
+ * Some install scripts need to pass a command line to the kernel, Such install
+ * scripts belong to OSs that provide paths to the kernel and initrd files that
+ * can be used to directly boot
+ * (http://wiki.qemu.org/download/qemu-doc.html#direct_005flinux_005fboot)
+ * the OS in order to pass the needed commandline to it.
+ *
+ * The media @media must have been identified successfully using
+ * #osinfo_db_identify_media() before calling this function.
+ *
+ * Returns: (transfer full): The generated command line string, NULL otherwise.
+ */
+gchar *osinfo_install_script_generate_command_line_for_media(OsinfoInstallScript *script,
+                                                             OsinfoMedia *media,
+                                                             OsinfoInstallConfig *config)
+{
+    const gchar *templateData = osinfo_install_script_get_template_data(script);
+    gchar *output = NULL;
+    OsinfoOs *os;
+
+    g_return_val_if_fail(media != NULL, NULL);
+
+    os = osinfo_media_get_os(media);
+    g_return_val_if_fail(os != NULL, NULL);
+
+    if (templateData) {
+        GError *error = NULL;
+        if (!osinfo_install_script_apply_template(script,
+                                                  os,
+                                                  media,
+                                                  "<data>",
+                                                  templateData,
+                                                  "command-line",
+                                                  &output,
+                                                  config,
+                                                  &error)) {
+            g_prefix_error(&error, "%s", _("Failed to apply script template: "));
+        }
+    }
+
+    return output;
+}
 
 OsinfoPathFormat osinfo_install_script_get_path_format(OsinfoInstallScript *script)
 {
diff --git a/osinfo/osinfo_install_script.h b/osinfo/osinfo_install_script.h
index 0a6afcb..c494192 100644
--- a/osinfo/osinfo_install_script.h
+++ b/osinfo/osinfo_install_script.h
@@ -235,6 +235,9 @@ GFile *osinfo_install_script_generate_output_for_media(OsinfoInstallScript *scri
 gchar *osinfo_install_script_generate_command_line(OsinfoInstallScript *script,
                                                    OsinfoOs *os,
                                                    OsinfoInstallConfig *config);
+gchar *osinfo_install_script_generate_command_line_for_media(OsinfoInstallScript *script,
+                                                             OsinfoMedia *media,
+                                                             OsinfoInstallConfig *config);
 
 gboolean osinfo_install_script_has_config_param(const OsinfoInstallScript *script, const OsinfoInstallConfigParam *config_param);
 
-- 
2.1.0

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux