diff --git a/src/daemon/rpmostreed-os.c b/src/daemon/rpmostreed-os.c index 8778247d..a62abb98 100644 --- a/src/daemon/rpmostreed-os.c +++ b/src/daemon/rpmostreed-os.c @@ -703,6 +703,7 @@ out: return TRUE; } +/* This is an older variant of Cleanup, kept for backcompat */ static gboolean os_handle_clear_rollback_target (RPMOSTreeOS *interface, GDBusMethodInvocation *invocation, @@ -712,9 +713,8 @@ os_handle_clear_rollback_target (RPMOSTreeOS *interface, glnx_unref_object RpmostreedTransaction *transaction = NULL; glnx_unref_object OstreeSysroot *ot_sysroot = NULL; g_autoptr(GCancellable) cancellable = g_cancellable_new (); + RpmOstreeTransactionCleanupFlags flags = 0; const char *osname; - gboolean opt_reboot = FALSE; - GVariantDict options_dict; GError *local_error = NULL; transaction = merge_compatible_txn (self, invocation); @@ -722,29 +722,19 @@ os_handle_clear_rollback_target (RPMOSTreeOS *interface, goto out; if (!rpmostreed_sysroot_load_state (rpmostreed_sysroot_get (), - cancellable, - &ot_sysroot, - NULL, - &local_error)) + cancellable, &ot_sysroot, NULL, &local_error)) goto out; - g_variant_dict_init (&options_dict, arg_options); - - g_variant_dict_lookup (&options_dict, - "reboot", "b", - &opt_reboot); - - g_variant_dict_clear (&options_dict); - osname = rpmostree_os_get_name (interface); - transaction = rpmostreed_transaction_new_clear_rollback (invocation, - ot_sysroot, - osname, - opt_reboot, - cancellable, - &local_error); + /* Note - intentionally ignoring the reboot option since I don't + * know why anyone would want that. + */ + flags = RPMOSTREE_TRANSACTION_CLEANUP_ROLLBACK_DEPLOY; + transaction = rpmostreed_transaction_new_cleanup (invocation, ot_sysroot, + osname, flags, + cancellable, &local_error); if (transaction == NULL) goto out; @@ -761,7 +751,6 @@ out: client_address = rpmostreed_transaction_get_client_address (transaction); rpmostree_os_complete_clear_rollback_target (interface, invocation, client_address); } - return TRUE; } diff --git a/src/daemon/rpmostreed-transaction-types.c b/src/daemon/rpmostreed-transaction-types.c index d512529f..9980da34 100644 --- a/src/daemon/rpmostreed-transaction-types.c +++ b/src/daemon/rpmostreed-transaction-types.c @@ -446,125 +446,6 @@ rpmostreed_transaction_new_rollback (GDBusMethodInvocation *invocation, return (RpmostreedTransaction *) self; } -/* ============================ Clear Rollback ============================ */ - -typedef struct { - RpmostreedTransaction parent; - char *osname; - gboolean reboot; -} ClearRollbackTransaction; - -typedef RpmostreedTransactionClass ClearRollbackTransactionClass; - -GType clear_rollback_transaction_get_type (void); - -G_DEFINE_TYPE (ClearRollbackTransaction, - clear_rollback_transaction, - RPMOSTREED_TYPE_TRANSACTION) - -static void -clear_rollback_transaction_finalize (GObject *object) -{ - ClearRollbackTransaction *self; - - self = (ClearRollbackTransaction *) object; - g_free (self->osname); - - G_OBJECT_CLASS (clear_rollback_transaction_parent_class)->finalize (object); -} - -static gboolean -clear_rollback_transaction_execute (RpmostreedTransaction *transaction, - GCancellable *cancellable, - GError **error) -{ - ClearRollbackTransaction *self; - OstreeSysroot *sysroot; - - g_autoptr(GPtrArray) deployments = NULL; - gint rollback_index; - gboolean ret = FALSE; - - self = (ClearRollbackTransaction *) transaction; - - sysroot = rpmostreed_transaction_get_sysroot (transaction); - - rollback_index = rpmostreed_rollback_deployment_index (self->osname, sysroot, error); - if (rollback_index < 0) - goto out; - - deployments = ostree_sysroot_get_deployments (sysroot); - - if (deployments->pdata[rollback_index] == ostree_sysroot_get_booted_deployment (sysroot)) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, - "Cannot undeploy currently booted deployment %i", - rollback_index); - goto out; - } - - g_ptr_array_remove_index (deployments, rollback_index); - - if (!ostree_sysroot_write_deployments (sysroot, - deployments, - cancellable, - error)) - goto out; - - if (self->reboot) - rpmostreed_reboot (cancellable, error); - - ret = TRUE; - -out: - return ret; -} - -static void -clear_rollback_transaction_class_init (ClearRollbackTransactionClass *class) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (class); - object_class->finalize = clear_rollback_transaction_finalize; - - class->execute = clear_rollback_transaction_execute; -} - -static void -clear_rollback_transaction_init (ClearRollbackTransaction *self) -{ -} - -RpmostreedTransaction * -rpmostreed_transaction_new_clear_rollback (GDBusMethodInvocation *invocation, - OstreeSysroot *sysroot, - const char *osname, - gboolean reboot, - GCancellable *cancellable, - GError **error) -{ - ClearRollbackTransaction *self; - - g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), NULL); - g_return_val_if_fail (OSTREE_IS_SYSROOT (sysroot), NULL); - g_return_val_if_fail (osname != NULL, NULL); - - self = g_initable_new (clear_rollback_transaction_get_type (), - cancellable, error, - "invocation", invocation, - "sysroot-path", gs_file_get_path_cached (ostree_sysroot_get_path (sysroot)), - NULL); - - if (self != NULL) - { - self->osname = g_strdup (osname); - self->reboot = reboot; - } - - return (RpmostreedTransaction *) self; -} - /* ================================ Upgrade/Deploy/Rebase ================================ */ typedef struct {