diff options
author | Colin Walters <walters@verbum.org> | 2013-09-16 09:13:58 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2013-09-16 18:32:13 -0400 |
commit | 8f1ea1b50aad70f671b8a2902f4b68771cce8682 (patch) | |
tree | 8934b8aa6e8a34ddb0ce3ac729e8dda694d41ace /src/ostree/ot-admin-builtin-undeploy.c | |
parent | c07c84cb6f17d2c709897188c2f7e46164636c30 (diff) | |
download | ostree-8f1ea1b50aad70f671b8a2902f4b68771cce8682.tar.gz |
sysroot: Clean up API
Now that we have a real GObject for the sysroot, we have a convenient
place to keep track of 4 pieces of state:
* The current deployment list
* The current bootversion
* The current subbootversion
* The current booted deployment (if any)
Avoid requiring callers to pass all of this around and load it
piecemeal; instead the new thing is ostree_sysroot_load().
Diffstat (limited to 'src/ostree/ot-admin-builtin-undeploy.c')
-rw-r--r-- | src/ostree/ot-admin-builtin-undeploy.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/ostree/ot-admin-builtin-undeploy.c b/src/ostree/ot-admin-builtin-undeploy.c index 1de2a6c2..055209db 100644 --- a/src/ostree/ot-admin-builtin-undeploy.c +++ b/src/ostree/ot-admin-builtin-undeploy.c @@ -38,7 +38,6 @@ ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCance GOptionContext *context; const char *deploy_index_str; int deploy_index; - int current_bootversion; gs_unref_ptrarray GPtrArray *current_deployments = NULL; gs_unref_object OstreeDeployment *booted_deployment = NULL; gs_unref_object OstreeDeployment *target_deployment = NULL; @@ -56,20 +55,13 @@ ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCance goto out; } + if (!ostree_sysroot_load (sysroot, cancellable, error)) + goto out; + current_deployments = ostree_sysroot_get_deployments (sysroot); + deploy_index_str = argv[1]; deploy_index = atoi (deploy_index_str); - if (!ostree_sysroot_list_deployments (sysroot, ¤t_bootversion, ¤t_deployments, - cancellable, error)) - { - g_prefix_error (error, "While listing deployments: "); - goto out; - } - - if (!ostree_sysroot_find_booted_deployment (sysroot, current_deployments, &booted_deployment, - cancellable, error)) - goto out; - if (deploy_index < 0) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, @@ -84,7 +76,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCance } target_deployment = g_object_ref (current_deployments->pdata[deploy_index]); - if (target_deployment == booted_deployment) + if (target_deployment == ostree_sysroot_get_booted_deployment (sysroot)) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Cannot undeploy currently booted deployment %i", deploy_index); @@ -93,8 +85,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCance g_ptr_array_remove_index (current_deployments, deploy_index); - if (!ostree_sysroot_write_deployments (sysroot, current_bootversion, - current_bootversion ? 0 : 1, current_deployments, + if (!ostree_sysroot_write_deployments (sysroot, current_deployments, cancellable, error)) goto out; |