From e9e956981b42f20b72c4ee292f4c79257714c186 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Tue, 22 May 2018 15:20:33 -0400 Subject: [PATCH] daemon/upgrader: Consistently remove transient state 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: https://github.com/ostreedev/ostree/issues/1595 --- src/daemon/rpmostree-sysroot-upgrader.c | 6 ++---- src/libpriv/rpmostree-origin.c | 16 +++++++++++++--- src/libpriv/rpmostree-origin.h | 3 +++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/daemon/rpmostree-sysroot-upgrader.c b/src/daemon/rpmostree-sysroot-upgrader.c index 721b5d7716..bf123222dd 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.c +++ b/src/daemon/rpmostree-sysroot-upgrader.c @@ -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; } diff --git a/src/libpriv/rpmostree-origin.c b/src/libpriv/rpmostree-origin.c index 16c298b862..30f42c7029 100644 --- a/src/libpriv/rpmostree-origin.c +++ b/src/libpriv/rpmostree-origin.c @@ -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); @@ -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) { diff --git a/src/libpriv/rpmostree-origin.h b/src/libpriv/rpmostree-origin.h index 2ad99e630e..c64d140f3d 100644 --- a/src/libpriv/rpmostree-origin.h +++ b/src/libpriv/rpmostree-origin.h @@ -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);