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;
|
glnx_unref_object OstreeSysroot *ot_sysroot = NULL;
|
||||||
g_autoptr(GCancellable) cancellable = g_cancellable_new ();
|
g_autoptr(GCancellable) cancellable = g_cancellable_new ();
|
||||||
g_autoptr(GVariantDict) dict = NULL;
|
|
||||||
const char *osname;
|
const char *osname;
|
||||||
gboolean reboot = FALSE;
|
|
||||||
GError *local_error = NULL;
|
GError *local_error = NULL;
|
||||||
|
|
||||||
/* try to merge with an existing transaction, otherwise start a new one */
|
/* 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);
|
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,
|
transaction = rpmostreed_transaction_new_initramfs_state (invocation,
|
||||||
ot_sysroot,
|
ot_sysroot,
|
||||||
osname,
|
osname,
|
||||||
regenerate,
|
regenerate,
|
||||||
(char**)args,
|
(char**)args,
|
||||||
reboot,
|
arg_options,
|
||||||
cancellable,
|
cancellable,
|
||||||
&local_error);
|
&local_error);
|
||||||
if (transaction == NULL)
|
if (transaction == NULL)
|
||||||
@ -1088,18 +1083,6 @@ out:
|
|||||||
|
|
||||||
return TRUE;
|
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
|
static gboolean
|
||||||
os_handle_kernel_args (RPMOSTreeOS *interface,
|
os_handle_kernel_args (RPMOSTreeOS *interface,
|
||||||
@ -1137,7 +1120,7 @@ os_handle_kernel_args (RPMOSTreeOS *interface,
|
|||||||
kernel_args_added,
|
kernel_args_added,
|
||||||
kernel_args_replaced,
|
kernel_args_replaced,
|
||||||
kernel_args_deleted,
|
kernel_args_deleted,
|
||||||
kernel_arg_flags_from_options (arg_options),
|
arg_options,
|
||||||
cancellable,
|
cancellable,
|
||||||
&local_error);
|
&local_error);
|
||||||
if (transaction == NULL)
|
if (transaction == NULL)
|
||||||
|
@ -41,6 +41,11 @@ vardict_lookup_bool (GVariantDict *dict,
|
|||||||
const char *key,
|
const char *key,
|
||||||
gboolean dfault);
|
gboolean dfault);
|
||||||
|
|
||||||
|
static void*
|
||||||
|
vardict_lookup_ptr (GVariantDict *dict,
|
||||||
|
const char *key,
|
||||||
|
const char *fmt);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
change_origin_refspec (GVariantDict *options,
|
change_origin_refspec (GVariantDict *options,
|
||||||
OstreeSysroot *sysroot,
|
OstreeSysroot *sysroot,
|
||||||
@ -1660,7 +1665,7 @@ typedef struct {
|
|||||||
char *osname;
|
char *osname;
|
||||||
gboolean regenerate;
|
gboolean regenerate;
|
||||||
char **args;
|
char **args;
|
||||||
gboolean reboot;
|
GVariantDict *options;
|
||||||
} InitramfsStateTransaction;
|
} InitramfsStateTransaction;
|
||||||
|
|
||||||
typedef RpmostreedTransactionClass InitramfsStateTransactionClass;
|
typedef RpmostreedTransactionClass InitramfsStateTransactionClass;
|
||||||
@ -1679,6 +1684,7 @@ initramfs_state_transaction_finalize (GObject *object)
|
|||||||
self = (InitramfsStateTransaction *) object;
|
self = (InitramfsStateTransaction *) object;
|
||||||
g_free (self->osname);
|
g_free (self->osname);
|
||||||
g_strfreev (self->args);
|
g_strfreev (self->args);
|
||||||
|
g_clear_pointer (&self->options, g_variant_dict_unref);
|
||||||
|
|
||||||
G_OBJECT_CLASS (initramfs_state_transaction_parent_class)->finalize (object);
|
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");
|
rpmostree_transaction_set_title ((RPMOSTreeTransaction*)self, "initramfs");
|
||||||
|
|
||||||
g_autoptr(RpmOstreeSysrootUpgrader) upgrader =
|
g_autoptr(RpmOstreeSysrootUpgrader) upgrader =
|
||||||
rpmostree_sysroot_upgrader_new (sysroot, self->osname, 0,
|
rpmostree_sysroot_upgrader_new (sysroot, self->osname, 0, cancellable, error);
|
||||||
cancellable, error);
|
|
||||||
if (upgrader == NULL)
|
if (upgrader == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -1724,7 +1729,7 @@ initramfs_state_transaction_execute (RpmostreedTransaction *transaction,
|
|||||||
if (!rpmostree_sysroot_upgrader_deploy (upgrader, NULL, cancellable, error))
|
if (!rpmostree_sysroot_upgrader_deploy (upgrader, NULL, cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (self->reboot)
|
if (vardict_lookup_bool (self->options, "reboot", FALSE))
|
||||||
rpmostreed_reboot (cancellable, error);
|
rpmostreed_reboot (cancellable, error);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1752,7 +1757,7 @@ rpmostreed_transaction_new_initramfs_state (GDBusMethodInvocation *invocation,
|
|||||||
const char *osname,
|
const char *osname,
|
||||||
gboolean regenerate,
|
gboolean regenerate,
|
||||||
char **args,
|
char **args,
|
||||||
gboolean reboot,
|
GVariant *options,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@ -1772,7 +1777,7 @@ rpmostreed_transaction_new_initramfs_state (GDBusMethodInvocation *invocation,
|
|||||||
self->osname = g_strdup (osname);
|
self->osname = g_strdup (osname);
|
||||||
self->regenerate = regenerate;
|
self->regenerate = regenerate;
|
||||||
self->args = g_strdupv (args);
|
self->args = g_strdupv (args);
|
||||||
self->reboot = reboot;
|
self->options = g_variant_dict_new (options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (RpmostreedTransaction *) self;
|
return (RpmostreedTransaction *) self;
|
||||||
@ -2213,7 +2218,7 @@ typedef struct {
|
|||||||
char **kernel_args_added;
|
char **kernel_args_added;
|
||||||
char **kernel_args_deleted;
|
char **kernel_args_deleted;
|
||||||
char **kernel_args_replaced;
|
char **kernel_args_replaced;
|
||||||
RpmOstreeTransactionKernelArgFlags flags;
|
GVariantDict *options;
|
||||||
} KernelArgTransaction;
|
} KernelArgTransaction;
|
||||||
|
|
||||||
typedef RpmostreedTransactionClass KernelArgTransactionClass;
|
typedef RpmostreedTransactionClass KernelArgTransactionClass;
|
||||||
@ -2235,6 +2240,7 @@ kernel_arg_transaction_finalize (GObject *object)
|
|||||||
g_strfreev (self->kernel_args_deleted);
|
g_strfreev (self->kernel_args_deleted);
|
||||||
g_strfreev (self->kernel_args_replaced);
|
g_strfreev (self->kernel_args_replaced);
|
||||||
g_free (self->existing_kernel_args);
|
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);
|
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 */
|
/* 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);
|
__attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = _ostree_kernel_args_from_string (self->existing_kernel_args);
|
||||||
g_autoptr(RpmOstreeSysrootUpgrader) upgrader =
|
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 */
|
/* We need the upgrader to perform the deployment */
|
||||||
if (upgrader == NULL)
|
if (upgrader == NULL)
|
||||||
@ -2293,7 +2300,8 @@ kernel_arg_transaction_execute (RpmostreedTransaction *transaction,
|
|||||||
if (!rpmostree_sysroot_upgrader_deploy_set_kargs (upgrader, kargs_strv,
|
if (!rpmostree_sysroot_upgrader_deploy_set_kargs (upgrader, kargs_strv,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (self->flags & RPMOSTREE_TRANSACTION_KERNEL_ARG_FLAG_REBOOT)
|
|
||||||
|
if (vardict_lookup_bool (self->options, "reboot", FALSE))
|
||||||
rpmostreed_reboot (cancellable, error);
|
rpmostreed_reboot (cancellable, error);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2323,7 +2331,7 @@ rpmostreed_transaction_new_kernel_arg (GDBusMethodInvocation *invocation,
|
|||||||
const char * const *kernel_args_added,
|
const char * const *kernel_args_added,
|
||||||
const char * const *kernel_args_replaced,
|
const char * const *kernel_args_replaced,
|
||||||
const char * const *kernel_args_deleted,
|
const char * const *kernel_args_deleted,
|
||||||
RpmOstreeTransactionKernelArgFlags flags,
|
GVariant *options,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
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_replaced = strdupv_canonicalize (kernel_args_replaced);
|
||||||
self->kernel_args_deleted = strdupv_canonicalize (kernel_args_deleted);
|
self->kernel_args_deleted = strdupv_canonicalize (kernel_args_deleted);
|
||||||
self->existing_kernel_args = g_strdup (existing_kernel_args);
|
self->existing_kernel_args = g_strdup (existing_kernel_args);
|
||||||
self->flags = flags;
|
self->options = g_variant_dict_new (options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (RpmostreedTransaction *) self;
|
return (RpmostreedTransaction *) self;
|
||||||
|
@ -75,7 +75,7 @@ rpmostreed_transaction_new_initramfs_state (GDBusMethodInvocation *invocat
|
|||||||
const char *osname,
|
const char *osname,
|
||||||
gboolean regenerate,
|
gboolean regenerate,
|
||||||
char **args,
|
char **args,
|
||||||
gboolean reboot,
|
GVariant *options,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
@ -127,10 +127,6 @@ rpmostreed_transaction_new_modify_yum_repo (GDBusMethodInvocation *invocation,
|
|||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
RPMOSTREE_TRANSACTION_KERNEL_ARG_FLAG_REBOOT = (1 << 0),
|
|
||||||
} RpmOstreeTransactionKernelArgFlags;
|
|
||||||
|
|
||||||
RpmostreedTransaction *
|
RpmostreedTransaction *
|
||||||
rpmostreed_transaction_new_kernel_arg (GDBusMethodInvocation *invocation,
|
rpmostreed_transaction_new_kernel_arg (GDBusMethodInvocation *invocation,
|
||||||
OstreeSysroot *sysroot,
|
OstreeSysroot *sysroot,
|
||||||
@ -139,7 +135,7 @@ rpmostreed_transaction_new_kernel_arg (GDBusMethodInvocation *invocation,
|
|||||||
const char * const *kernel_args_added,
|
const char * const *kernel_args_added,
|
||||||
const char * const *kernel_args_replaced,
|
const char * const *kernel_args_replaced,
|
||||||
const char * const *kernel_args_deleted,
|
const char * const *kernel_args_deleted,
|
||||||
RpmOstreeTransactionKernelArgFlags flags,
|
GVariant *options,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user