From 583f49fa4138cfcd54e5073df408308b02530631 Mon Sep 17 00:00:00 2001 From: Rafael Fonseca Date: Mon, 27 Jan 2020 13:30:20 +0100 Subject: [PATCH] fixup! deploy: Keep last deployment version during stage Check also booted and merge deployments --- src/libostree/ostree-sysroot.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c index 71cf634668..b4af635562 100644 --- a/src/libostree/ostree-sysroot.c +++ b/src/libostree/ostree-sysroot.c @@ -1745,13 +1745,27 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot, /* tracks current versioned deployment */ OstreeRepo *repo = ostree_sysroot_repo (sysroot); - const gchar *last_version = + const gchar *new_version = _ostree_deployment_get_version (new_deployment, repo, error); + gboolean retained_previous_version = FALSE; + if (booted_deployment) + { + const gchar *booted_version = + _ostree_deployment_get_version (booted_deployment, repo, error); + retained_previous_version = (g_strcmp0 (booted_deployment, new_version) != 0); + } + + if (!retained_previous_version && merge_deployment) + { + const gchar *merge_version = + _ostree_deployment_get_version (merge_deployment, repo, error); + retained_previous_version = (g_strcmp0 (merge_deployment, new_version) != 0); + } + /* tracks when we come across the booted deployment */ gboolean before_booted = TRUE; gboolean before_merge = TRUE; - gboolean retained_previous_version = FALSE; for (guint i = 0; i < deployments->len; i++) { OstreeDeployment *deployment = deployments->pdata[i]; @@ -1773,7 +1787,7 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot, if (passed_crossover && osname_matches && !retained_previous_version) { const gchar *version = _ostree_deployment_get_version (deployment, repo, error); - is_previous_version = version && (!last_version || (g_strcmp0 (version, last_version) < 0)); + is_previous_version = (g_strcmp0 (version, new_version) != 0); } /* Retain deployment if: