[virt-tools-list] [libosinfo 4/8] Fill in media with guessed info in Db::guess_os_from_media

Christophe Fergeau cfergeau at redhat.com
Mon Dec 3 11:23:33 UTC 2012


---
 osinfo/osinfo_db.c    | 35 +++++++++++++++++++++++++++++++++++
 tools/osinfo-detect.c |  5 ++---
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index 935e299..665554c 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -391,6 +391,40 @@ static gint media_volume_compare (gconstpointer a, gconstpointer b)
         return 1;
 }
 
+static void fill_media (OsinfoMedia *media, OsinfoMedia *matched_media)
+{
+    gboolean is_installer;
+    gboolean is_live;
+    gint reboots;
+    const gchar *kernel_path;
+    const gchar *initrd_path;
+    const gchar *arch;
+    const gchar *url;
+
+    arch = osinfo_media_get_architecture(matched_media);
+    if (arch != NULL)
+        g_object_set(G_OBJECT(media), "architecture", arch, NULL);
+    url = osinfo_media_get_url(matched_media);
+    if (url != NULL)
+        g_object_set(G_OBJECT(media), "url", url, NULL);
+
+    kernel_path = osinfo_media_get_kernel_path(matched_media);
+    if (kernel_path != NULL)
+        g_object_set(G_OBJECT(media), "kernel_path", kernel_path, NULL);
+
+    initrd_path = osinfo_media_get_initrd_path(matched_media);
+    if (initrd_path != NULL)
+        g_object_set(G_OBJECT(media), "initrd_path", initrd_path, NULL);
+    is_installer = osinfo_media_get_installer(matched_media);
+    is_live = osinfo_media_get_live(matched_media);
+    reboots = osinfo_media_get_installer_reboots(matched_media);
+    g_object_set(G_OBJECT(media),
+                 "installer", is_installer,
+                 "live", is_live,
+                 "installer-reboots", reboots,
+                 NULL);
+}
+
 /**
  * osinfo_db_guess_os_from_media:
  * @db: the database
@@ -443,6 +477,7 @@ OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db,
                 match_regex (os_system, media_system) &&
                 match_regex (os_publisher, media_publisher)) {
                 ret = os;
+                fill_media(media, os_media);
                 if (matched_media != NULL)
                     *matched_media = os_media;
                 break;
diff --git a/tools/osinfo-detect.c b/tools/osinfo-detect.c
index 60aabba..944e72d 100644
--- a/tools/osinfo-detect.c
+++ b/tools/osinfo-detect.c
@@ -227,7 +227,6 @@ gint main(gint argc, gchar **argv)
 
     if (type == URL_TYPE_MEDIA) {
         OsinfoMedia *media = NULL;
-        OsinfoMedia *matched_media = NULL;
         media = osinfo_media_create_from_location(argv[1], NULL, &error);
         if (error != NULL) {
             if (error->code != OSINFO_MEDIA_ERROR_NOT_BOOTABLE) {
@@ -241,8 +240,8 @@ gint main(gint argc, gchar **argv)
         } else {
             print_bootable(TRUE);
         }
-        os = osinfo_db_guess_os_from_media(db, media, &matched_media);
-        print_os_media(os, matched_media);
+        os = osinfo_db_guess_os_from_media(db, media, NULL);
+        print_os_media(os, media);
     } else if (type == URL_TYPE_TREE) {
         OsinfoTree *tree = NULL;
         OsinfoTree *matched_tree = NULL;
-- 
1.8.0.1




More information about the virt-tools-list mailing list