yum: adjust to the Zif 0.1.3 API break

This commit is contained in:
Richard Hughes 2010-11-12 09:04:24 +00:00
parent 6de193a6f0
commit 41b47cbe5f

View File

@ -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; j<array_tmp->len; 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",