daemon/kargs: Fix handling of staged deployments
When handling `GetDeploymentBootConfig()`, we would trip an assertion when trying to read the full bootconfig from a staged deployment, which of course doesn't have a full bootconfig yet. Rework this to add a new `staged` key to the returned dict, in which case only `options` is included. (Which is all `rpm-ostree kargs` needs anyway). Closes: #1708 Approved by: cgwalters
This commit is contained in:
parent
770e6e72e1
commit
b104a289f7
@ -1162,11 +1162,19 @@ os_handle_get_deployment_boot_config (RPMOSTreeOS *interface,
|
|||||||
/* We initalize a dictionary and put key/value pair in bootconfig into it */
|
/* We initalize a dictionary and put key/value pair in bootconfig into it */
|
||||||
g_variant_dict_init (&boot_config_dict, NULL);
|
g_variant_dict_init (&boot_config_dict, NULL);
|
||||||
|
|
||||||
|
gboolean staged = ostree_deployment_is_staged (target_deployment);
|
||||||
|
g_variant_dict_insert (&boot_config_dict, "staged", "b", staged);
|
||||||
|
|
||||||
/* We loop through the key and add each key/value pair value into the variant dict */
|
/* We loop through the key and add each key/value pair value into the variant dict */
|
||||||
for (char **iter = (char **)bootconfig_keys; iter && *iter; iter++)
|
for (char **iter = (char **)bootconfig_keys; iter && *iter; iter++)
|
||||||
{
|
{
|
||||||
const char *key = *iter;
|
const char *key = *iter;
|
||||||
|
/* We can only populate "options" in the staged path. */
|
||||||
|
if (staged && !g_str_equal (key, "options"))
|
||||||
|
continue;
|
||||||
|
|
||||||
const char *value = ostree_bootconfig_parser_get (bootconfig, key);
|
const char *value = ostree_bootconfig_parser_get (bootconfig, key);
|
||||||
|
g_assert (value);
|
||||||
|
|
||||||
g_variant_dict_insert (&boot_config_dict, key, "s", value);
|
g_variant_dict_insert (&boot_config_dict, key, "s", value);
|
||||||
}
|
}
|
||||||
|
@ -116,11 +116,15 @@ echo "ok import kargs from current deployment"
|
|||||||
vm_rpmostree kargs --append=PACKAGE=TEST
|
vm_rpmostree kargs --append=PACKAGE=TEST
|
||||||
vm_build_rpm foo
|
vm_build_rpm foo
|
||||||
vm_rpmostree install foo
|
vm_rpmostree install foo
|
||||||
|
vm_pending_is_staged # this is default now, but just being explicit
|
||||||
|
vm_rpmostree kargs --append=PACKAGE2=TEST2
|
||||||
vm_reboot
|
vm_reboot
|
||||||
|
|
||||||
vm_cmd grep ^options /boot/loader/entries/ostree-2-$osname.conf > kargs.txt
|
vm_cmd grep ^options /boot/loader/entries/ostree-2-$osname.conf > kargs.txt
|
||||||
assert_file_has_content_literal kargs.txt 'PACKAGE=TEST'
|
assert_file_has_content_literal kargs.txt 'PACKAGE=TEST'
|
||||||
|
assert_file_has_content_literal kargs.txt 'PACKAGE2=TEST2'
|
||||||
echo "ok kargs with multiple operations"
|
echo "ok kargs with multiple operations"
|
||||||
vm_rpmostree kargs > kargs.txt
|
vm_rpmostree kargs > kargs.txt
|
||||||
assert_file_has_content_literal kargs.txt 'PACKAGE=TEST'
|
assert_file_has_content_literal kargs.txt 'PACKAGE=TEST'
|
||||||
|
assert_file_has_content_literal kargs.txt 'PACKAGE2=TEST2'
|
||||||
echo "ok kargs display with multiple operations"
|
echo "ok kargs display with multiple operations"
|
||||||
|
Loading…
Reference in New Issue
Block a user