[ostree/wip/grub2-efi: 2/3] wip



commit 6c53d2c5449a5b44ee9ee61f0ec5c1798f4121dd
Author: Colin Walters <walters verbum org>
Date:   Fri Oct 17 18:59:30 2014 -0400

    wip

 src/libostree/ostree-bootloader-grub2.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c
index becfeb7..02a9a9f 100644
--- a/src/libostree/ostree-bootloader-grub2.c
+++ b/src/libostree/ostree-bootloader-grub2.c
@@ -50,13 +50,23 @@ static gboolean
 _ostree_bootloader_grub2_query (OstreeBootloader *bootloader)
 {
   OstreeBootloaderGrub2 *self = OSTREE_BOOTLOADER_GRUB2 (bootloader);
+  gs_unref_object GFile *marker_parent = NULL;
+  gs_unref_object GFileInfo *file_info = NULL;
 
   if (g_file_query_exists (self->config_path_bios, NULL))
     return TRUE;
 
-  if (g_file_query_exists (self->config_path_efi_marker, NULL))
+  marker_parent = g_file_get_parent (self->config_path_efi_marker);
+  if (!ot_gfile_query_info_allow_noent (self->config_path_efi_marker, "standard::symlink-target",
+                                        G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                                        &file_info, cancellable, error))
+    goto out;
+
+  if (file_info)
     {
+      const char *target = g_file_info_get_symlink_target (file_info);
       self->is_efi = TRUE;
+      self->config_path_efi_dest = g_file_resolve_relative_path (marker_parent, target);
       return TRUE;
     }
 
@@ -186,14 +196,23 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader      *bootloader,
 {
   OstreeBootloaderGrub2 *self = OSTREE_BOOTLOADER_GRUB2 (bootloader);
   gboolean ret = FALSE;
+  gs_unref_object GFile *efi_new_config_temp = NULL;
   gs_unref_object GFile *new_config_path = NULL;
   gs_unref_object GSSubprocessContext *procctx = NULL;
   gs_unref_object GSSubprocess *proc = NULL;
   gs_strfreev char **child_env = g_get_environ ();
   gs_free char *bootversion_str = g_strdup_printf ("%u", (guint)bootversion);
 
-  new_config_path = ot_gfile_resolve_path_printf (self->sysroot->path, "boot/loader.%d/grub.cfg",
-                                                  bootversion);
+  if (self->is_efi)
+    {
+      new_config_path = ot_gfile_resolve_path_printf (self->sysroot->path, "boot/loader.%d/grub.cfg",
+                                                      bootversion);
+    }
+  else
+    {
+      new_config_path = ot_gfile_resolve_path_printf (self->sysroot->path, "boot/loader.%d/grub.cfg",
+                                                      bootversion);
+    }
 
   procctx = gs_subprocess_context_newv ("grub2-mkconfig", "-o",
                                         gs_file_get_path_cached (new_config_path),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]