diff options
author | Colin Walters <walters@verbum.org> | 2018-04-12 12:40:08 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-04-18 18:59:15 +0000 |
commit | 16d3359bf8827f6a6d70aa313c6e7f16a4f2e277 (patch) | |
tree | 3dfdec5cd93ae88865e7431362be4336cd987b46 /src/libostree/ostree-sysroot.c | |
parent | 09dc2a87724111e83249b42dd4c4faa5dd2c2840 (diff) | |
download | ostree-16d3359bf8827f6a6d70aa313c6e7f16a4f2e277.tar.gz |
lib/sysroot: Move staged into deployment list, rework handling
Followup to: https://github.com/ostreedev/ostree/pull/1503
After starting some more work on on this in rpm-ostree, it is
actually simpler if the staged deployment just shows up in the list.
It's effectively opt-in today; down the line we may make it the default,
but I worry about breaking things that e.g. assume they can mutate
the deployment before rebooting and have `/etc` already merged.
There's not that many things in libostree that iterate over the deployment
list. The biggest change here is around the
`ostree_sysroot_write_deployments_with_options` API. I initially
tried hard to support a use case like "push a rollback" while retaining
the staged deployment, but everything gets very messy because that
function truly is operating on the bootloader list.
For now what I settled on is to just discard the staged deployment;
down the line we can enhance things.
Where we then have some new gymnastics is around implementing
the finalization; we need to go to some effort to pull the staged
deployment out of the list and mark it as unstaged, and then pass
it down to `write_deployments()`.
Closes: #1539
Approved by: jlebon
Diffstat (limited to 'src/libostree/ostree-sysroot.c')
-rw-r--r-- | src/libostree/ostree-sysroot.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c index 51d51340..f59f1508 100644 --- a/src/libostree/ostree-sysroot.c +++ b/src/libostree/ostree-sysroot.c @@ -740,6 +740,15 @@ compare_deployments_by_boot_loader_version_reversed (gconstpointer a_pp, OstreeBootconfigParser *a_bootconfig = ostree_deployment_get_bootconfig (a); OstreeBootconfigParser *b_bootconfig = ostree_deployment_get_bootconfig (b); + /* Staged deployments are always first */ + if (ostree_deployment_is_staged (a)) + { + g_assert (!ostree_deployment_is_staged (b)); + return -1; + } + else if (ostree_deployment_is_staged (b)) + return 1; + return compare_boot_loader_configs (a_bootconfig, b_bootconfig); } @@ -824,11 +833,16 @@ _ostree_sysroot_reload_staged (OstreeSysroot *self, g_variant_dict_lookup (staged_deployment_dict, "kargs", "^a&s", &kargs); if (target) { - self->staged_deployment = + g_autoptr(OstreeDeployment) staged = _ostree_sysroot_deserialize_deployment_from_variant (target, error); - if (!self->staged_deployment) + if (!staged) return FALSE; - _ostree_deployment_set_bootconfig_from_kargs (self->staged_deployment, kargs); + + _ostree_deployment_set_bootconfig_from_kargs (staged, kargs); + if (!load_origin (self, staged, NULL, error)) + return FALSE; + + self->staged_deployment = g_steal_pointer (&staged); self->staged_deployment_data = g_steal_pointer (&staged_deployment_data); /* We set this flag for ostree_deployment_is_staged() because that API * doesn't have access to the sysroot, which currently has the @@ -938,8 +952,16 @@ ostree_sysroot_load_if_changed (OstreeSysroot *self, if (root_is_ostree_booted && !self->booted_deployment) return glnx_throw (error, "Unexpected state: /run/ostree-booted found and in / sysroot but not in a booted deployment"); + if (!_ostree_sysroot_reload_staged (self, error)) + return FALSE; + /* Ensure the entires are sorted */ g_ptr_array_sort (deployments, compare_deployments_by_boot_loader_version_reversed); + + /* Staged shows up first */ + if (self->staged_deployment) + g_ptr_array_insert (deployments, 0, g_object_ref (self->staged_deployment)); + /* And then set their index variables */ for (guint i = 0; i < deployments->len; i++) { @@ -947,9 +969,6 @@ ostree_sysroot_load_if_changed (OstreeSysroot *self, ostree_deployment_set_index (deployment, i); } - if (!_ostree_sysroot_reload_staged (self, error)) - return FALSE; - /* Determine whether we're "physical" or not, the first time we initialize */ if (!self->loaded) { |