[libosinfo PATCH v2 6/7] tools, detect: Use osinfo_db_identify_tree()

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

 



Let's switch osinfo-detect to use the new API as the old one will end up
being deprecated soon.

Also,, the code path for medias and trees is now way more similar with
the changes.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 tools/osinfo-detect.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/tools/osinfo-detect.c b/tools/osinfo-detect.c
index c21e694..feb9978 100644
--- a/tools/osinfo-detect.c
+++ b/tools/osinfo-detect.c
@@ -173,8 +173,11 @@ static void print_media(OsinfoMedia *media)
     g_object_unref(os);
 }
 
-static void print_os_tree(OsinfoOs *os, OsinfoTree *tree, OsinfoTree *matched_tree)
+static void print_tree(OsinfoTree *tree)
 {
+    OsinfoOs *os;
+
+    g_object_get(G_OBJECT(tree), "os", &os, NULL);
     if (os == NULL)
         return;
 
@@ -185,15 +188,15 @@ static void print_os_tree(OsinfoOs *os, OsinfoTree *tree, OsinfoTree *matched_tr
         const gchar *bootiso = osinfo_tree_get_boot_iso_path(tree);
 
         if (!kernel)
-            kernel = osinfo_tree_get_kernel_path(matched_tree);
+            kernel = osinfo_tree_get_kernel_path(tree);
         if (!initrd)
-            initrd = osinfo_tree_get_initrd_path(matched_tree);
+            initrd = osinfo_tree_get_initrd_path(tree);
         if (!bootiso)
-            bootiso = osinfo_tree_get_boot_iso_path(matched_tree);
+            bootiso = osinfo_tree_get_boot_iso_path(tree);
 
         g_print("OSINFO_INSTALLER=%s\n", id);
         g_print("OSINFO_TREE=%s\n",
-                osinfo_entity_get_id(OSINFO_ENTITY(matched_tree)));
+                osinfo_entity_get_id(OSINFO_ENTITY(tree)));
         if (kernel)
             g_print("OSINFO_TREE_KERNEL=%s\n", kernel);
         if (initrd)
@@ -205,7 +208,7 @@ static void print_os_tree(OsinfoOs *os, OsinfoTree *tree, OsinfoTree *matched_tr
         const gchar *name;
         guint num_variants;
 
-        variants = osinfo_tree_get_os_variants(matched_tree);
+        variants = osinfo_tree_get_os_variants(tree);
         num_variants = osinfo_list_get_length(OSINFO_LIST(variants));
         if (num_variants == 1) {
             OsinfoEntity *variant;
@@ -299,9 +302,7 @@ gint main(gint argc, gchar **argv)
         osinfo_db_identify_media(db, media);
         print_media(media);
     } else if (type == URL_TYPE_TREE) {
-        OsinfoOs *os = NULL;
         OsinfoTree *tree = NULL;
-        OsinfoTree *matched_tree = NULL;
         tree = osinfo_tree_create_from_location(argv[1], NULL, &error);
         if (error != NULL) {
             g_printerr(_("Error parsing installer tree: %s\n"), error->message);
@@ -309,8 +310,8 @@ gint main(gint argc, gchar **argv)
             ret = -3;
             goto EXIT;
         }
-        os = osinfo_db_guess_os_from_tree(db, tree, &matched_tree);
-        print_os_tree(os, tree, matched_tree);
+        osinfo_db_identify_tree(db, tree);
+        print_tree(tree);
     }
 
 
-- 
2.21.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