initramfs: Print regeneration status for pending deployment
Previously, after enabling initramfs regeneration, the initramfs command would indicate that initramfs regeneratin is disabled, suggesting that the initramfs had not actually been enabled. This happened because the initramfs regeneration status for the current deployment was printed; initramfs regeneration is only enabled for a pending deployment. This change prints the regeneration for the pending deployment, rather than the current, when no options are given to the initramfs command. Fixes: #1526 Closes: #1548 Approved by: jlebon
This commit is contained in:
parent
bce966a981
commit
be7d87e4b9
@ -85,8 +85,9 @@ rpmostree_builtin_initramfs (int argc,
|
||||
|
||||
if (!(opt_enable || opt_disable))
|
||||
{
|
||||
GVariantIter iter;
|
||||
g_autoptr(GVariant) deployments = rpmostree_sysroot_dup_deployments (sysroot_proxy);
|
||||
gboolean cur_regenerate = FALSE;
|
||||
g_autofree char **initramfs_args = NULL;
|
||||
|
||||
if (opt_reboot)
|
||||
{
|
||||
@ -95,41 +96,27 @@ rpmostree_builtin_initramfs (int argc,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_variant_iter_init (&iter, deployments);
|
||||
|
||||
while (TRUE)
|
||||
if (g_variant_n_children (deployments) > 1)
|
||||
{
|
||||
gboolean cur_regenerate;
|
||||
g_autoptr(GVariant) child = g_variant_iter_next_value (&iter);
|
||||
g_autoptr(GVariantDict) dict = NULL;
|
||||
g_autofree char **initramfs_args = NULL;
|
||||
gboolean is_booted;
|
||||
g_autoptr(GVariant) pending = g_variant_get_child_value (deployments, 0);
|
||||
g_auto(GVariantDict) dict;
|
||||
g_variant_dict_init (&dict, pending);
|
||||
|
||||
if (child == NULL)
|
||||
break;
|
||||
|
||||
dict = g_variant_dict_new (child);
|
||||
|
||||
if (!g_variant_dict_lookup (dict, "booted", "b", &is_booted))
|
||||
continue;
|
||||
if (!is_booted)
|
||||
continue;
|
||||
|
||||
if (!g_variant_dict_lookup (dict, "regenerate-initramfs", "b", &cur_regenerate))
|
||||
if (!g_variant_dict_lookup (&dict, "regenerate-initramfs", "b", &cur_regenerate))
|
||||
cur_regenerate = FALSE;
|
||||
if (cur_regenerate)
|
||||
{
|
||||
g_variant_dict_lookup (dict, "initramfs-args", "^a&s", &initramfs_args);
|
||||
g_variant_dict_lookup (&dict, "initramfs-args", "^a&s", &initramfs_args);
|
||||
}
|
||||
}
|
||||
|
||||
g_print ("Initramfs regeneration: %s\n", cur_regenerate ? "enabled" : "disabled");
|
||||
if (initramfs_args)
|
||||
{
|
||||
g_print ("Initramfs args: ");
|
||||
for (char **iter = initramfs_args; iter && *iter; iter++)
|
||||
g_print ("%s ", *iter);
|
||||
g_print ("\n");
|
||||
}
|
||||
g_print ("Initramfs regeneration: %s\n", cur_regenerate ? "enabled" : "disabled");
|
||||
if (initramfs_args)
|
||||
{
|
||||
g_print ("Initramfs args: ");
|
||||
for (char **iter = initramfs_args; iter && *iter; iter++)
|
||||
g_print ("%s ", *iter);
|
||||
g_print ("\n");
|
||||
}
|
||||
}
|
||||
else if (opt_enable && opt_disable)
|
||||
|
@ -42,7 +42,11 @@ fi
|
||||
assert_file_has_content err.txt "reboot.*used with.*enable"
|
||||
echo "ok initramfs state"
|
||||
|
||||
vm_rpmostree initramfs --enable
|
||||
vm_rpmostree initramfs --enable > initramfs.txt
|
||||
assert_file_has_content initramfs.txt "Initramfs regeneration.*enabled"
|
||||
vm_rpmostree initramfs > initramfs.txt
|
||||
assert_file_has_content initramfs.txt "Initramfs regeneration.*enabled"
|
||||
|
||||
vm_assert_status_jq \
|
||||
'.deployments[1].booted' \
|
||||
'.deployments[0]["regenerate-initramfs"]' \
|
||||
@ -64,7 +68,11 @@ fi
|
||||
assert_file_has_content err.txt "already.*enabled"
|
||||
echo "ok initramfs enabled"
|
||||
|
||||
vm_rpmostree initramfs --disable
|
||||
vm_rpmostree initramfs --disable > initramfs.txt
|
||||
assert_file_has_content initramfs.txt "Initramfs regeneration.*disabled"
|
||||
vm_rpmostree initramfs > initramfs.txt
|
||||
assert_file_has_content initramfs.txt "Initramfs regeneration.*disabled"
|
||||
|
||||
vm_reboot
|
||||
vm_assert_status_jq \
|
||||
'.deployments[0].booted' \
|
||||
|
Loading…
Reference in New Issue
Block a user