lib/deploy: Clean up kargs override handling

Tighten up how we handle kargs here so it's more clear. When we call
`sysroot_finalize_deployment`, any karg overrides have already been set
on the bootconfig object of the deployment. So re-setting it here is
redundant and confusing.
This commit is contained in:
Jonathan Lebon 2020-08-17 09:48:09 -04:00
parent 83bb09ae33
commit 52a6224606

View File

@ -2770,7 +2770,6 @@ get_var_dfd (OstreeSysroot *self,
static gboolean
sysroot_finalize_deployment (OstreeSysroot *self,
OstreeDeployment *deployment,
char **override_kernel_argv,
OstreeDeployment *merge_deployment,
GCancellable *cancellable,
GError **error)
@ -2780,15 +2779,18 @@ sysroot_finalize_deployment (OstreeSysroot *self,
if (!glnx_opendirat (self->sysroot_fd, deployment_path, TRUE, &deployment_dfd, error))
return FALSE;
/* Only use the merge if we didn't get an override */
if (!override_kernel_argv && merge_deployment)
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (deployment);
/* If the kargs weren't set yet, then just pick it up from the merge deployment. In the
* deploy path, overrides are set as part of sysroot_initialize_deployment(). In the
* finalize-staged path, they're set by OstreeSysroot when reading the staged GVariant. */
if (merge_deployment && ostree_bootconfig_parser_get (bootconfig, "options") == NULL)
{
/* Override the bootloader arguments */
OstreeBootconfigParser *merge_bootconfig = ostree_deployment_get_bootconfig (merge_deployment);
if (merge_bootconfig)
{
const char *opts = ostree_bootconfig_parser_get (merge_bootconfig, "options");
ostree_bootconfig_parser_set (ostree_deployment_get_bootconfig (deployment), "options", opts);
const char *kargs = ostree_bootconfig_parser_get (merge_bootconfig, "options");
ostree_bootconfig_parser_set (bootconfig, "options", kargs);
}
}
@ -2882,8 +2884,7 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
&deployment, cancellable, error))
return FALSE;
if (!sysroot_finalize_deployment (self, deployment, override_kernel_argv,
provided_merge_deployment,
if (!sysroot_finalize_deployment (self, deployment, provided_merge_deployment,
cancellable, error))
return FALSE;
@ -3149,8 +3150,6 @@ _ostree_sysroot_finalize_staged (OstreeSysroot *self,
ostree_deployment_get_csum (merge_deployment_stub),
ostree_deployment_get_deployserial (merge_deployment_stub));
}
g_autofree char **kargs = NULL;
g_variant_lookup (self->staged_deployment_data, "kargs", "^a&s", &kargs);
/* Unlink the staged state now; if we're interrupted in the middle,
* we don't want e.g. deal with the partially written /etc merge.
@ -3158,7 +3157,7 @@ _ostree_sysroot_finalize_staged (OstreeSysroot *self,
if (!glnx_unlinkat (AT_FDCWD, _OSTREE_SYSROOT_RUNSTATE_STAGED, 0, error))
return FALSE;
if (!sysroot_finalize_deployment (self, self->staged_deployment, kargs, merge_deployment,
if (!sysroot_finalize_deployment (self, self->staged_deployment, merge_deployment,
cancellable, error))
return FALSE;