[Libosinfo] [libosinfo PATCH v2 7/7] db: deprecate osinfo_db_guess_os_from_tree()

Fabiano Fidêncio fidencio at redhat.com
Wed Jun 26 11:27:10 UTC 2019


Let's deprecate osinfo_db_guess_os_from_tree() and "force" the apps to
use the new/simpler API.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 osinfo/osinfo_db.c | 41 +++++++++++++++++++++++++----------------
 osinfo/osinfo_db.h |  1 +
 tests/test-db.c    | 37 -------------------------------------
 3 files changed, 26 insertions(+), 53 deletions(-)

diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index 56b868c..43b66eb 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -840,20 +840,10 @@ static gboolean compare_tree(OsinfoTree *tree,
     return FALSE;
 }
 
-/**
- * osinfo_db_guess_os_from_tree:
- * @db: the database
- * @tree: the installation tree
- * @matched_tree: (out) (transfer none) (allow-none): the matched operating
- * system tree
- *
- * Guess operating system given an #OsinfoTree object.
- *
- * Returns: (transfer none): the operating system, or NULL if guessing failed
- */
-OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db,
-                                       OsinfoTree *tree,
-                                       OsinfoTree **matched_tree)
+static OsinfoOs *
+osinfo_db_guess_os_from_tree_internal(OsinfoDb *db,
+                                      OsinfoTree *tree,
+                                      OsinfoTree **matched_tree)
 {
     OsinfoOs *ret = NULL;
     GList *oss = NULL;
@@ -875,6 +865,25 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db,
     return ret;
 }
 
+/**
+ * osinfo_db_guess_os_from_tree:
+ * @db: the database
+ * @tree: the installation tree
+ * @matched_tree: (out) (transfer none) (allow-none): the matched operating
+ * system tree
+ *
+ * Guess operating system given an #OsinfoTree object.
+ *
+ * Returns: (transfer none): the operating system, or NULL if guessing failed
+ * Deprecated: 1.6.0: Use osinfo_db_identify_tree() instead.
+ */
+OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db,
+                                       OsinfoTree *tree,
+                                       OsinfoTree **matched_tree)
+{
+    return osinfo_db_guess_os_from_tree_internal(db, tree, matched_tree);
+}
+
 static void fill_tree(OsinfoDb *db, OsinfoTree *tree,
                       OsinfoTree *matched_tree,
                       OsinfoOs *os)
@@ -969,8 +978,8 @@ gboolean osinfo_db_identify_tree(OsinfoDb *db,
     g_return_val_if_fail(OSINFO_IS_TREE(tree), FALSE);
     g_return_val_if_fail(OSINFO_IS_DB(db), FALSE);
 
-    matched_os = osinfo_db_guess_os_from_tree(db, tree,
-                                              &matched_tree);
+    matched_os = osinfo_db_guess_os_from_tree_internal(db, tree,
+                                                       &matched_tree);
     if (matched_os == NULL) {
         return FALSE;
     }
diff --git a/osinfo/osinfo_db.h b/osinfo/osinfo_db.h
index 7702739..a35f9b4 100644
--- a/osinfo/osinfo_db.h
+++ b/osinfo/osinfo_db.h
@@ -107,6 +107,7 @@ OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db,
 gboolean osinfo_db_identify_media(OsinfoDb *db,
                                   OsinfoMedia *media);
 
+G_DEPRECATED_FOR(osinfo_db_identify_tree)
 OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db,
                                        OsinfoTree *tree,
                                        OsinfoTree **matched_tree);
diff --git a/tests/test-db.c b/tests/test-db.c
index b7f83d7..f21654f 100644
--- a/tests/test-db.c
+++ b/tests/test-db.c
@@ -492,42 +492,6 @@ create_tree(const gchar *arch, gboolean set_treeinfo_arch)
 }
 
 
-static void
-test_guess_os_from_tree(void)
-{
-    OsinfoLoader *loader = osinfo_loader_new();
-    OsinfoDb *db;
-    OsinfoTree *tree;
-    OsinfoTree *matched_tree = NULL;
-    OsinfoOs *os;
-
-    GError *error = NULL;
-
-    osinfo_loader_process_path(loader, SRCDIR "/tests/dbdata", &error);
-    g_assert_no_error(error);
-    db = osinfo_loader_get_db(loader);
-
-    /* Matching against an "all" architecture" */
-    tree = create_tree("x86_64", FALSE);
-    os = osinfo_db_guess_os_from_tree(db, tree, &matched_tree);
-    g_assert_nonnull(os);
-    g_assert_nonnull(matched_tree);
-    g_assert_cmpstr(osinfo_tree_get_architecture(matched_tree), ==, "all");
-    g_object_unref(tree);
-    matched_tree = NULL;
-
-    /* Matching against a known architecture, which has to have precendence */
-    tree = create_tree("i686", TRUE);
-    os = osinfo_db_guess_os_from_tree(db, tree, &matched_tree);
-    g_assert_nonnull(os);
-    g_assert_nonnull(matched_tree);
-    g_assert_cmpstr(osinfo_tree_get_architecture(matched_tree), ==, "i686");
-
-    g_object_unref(tree);
-    g_object_unref(loader);
-}
-
-
 static void
 test_identify_tree(void)
 {
@@ -571,7 +535,6 @@ main(int argc, char *argv[])
     g_test_add_func("/db/prop_os", test_prop_os);
     g_test_add_func("/db/rel_os", test_rel_os);
     g_test_add_func("/db/identify_media", test_identify_media);
-    g_test_add_func("/db/guess_os_from_tree", test_guess_os_from_tree);
     g_test_add_func("/db/identify_tree", test_identify_tree);
 
     /* Upfront so we don't confuse valgrind */
-- 
2.21.0




More information about the Libosinfo mailing list