From 077d7c1a9e0f2643387225ec4965a9f483a692e7 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 11 Sep 2017 20:00:40 +0000 Subject: [PATCH] daemon/deploy: allow redeploying livefs booted commit Also something I noticed while working on #981. When sitting on a livefs commit, once a user does `rpm-ostree cleanup --pending --rollback`, it's impossible to redeploy the same booted commit. Let's allow users to do this. Closes: #984 Approved by: cgwalters --- src/daemon/rpmostreed-transaction-types.c | 18 +++++++++++++++++- tests/vmcheck/test-livefs.sh | 6 ++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/daemon/rpmostreed-transaction-types.c b/src/daemon/rpmostreed-transaction-types.c index 5773fc2bfa..e75215e9df 100644 --- a/src/daemon/rpmostreed-transaction-types.c +++ b/src/daemon/rpmostreed-transaction-types.c @@ -814,7 +814,23 @@ deploy_transaction_execute (RpmostreedTransaction *transaction, &base_changed, cancellable, error)) return FALSE; - changed = changed || base_changed; + if (base_changed) + changed = TRUE; + else + { + /* If we're on a live deployment, then allow redeploying a clean version of the + * same base commit. This is useful if e.g. the pushed rollback was cleaned up. */ + + OstreeDeployment *deployment = + rpmostree_sysroot_upgrader_get_merge_deployment (upgrader); + + gboolean is_live; + if (!rpmostree_syscore_deployment_is_live (sysroot, deployment, &is_live, error)) + return FALSE; + + if (is_live) + changed = TRUE; + } } /* let's figure out if those new overrides are valid and if so, canonicalize diff --git a/tests/vmcheck/test-livefs.sh b/tests/vmcheck/test-livefs.sh index ef961f7f23..e5948f3657 100755 --- a/tests/vmcheck/test-livefs.sh +++ b/tests/vmcheck/test-livefs.sh @@ -110,6 +110,12 @@ vm_cmd cat /etc/test-livefs-with-etc.conf > test-livefs-with-etc.conf assert_file_has_content test-livefs-with-etc.conf "custom" echo "ok livefs preserved modified config" +vm_rpmostree cleanup -p +# make sure there's no layering going on somehow +vm_assert_status_jq '.deployments[0]["base-checksum"]|not' +vm_rpmostree deploy $(vm_get_booted_deployment_info checksum) +echo "ok livefs redeploy booted commit" + reset vm_rpmostree install /tmp/vmcheck/yumrepo/packages/x86_64/foo-1.0-1.x86_64.rpm vm_rpmostree ex livefs