From 41b47cbe5fd7f33987301723c18f19a87a69e3ba Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 12 Nov 2010 09:04:24 +0000 Subject: [PATCH] yum: adjust to the Zif 0.1.3 API break --- backends/yum/pk-backend-yum.c | 64 ++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c index 897db7cf8..b9802c090 100644 --- a/backends/yum/pk-backend-yum.c +++ b/backends/yum/pk-backend-yum.c @@ -783,6 +783,64 @@ out: return array_retval; } +/** + * pk_backend_what_provides_helper: + */ +static GPtrArray * +pk_backend_what_provides_helper (GPtrArray *store_array, gchar **search, ZifState *state, GError **error) +{ + gboolean ret; + GPtrArray *array = NULL; + GPtrArray *array_retval = NULL; + GPtrArray *array_tmp; + guint i, j; + ZifDepend *depend; + ZifPackage *package; + ZifState *state_local; + + /* set steps */ + zif_state_set_number_steps (state, g_strv_length (search)); + + /* resolve all the groups */ + array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); + for (i=0; search[i] != NULL; i++) { + state_local = zif_state_get_child (state); + + /* parse this depend */ + depend = zif_depend_new (); + ret = zif_depend_parse_description (depend, search[i], error); + if (!ret) + goto out; + + /* find what provides this depend */ + array_tmp = zif_store_array_what_provides (store_array, depend, state_local, error); + g_object_unref (depend); + if (array_tmp == NULL) + goto out; + + /* add each result */ + for (j=0; jlen; j++) { + package = g_ptr_array_index (array_tmp, i); + g_ptr_array_add (array, g_object_ref (package)); + } + g_ptr_array_unref (array_tmp); + + /* set steps */ + zif_state_set_number_steps (state_local, 2); + + /* this part done */ + ret = zif_state_done (state, error); + if (!ret) + goto out; + } + + /* success */ + array_retval = g_ptr_array_ref (array); +out: + if (array != NULL) + g_ptr_array_unref (array); + return array_retval; +} #endif /** @@ -896,7 +954,7 @@ pk_backend_search_thread (PkBackend *backend) array = zif_store_array_resolve (store_array, search, state_local, &error); } } else if (role == PK_ROLE_ENUM_WHAT_PROVIDES) { - array = zif_store_array_what_provides (store_array, search, state_local, &error); + array = pk_backend_what_provides_helper (store_array, search, state_local, &error); } if (array == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "failed to search: %s", error->message); @@ -1655,7 +1713,6 @@ pk_backend_get_depends_thread (PkBackend *backend) GPtrArray *result; GPtrArray *requires; GPtrArray *provides; - const gchar *to_array[] = { NULL, NULL }; len = g_strv_length (package_ids); @@ -1736,8 +1793,7 @@ pk_backend_get_depends_thread (PkBackend *backend) require = g_ptr_array_index (requires, k); /* find the package providing the depend */ - to_array[0] = zif_depend_get_name (require); - provides = zif_store_array_what_provides (store_array, (gchar**)to_array, state_loop_inner, &error); + provides = zif_store_array_what_provides (store_array, require, state_loop_inner, &error); if (provides == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "failed to find provide for %s: %s",