daemon/upgrader: Reuse sack from core for advisories
In #1344, we changed `upgrade` to always write the cached update. One thing I hadn't noticed was that with pkglayering, loading the sack twice meant we printed all that gory repo info twice. Really, the much nicer thing to do is just to make an effort to try to *keep* the original sack that the core used so that we skip all that overhead completely. Closes: #1357 Approved by: cgwalters
This commit is contained in:
parent
ab5452bc3a
commit
33ea6fbc96
@ -67,9 +67,10 @@ struct RpmOstreeSysrootUpgrader {
|
||||
/* Used during tree construction */
|
||||
OstreeRepoDevInoCache *devino_cache;
|
||||
int tmprootfs_dfd;
|
||||
RpmOstreeRefSack *rsack;
|
||||
RpmOstreeRefSack *rsack; /* sack of base layer */
|
||||
GLnxTmpDir metatmpdir;
|
||||
RpmOstreeContext *ctx;
|
||||
DnfSack *rpmmd_sack; /* sack from core */
|
||||
|
||||
GPtrArray *overlay_packages; /* Finalized list of pkgs to overlay */
|
||||
GPtrArray *override_remove_packages; /* Finalized list of base pkgs to remove */
|
||||
@ -200,7 +201,8 @@ rpmostree_sysroot_upgrader_finalize (GObject *object)
|
||||
RpmOstreeSysrootUpgrader *self = RPMOSTREE_SYSROOT_UPGRADER (object);
|
||||
|
||||
g_clear_pointer (&self->rsack, rpmostree_refsack_unref);
|
||||
g_clear_object (&self->ctx);
|
||||
g_clear_object (&self->rpmmd_sack);
|
||||
g_clear_object (&self->ctx); /* Note this is already cleared in the happy path */
|
||||
glnx_close_fd (&self->tmprootfs_dfd);
|
||||
|
||||
(void)glnx_tmpdir_delete (&self->metatmpdir, NULL, NULL);
|
||||
@ -363,6 +365,14 @@ rpmostree_sysroot_upgrader_get_merge_deployment (RpmOstreeSysrootUpgrader *self)
|
||||
return self->origin_merge_deployment;
|
||||
}
|
||||
|
||||
/* Returns DnfSack used, if any. */
|
||||
DnfSack*
|
||||
rpmostree_sysroot_upgrader_get_sack (RpmOstreeSysrootUpgrader *self,
|
||||
GError **error)
|
||||
{
|
||||
return self->rpmmd_sack;
|
||||
}
|
||||
|
||||
/*
|
||||
* Like ostree_sysroot_upgrader_pull(), but also handles the `baserefspec` we
|
||||
* use when doing layered packages.
|
||||
@ -891,6 +901,10 @@ prep_local_assembly (RpmOstreeSysrootUpgrader *self,
|
||||
if (!rpmostree_context_prepare (self->ctx, cancellable, error))
|
||||
return FALSE;
|
||||
self->layering_type = RPMOSTREE_SYSROOT_UPGRADER_LAYERING_RPMMD_REPOS;
|
||||
|
||||
/* keep a ref on it in case the level higher up needs it */
|
||||
self->rpmmd_sack =
|
||||
g_object_ref (dnf_context_get_sack (rpmostree_context_get_dnf (self->ctx)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -87,6 +87,10 @@ rpmostree_sysroot_upgrader_set_origin (RpmOstreeSysrootUpgrader *self,
|
||||
const char *
|
||||
rpmostree_sysroot_upgrader_get_base (RpmOstreeSysrootUpgrader *self);
|
||||
|
||||
DnfSack*
|
||||
rpmostree_sysroot_upgrader_get_sack (RpmOstreeSysrootUpgrader *self,
|
||||
GError **error);
|
||||
|
||||
gboolean
|
||||
rpmostree_sysroot_upgrader_pull_base (RpmOstreeSysrootUpgrader *self,
|
||||
const char *dir_to_pull,
|
||||
|
@ -943,7 +943,7 @@ gboolean
|
||||
rpmostreed_update_generate_variant (OstreeDeployment *booted_deployment,
|
||||
OstreeDeployment *staged_deployment,
|
||||
OstreeRepo *repo,
|
||||
DnfSack *sack,
|
||||
DnfSack *sack, /* allow-none */
|
||||
GVariant **out_update,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
|
@ -198,7 +198,7 @@ static gboolean
|
||||
generate_update_variant (OstreeRepo *repo,
|
||||
OstreeDeployment *booted_deployment,
|
||||
OstreeDeployment *staged_deployment,
|
||||
DnfSack *sack,
|
||||
DnfSack *sack, /* allow-none */
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
@ -1189,15 +1189,7 @@ deploy_transaction_execute (RpmostreedTransaction *transaction,
|
||||
OstreeDeployment *booted_deployment =
|
||||
ostree_sysroot_get_booted_deployment (sysroot);
|
||||
|
||||
g_autoptr(DnfSack) sack = NULL;
|
||||
if (g_hash_table_size (rpmostree_origin_get_packages (origin)) > 0)
|
||||
{
|
||||
/* don't force a refresh; we want the same sack state used by the core */
|
||||
if (!get_sack_for_booted (sysroot, repo, booted_deployment, FALSE, &sack,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DnfSack *sack = rpmostree_sysroot_upgrader_get_sack (upgrader, error);
|
||||
if (!generate_update_variant (repo, booted_deployment, new_deployment, sack,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user