libostree: Add initial GRUB2 support
In this approach, we drop a /etc/grub.d/15_ostree file which is a hybrid of shell/C that picks up bits from the GRUB2 library (e.g. the block device script generation), and then calls into libostree's GRUB2 code which knows about the BLS entries. This is admittedly ugly. There exists another approach for GRUB2 to learn the BLS specification. However, the spec has a few issues: https://www.redhat.com/archives/anaconda-devel-list/2014-July/msg00002.html This approach also gives a bit more control to the admin via the naming of the 15_ostree symlink; they can easily disable it: Or reorder the ostree entries ahead of 10_linux: Also, this approach doesn't require patches for grub2, which is an issue with the pressure to backport (rpm-)OSTree to EL7.
This commit is contained in:
1 parent
92c5a9f992
commit
d546abfa2a
19 files changed
+639
-11
No files matched your search
@@ -1004,6 +1004,8 @@ get_kernel_from_tree (GFile *deployroot,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
gs_unref_object GFile *ostree_bootdir
|
||||
= g_file_resolve_relative_path (deployroot, "usr/lib/ostree-boot");
|
||||
gs_unref_object GFile *bootdir = g_file_get_child (deployroot, "boot");
|
||||
gs_unref_object GFileEnumerator *dir_enum = NULL;
|
||||
gs_unref_object GFile *ret_kernel = NULL;
|
||||
@@ -1011,11 +1013,22 @@ get_kernel_from_tree (GFile *deployroot,
|
||||
gs_free char *kernel_checksum = NULL;
|
||||
gs_free char *initramfs_checksum = NULL;
|
||||
|
||||
dir_enum = g_file_enumerate_children (bootdir, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL, error);
|
||||
if (!dir_enum)
|
||||
goto out;
|
||||
if (g_file_query_exists (ostree_bootdir, NULL))
|
||||
{
|
||||
dir_enum = g_file_enumerate_children (ostree_bootdir, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL, error);
|
||||
if (!dir_enum)
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
dir_enum = g_file_enumerate_children (bootdir, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL, error);
|
||||
if (!dir_enum)
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
@@ -1510,6 +1523,7 @@ ostree_sysroot_write_deployments (OstreeSysroot *self,
|
||||
guint i;
|
||||
gboolean requires_new_bootversion = FALSE;
|
||||
gboolean found_booted_deployment = FALSE;
|
||||
gboolean bootloader_is_atomic = FALSE;
|
||||
|
||||
g_assert (self->loaded);
|
||||
|
||||
@@ -1578,6 +1592,8 @@ ostree_sysroot_write_deployments (OstreeSysroot *self,
|
||||
g_prefix_error (error, "Swapping current bootlinks: ");
|
||||
goto out;
|
||||
}
|
||||
|
||||
bootloader_is_atomic = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1615,11 +1631,17 @@ ostree_sysroot_write_deployments (OstreeSysroot *self,
|
||||
g_debug ("Using bootloader: %s", bootloader ?
|
||||
g_type_name (G_TYPE_FROM_INSTANCE (bootloader)) : "(none)");
|
||||
|
||||
if (bootloader && !_ostree_bootloader_write_config (bootloader, new_bootversion,
|
||||
cancellable, error))
|
||||
if (bootloader)
|
||||
bootloader_is_atomic = _ostree_bootloader_is_atomic (bootloader);
|
||||
|
||||
if (bootloader)
|
||||
{
|
||||
g_prefix_error (error, "Bootloader write config: ");
|
||||
goto out;
|
||||
if (!_ostree_bootloader_write_config (bootloader, new_bootversion,
|
||||
cancellable, error))
|
||||
{
|
||||
g_prefix_error (error, "Bootloader write config: ");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (!full_system_sync (cancellable, error))
|
||||
@@ -1627,7 +1649,7 @@ ostree_sysroot_write_deployments (OstreeSysroot *self,
|
||||
g_prefix_error (error, "Full sync: ");
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
if (!swap_bootloader (self, self->bootversion, new_bootversion,
|
||||
cancellable, error))
|
||||
{
|
||||
@@ -1637,7 +1659,8 @@ ostree_sysroot_write_deployments (OstreeSysroot *self,
|
||||
}
|
||||
|
||||
gs_log_structured_print_id_v (OSTREE_DEPLOYMENT_COMPLETE_ID,
|
||||
"Transaction complete; bootconfig swap: %s deployment count change: %i)",
|
||||
"%s; bootconfig swap: %s deployment count change: %i",
|
||||
(bootloader_is_atomic ? "Transaction complete" : "Bootloader updated"),
|
||||
requires_new_bootversion ? "yes" : "no",
|
||||
new_deployments->len - self->deployments->len);
|
||||
|
||||
|
||||
Reference in new issue
Block a user