Skip to content

Commit

Permalink
fix: ensure update boot configuration for each deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohuiw42 committed Oct 23, 2024
1 parent 9fa9a0f commit 3424ac9
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions debian/patches/deepin-use-custom-grub-message.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c
index cbe7605..2015bf5 100644
--- a/src/libostree/ostree-bootloader-grub2.c
+++ b/src/libostree/ostree-bootloader-grub2.c
Index: ostree/src/libostree/ostree-bootloader-grub2.c
===================================================================
--- ostree.orig/src/libostree/ostree-bootloader-grub2.c
+++ ostree/src/libostree/ostree-bootloader-grub2.c
@@ -25,6 +25,8 @@
#include <sys/mount.h>

Expand All @@ -11,7 +11,7 @@ index cbe7605..2015bf5 100644

// Written by bootupd
#define BOOTUPD_CONFIG "boot/bootupd-state.json"
@@ -166,6 +168,67 @@ _ostree_bootloader_grub2_get_name (OstreeBootloader *bootloader)
@@ -166,6 +168,71 @@ _ostree_bootloader_grub2_get_name (Ostre
return "grub2";
}

Expand Down Expand Up @@ -43,7 +43,11 @@ index cbe7605..2015bf5 100644
+{
+ GPtrArray *deployments = sysroot->deployments;
+
+ if (index >= deployments->len)
+ /* Check if the index exceeds the deployment array length, allowing one extra
+ * index if 'stage_deploy_time' is true.
+ * For the first time to boot, index could be 1 even if there's only one deployment.
+ */
+ if (index >= deployments->len + (stage_deploy_time ? 1 : 0))
+ return title;
+
+ g_autofree char *deploy_time = NULL;
Expand Down Expand Up @@ -79,23 +83,23 @@ index cbe7605..2015bf5 100644
/* This implementation is quite complex; see this issue for
* a starting point:
* https://github.com/ostreedev/ostree/issues/717
@@ -180,6 +243,7 @@ _ostree_bootloader_grub2_generate_config (OstreeSysroot *sysroot, int bootversio
@@ -181,6 +248,7 @@ _ostree_bootloader_grub2_generate_config
static const char hardcoded_insmods[] = "insmod gzio\n";
const char *grub2_boot_device_id = g_getenv ("GRUB2_BOOT_DEVICE_ID");
const char *grub2_prepare_root_cache = g_getenv ("GRUB2_PREPARE_ROOT_CACHE");
+ const char *stage_deploy_time = g_getenv ("OSTREE_STAGE_DEPLOY_TIME");

/* We must have been called via the wrapper script */
g_assert (grub2_boot_device_id != NULL);
@@ -214,6 +278,7 @@ _ostree_bootloader_grub2_generate_config (OstreeSysroot *sysroot, int bootversio
@@ -216,6 +284,7 @@ _ostree_bootloader_grub2_generate_config

kernel = ostree_bootconfig_parser_get (config, "linux");

+ title = ostree_update_grub_boot_message(sysroot, stage_deploy_time, title, i);
quoted_title = g_shell_quote (title);
uuid = g_strdup_printf ("ostree-%u-%s", (guint)i, grub2_boot_device_id);
quoted_uuid = g_shell_quote (uuid);
@@ -285,6 +350,8 @@ typedef struct
@@ -289,6 +358,8 @@ typedef struct
{
const char *root;
const char *bootversion_str;
Expand All @@ -104,7 +108,7 @@ index cbe7605..2015bf5 100644
gboolean is_efi;
} Grub2ChildSetupData;

@@ -299,6 +366,8 @@ grub2_child_setup (gpointer user_data)
@@ -303,6 +374,8 @@ grub2_child_setup (gpointer user_data)
if (cdata->is_efi)
setenv ("_OSTREE_GRUB2_IS_EFI", "1", TRUE);

Expand All @@ -113,7 +117,7 @@ index cbe7605..2015bf5 100644
/* Everything below this is dealing with the chroot case; if
* we're not doing that, return early.
*/
@@ -425,6 +494,11 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader, int bootver
@@ -429,6 +502,11 @@ _ostree_bootloader_grub2_write_config (O
g_autofree char *bootversion_str = g_strdup_printf ("%u", (guint)bootversion);
cdata.bootversion_str = bootversion_str;
cdata.is_efi = self->is_efi;
Expand All @@ -125,3 +129,19 @@ index cbe7605..2015bf5 100644
/* Note in older versions of the grub2 package, this script doesn't even try
to be atomic; it just does:

Index: ostree/src/libostree/ostree-sysroot-deploy.c
===================================================================
--- ostree.orig/src/libostree/ostree-sysroot-deploy.c
+++ ostree/src/libostree/ostree-sysroot-deploy.c
@@ -3009,7 +3009,10 @@ ostree_sysroot_write_deployments_with_op
};
g_autoptr (OstreeBootloader) bootloader = NULL;
g_autofree char *new_subbootdir = NULL;
- if (!requires_new_bootversion)
+ /* we need to touch the bootloader configuration for each deployment to update
+ * the grub time stamp.
+ */
+ if (/*!requires_new_bootversion*/FALSE)
{
if (!create_new_bootlinks (self, self->bootversion, new_deployments, cancellable, error))
return FALSE;

0 comments on commit 3424ac9

Please sign in to comment.