Skip to content

Commit

Permalink
daemon/upgrader: Consistently remove transient state
Browse files Browse the repository at this point in the history
With the new support for pinning deployments, we need to also update
rpm-ostree to clean up the transient state as is now done in the ostree
sysroot upgrader.

This addresses that issue as well as tries to be a little cleaner in how
we clean up other transient state. Notably, we add a new helper function
to `RpmOstreeOrigin` to do this for us and use it in the upgrader. In
other cases, we do want this transient information since it allows us to
describe the deployment.

Closes: ostreedev/ostree#1595
  • Loading branch information
jlebon committed May 22, 2018
1 parent 99901ac commit e9e9569
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/daemon/rpmostree-sysroot-upgrader.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@ parse_origin_deployment (RpmOstreeSysrootUpgrader *self,
return FALSE;
}

/* A bit hacky; here we clean out the live state which is deployment specific.
* We don't expect users of the upgrader to want the live state.
*/
rpmostree_origin_set_live_state (self->origin, NULL, NULL);
/* Remove the things we wouldn't want to carry over from a previous deployment. */
rpmostree_origin_remove_transient_state (self->origin);

return TRUE;
}
Expand Down
16 changes: 13 additions & 3 deletions src/libpriv/rpmostree-origin.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ rpmostree_origin_parse_keyfile (GKeyFile *origin,
ret->cached_overrides_remove =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);

/* NOTE hack here - see https://github.com/ostreedev/ostree/pull/343 */
g_key_file_remove_key (ret->kf, "origin", "unlocked", NULL);

ret->cached_unconfigured_state = g_key_file_get_string (ret->kf, "origin", "unconfigured-state", NULL);

g_autofree char *refspec = g_key_file_get_string (ret->kf, "origin", "refspec", NULL);
Expand Down Expand Up @@ -177,6 +174,19 @@ rpmostree_origin_dup (RpmOstreeOrigin *origin)
return ret;
}

void
rpmostree_origin_remove_transient_state (RpmOstreeOrigin *origin)
{
/* first libostree-known things */
ostree_deployment_origin_remove_transient_state (origin->kf);

/* this is already covered by the above, but the below also updates the cached value */
rpmostree_origin_set_override_commit (origin, NULL, NULL);

/* then rpm-ostree specific things */
rpmostree_origin_set_live_state (origin, NULL, NULL);
}

const char *
rpmostree_origin_get_refspec (RpmOstreeOrigin *origin)
{
Expand Down
3 changes: 3 additions & 0 deletions src/libpriv/rpmostree-origin.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ rpmostree_origin_parse_deployment (OstreeDeployment *deployment,
RpmOstreeOrigin *
rpmostree_origin_dup (RpmOstreeOrigin *origin);

void
rpmostree_origin_remove_transient_state (RpmOstreeOrigin *origin);

const char *
rpmostree_origin_get_refspec (RpmOstreeOrigin *origin);

Expand Down

0 comments on commit e9e9569

Please sign in to comment.