lib/core: Add API to retrieve all pkgs

Will be used for `compose tree --ex-output-jigdo-set`. Also probably more things
could use this. I first tried just doing another query in the higher level code
but that fails for this case as `sort_packages() reimplements
`dnf_transaction_ensure_repo_list()` which we need to get the `DnfRepo` (which
itself feels like a hack, we should be maintaining that dynamically or have a
hash accessor).

Closes: #1184
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-12-21 06:09:54 +01:00 committed by Atomic Bot
parent 032c1556f4
commit 7fa55f7e5f
3 changed files with 19 additions and 5 deletions

View File

@ -49,6 +49,7 @@ struct _RpmOstreeContext {
gboolean async_running;
GCancellable *async_cancellable;
GError *async_error;
GPtrArray *pkgs; /* All packages */
GPtrArray *pkgs_to_download;
GPtrArray *pkgs_to_import;
guint n_async_pkgs_imported;

View File

@ -274,6 +274,7 @@ rpmostree_context_finalize (GObject *object)
g_clear_pointer (&rctx->passwd_dir, g_free);
g_clear_pointer (&rctx->pkgs, g_ptr_array_unref);
g_clear_pointer (&rctx->pkgs_to_download, g_ptr_array_unref);
g_clear_pointer (&rctx->pkgs_to_import, g_ptr_array_unref);
g_clear_pointer (&rctx->pkgs_to_relabel, g_ptr_array_unref);
@ -1879,11 +1880,12 @@ rpmostree_context_prepare (RpmOstreeContext *self,
rpmostree_output_task_end ("failed");
return FALSE;
}
g_autoptr(GPtrArray) packages = dnf_goal_get_packages (dnf_context_get_goal (dnfctx),
DNF_PACKAGE_INFO_INSTALL,
DNF_PACKAGE_INFO_UPDATE,
DNF_PACKAGE_INFO_DOWNGRADE, -1);
if (!sort_packages (self, packages, cancellable, error))
g_clear_pointer (&self->pkgs, (GDestroyNotify)g_ptr_array_unref);
self->pkgs = dnf_goal_get_packages (dnf_context_get_goal (dnfctx),
DNF_PACKAGE_INFO_INSTALL,
DNF_PACKAGE_INFO_UPDATE,
DNF_PACKAGE_INFO_DOWNGRADE, -1);
if (!sort_packages (self, self->pkgs, cancellable, error))
{
rpmostree_output_task_end ("failed");
return FALSE;
@ -1908,6 +1910,15 @@ rpmostree_context_prepare_jigdo (RpmOstreeContext *self,
return rpmostree_context_prepare (self, cancellable, error);
}
/* Must have invoked rpmostree_context_prepare().
* Returns: (transfer container): All packages in the depsolved list.
*/
GPtrArray *
rpmostree_context_get_packages (RpmOstreeContext *self)
{
return g_ptr_array_ref (self->pkgs);
}
/* Rather than doing a depsolve, directly set which packages
* are required. Will be used by jigdo.
*/

View File

@ -137,6 +137,8 @@ gboolean rpmostree_context_prepare_jigdo (RpmOstreeContext *self,
GCancellable *cancellable,
GError **error);
GPtrArray *rpmostree_context_get_packages (RpmOstreeContext *self);
/* Alternative to _prepare() for non-depsolve cases like jigdo */
gboolean rpmostree_context_set_packages (RpmOstreeContext *self,
GPtrArray *packages,