daemon: Carry option GVariant into transaction type
Rather than using flags, use the new approach of just carrying the GVariant from the D-Bus message all the way to inside the transaction type. Closes: #1816 Approved by: cgwalters
This commit is contained in:
parent
6334aebca1
commit
97bb57d7a7
@ -1036,9 +1036,7 @@ os_handle_set_initramfs_state (RPMOSTreeOS *interface,
|
||||
{
|
||||
glnx_unref_object OstreeSysroot *ot_sysroot = NULL;
|
||||
g_autoptr(GCancellable) cancellable = g_cancellable_new ();
|
||||
g_autoptr(GVariantDict) dict = NULL;
|
||||
const char *osname;
|
||||
gboolean reboot = FALSE;
|
||||
GError *local_error = NULL;
|
||||
|
||||
/* try to merge with an existing transaction, otherwise start a new one */
|
||||
@ -1058,15 +1056,12 @@ os_handle_set_initramfs_state (RPMOSTreeOS *interface,
|
||||
|
||||
osname = rpmostree_os_get_name (interface);
|
||||
|
||||
dict = g_variant_dict_new (arg_options);
|
||||
g_variant_dict_lookup (dict, "reboot", "b", &reboot);
|
||||
|
||||
transaction = rpmostreed_transaction_new_initramfs_state (invocation,
|
||||
ot_sysroot,
|
||||
osname,
|
||||
regenerate,
|
||||
(char**)args,
|
||||
reboot,
|
||||
arg_options,
|
||||
cancellable,
|
||||
&local_error);
|
||||
if (transaction == NULL)
|
||||
@ -1088,18 +1083,6 @@ out:
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
static RpmOstreeTransactionKernelArgFlags
|
||||
kernel_arg_flags_from_options (GVariant *options)
|
||||
{
|
||||
RpmOstreeTransactionKernelArgFlags ret = 0;
|
||||
g_auto(GVariantDict) dict;
|
||||
g_variant_dict_init (&dict, options);
|
||||
|
||||
if (vardict_lookup_bool (&dict, "reboot", FALSE))
|
||||
ret |= RPMOSTREE_TRANSACTION_KERNEL_ARG_FLAG_REBOOT;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
os_handle_kernel_args (RPMOSTreeOS *interface,
|
||||
@ -1137,7 +1120,7 @@ os_handle_kernel_args (RPMOSTreeOS *interface,
|
||||
kernel_args_added,
|
||||
kernel_args_replaced,
|
||||
kernel_args_deleted,
|
||||
kernel_arg_flags_from_options (arg_options),
|
||||
arg_options,
|
||||
cancellable,
|
||||
&local_error);
|
||||
if (transaction == NULL)
|
||||
|
@ -41,6 +41,11 @@ vardict_lookup_bool (GVariantDict *dict,
|
||||
const char *key,
|
||||
gboolean dfault);
|
||||
|
||||
static void*
|
||||
vardict_lookup_ptr (GVariantDict *dict,
|
||||
const char *key,
|
||||
const char *fmt);
|
||||
|
||||
static gboolean
|
||||
change_origin_refspec (GVariantDict *options,
|
||||
OstreeSysroot *sysroot,
|
||||
@ -1660,7 +1665,7 @@ typedef struct {
|
||||
char *osname;
|
||||
gboolean regenerate;
|
||||
char **args;
|
||||
gboolean reboot;
|
||||
GVariantDict *options;
|
||||
} InitramfsStateTransaction;
|
||||
|
||||
typedef RpmostreedTransactionClass InitramfsStateTransactionClass;
|
||||
@ -1679,6 +1684,7 @@ initramfs_state_transaction_finalize (GObject *object)
|
||||
self = (InitramfsStateTransaction *) object;
|
||||
g_free (self->osname);
|
||||
g_strfreev (self->args);
|
||||
g_clear_pointer (&self->options, g_variant_dict_unref);
|
||||
|
||||
G_OBJECT_CLASS (initramfs_state_transaction_parent_class)->finalize (object);
|
||||
}
|
||||
@ -1695,8 +1701,7 @@ initramfs_state_transaction_execute (RpmostreedTransaction *transaction,
|
||||
rpmostree_transaction_set_title ((RPMOSTreeTransaction*)self, "initramfs");
|
||||
|
||||
g_autoptr(RpmOstreeSysrootUpgrader) upgrader =
|
||||
rpmostree_sysroot_upgrader_new (sysroot, self->osname, 0,
|
||||
cancellable, error);
|
||||
rpmostree_sysroot_upgrader_new (sysroot, self->osname, 0, cancellable, error);
|
||||
if (upgrader == NULL)
|
||||
return FALSE;
|
||||
|
||||
@ -1724,7 +1729,7 @@ initramfs_state_transaction_execute (RpmostreedTransaction *transaction,
|
||||
if (!rpmostree_sysroot_upgrader_deploy (upgrader, NULL, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (self->reboot)
|
||||
if (vardict_lookup_bool (self->options, "reboot", FALSE))
|
||||
rpmostreed_reboot (cancellable, error);
|
||||
|
||||
return TRUE;
|
||||
@ -1748,13 +1753,13 @@ initramfs_state_transaction_init (InitramfsStateTransaction *self)
|
||||
|
||||
RpmostreedTransaction *
|
||||
rpmostreed_transaction_new_initramfs_state (GDBusMethodInvocation *invocation,
|
||||
OstreeSysroot *sysroot,
|
||||
const char *osname,
|
||||
gboolean regenerate,
|
||||
char **args,
|
||||
gboolean reboot,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
OstreeSysroot *sysroot,
|
||||
const char *osname,
|
||||
gboolean regenerate,
|
||||
char **args,
|
||||
GVariant *options,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
InitramfsStateTransaction *self;
|
||||
|
||||
@ -1772,7 +1777,7 @@ rpmostreed_transaction_new_initramfs_state (GDBusMethodInvocation *invocation,
|
||||
self->osname = g_strdup (osname);
|
||||
self->regenerate = regenerate;
|
||||
self->args = g_strdupv (args);
|
||||
self->reboot = reboot;
|
||||
self->options = g_variant_dict_new (options);
|
||||
}
|
||||
|
||||
return (RpmostreedTransaction *) self;
|
||||
@ -2213,7 +2218,7 @@ typedef struct {
|
||||
char **kernel_args_added;
|
||||
char **kernel_args_deleted;
|
||||
char **kernel_args_replaced;
|
||||
RpmOstreeTransactionKernelArgFlags flags;
|
||||
GVariantDict *options;
|
||||
} KernelArgTransaction;
|
||||
|
||||
typedef RpmostreedTransactionClass KernelArgTransactionClass;
|
||||
@ -2235,6 +2240,7 @@ kernel_arg_transaction_finalize (GObject *object)
|
||||
g_strfreev (self->kernel_args_deleted);
|
||||
g_strfreev (self->kernel_args_replaced);
|
||||
g_free (self->existing_kernel_args);
|
||||
g_clear_pointer (&self->options, g_variant_dict_unref);
|
||||
G_OBJECT_CLASS (kernel_arg_transaction_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@ -2256,7 +2262,8 @@ kernel_arg_transaction_execute (RpmostreedTransaction *transaction,
|
||||
/* Read in the existing kernel args and convert those to an #OstreeKernelArg instance for API usage */
|
||||
__attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = _ostree_kernel_args_from_string (self->existing_kernel_args);
|
||||
g_autoptr(RpmOstreeSysrootUpgrader) upgrader =
|
||||
rpmostree_sysroot_upgrader_new (sysroot, self->osname, upgrader_flags, cancellable, error);
|
||||
rpmostree_sysroot_upgrader_new (sysroot, self->osname, upgrader_flags,
|
||||
cancellable, error);
|
||||
|
||||
/* We need the upgrader to perform the deployment */
|
||||
if (upgrader == NULL)
|
||||
@ -2293,7 +2300,8 @@ kernel_arg_transaction_execute (RpmostreedTransaction *transaction,
|
||||
if (!rpmostree_sysroot_upgrader_deploy_set_kargs (upgrader, kargs_strv,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
if (self->flags & RPMOSTREE_TRANSACTION_KERNEL_ARG_FLAG_REBOOT)
|
||||
|
||||
if (vardict_lookup_bool (self->options, "reboot", FALSE))
|
||||
rpmostreed_reboot (cancellable, error);
|
||||
|
||||
return TRUE;
|
||||
@ -2323,7 +2331,7 @@ rpmostreed_transaction_new_kernel_arg (GDBusMethodInvocation *invocation,
|
||||
const char * const *kernel_args_added,
|
||||
const char * const *kernel_args_replaced,
|
||||
const char * const *kernel_args_deleted,
|
||||
RpmOstreeTransactionKernelArgFlags flags,
|
||||
GVariant *options,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
@ -2345,7 +2353,7 @@ rpmostreed_transaction_new_kernel_arg (GDBusMethodInvocation *invocation,
|
||||
self->kernel_args_replaced = strdupv_canonicalize (kernel_args_replaced);
|
||||
self->kernel_args_deleted = strdupv_canonicalize (kernel_args_deleted);
|
||||
self->existing_kernel_args = g_strdup (existing_kernel_args);
|
||||
self->flags = flags;
|
||||
self->options = g_variant_dict_new (options);
|
||||
}
|
||||
|
||||
return (RpmostreedTransaction *) self;
|
||||
|
@ -75,7 +75,7 @@ rpmostreed_transaction_new_initramfs_state (GDBusMethodInvocation *invocat
|
||||
const char *osname,
|
||||
gboolean regenerate,
|
||||
char **args,
|
||||
gboolean reboot,
|
||||
GVariant *options,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
@ -127,10 +127,6 @@ rpmostreed_transaction_new_modify_yum_repo (GDBusMethodInvocation *invocation,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
typedef enum {
|
||||
RPMOSTREE_TRANSACTION_KERNEL_ARG_FLAG_REBOOT = (1 << 0),
|
||||
} RpmOstreeTransactionKernelArgFlags;
|
||||
|
||||
RpmostreedTransaction *
|
||||
rpmostreed_transaction_new_kernel_arg (GDBusMethodInvocation *invocation,
|
||||
OstreeSysroot *sysroot,
|
||||
@ -139,7 +135,7 @@ rpmostreed_transaction_new_kernel_arg (GDBusMethodInvocation *invocation,
|
||||
const char * const *kernel_args_added,
|
||||
const char * const *kernel_args_replaced,
|
||||
const char * const *kernel_args_deleted,
|
||||
RpmOstreeTransactionKernelArgFlags flags,
|
||||
GVariant *options,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user