Skip to content

Commit

Permalink
fix: support GRUB_SAVEDEFAULT config in grub
Browse files Browse the repository at this point in the history
  • Loading branch information
ssk-wh committed Oct 8, 2024
1 parent 4becf6b commit 348c238
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
ostree (2024.6-1deepin3) unstable; urgency=medium

* use last boot as default if GRUB_SAVEDEFAULT set in grub

-- ssk-wh <[email protected]> Tue, 08 Oct 2024 14:33:59 +0800

ostree (2024.6-1deepin2) unstable; urgency=medium

* curl: Make socket callback during cleanup into no-op.
Expand Down
43 changes: 43 additions & 0 deletions debian/patches/deepin-save-last-boot-as-defalt-for-grub.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Index: ostree-fork-from-deepin/src/boot/grub2/grub2-15_ostree
===================================================================
--- ostree-fork-from-deepin.orig/src/boot/grub2/grub2-15_ostree
+++ ostree-fork-from-deepin/src/boot/grub2/grub2-15_ostree
@@ -62,4 +62,9 @@ export GRUB2_BOOT_DEVICE_ID
GRUB2_PREPARE_ROOT_CACHE="$(prepare_grub_to_access_device ${DEVICE})"
export GRUB2_PREPARE_ROOT_CACHE

+if [ "x${GRUB_SAVEDEFAULT}" = "xtrue" ] ; then
+ OSTREE_SAVEDEFAULT='true'
+ export OSTREE_SAVEDEFAULT
+fi
+
exec ostree admin instutil grub2-generate
Index: ostree-fork-from-deepin/src/libostree/ostree-bootloader-grub2.c
===================================================================
--- ostree-fork-from-deepin.orig/src/libostree/ostree-bootloader-grub2.c
+++ ostree-fork-from-deepin/src/libostree/ostree-bootloader-grub2.c
@@ -177,6 +177,7 @@ _ostree_bootloader_grub2_generate_config
/* So... yeah. Just going to hardcode these. */
static const char hardcoded_video[] = "load_video\n"
"set gfxpayload=keep\n";
+ static const char hardcoded_savedefault[] = "savedefault\n";
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");
@@ -187,6 +188,7 @@ _ostree_bootloader_grub2_generate_config

/* Passed from the parent */
gboolean is_efi = g_getenv ("_OSTREE_GRUB2_IS_EFI") != NULL;
+ gboolean savedefault = g_getenv ("OSTREE_SAVEDEFAULT") != NULL;

g_autoptr (GOutputStream) out_stream = g_unix_output_stream_new (target_fd, FALSE);

@@ -226,6 +228,8 @@ _ostree_bootloader_grub2_generate_config

/* Hardcoded sections */
g_string_append (output, hardcoded_video);
+ if (savedefault)
+ g_string_append (output, hardcoded_savedefault);
g_string_append (output, hardcoded_insmods);
g_string_append (output, grub2_prepare_root_cache);
g_string_append_c (output, '\n');
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ debian/test-sysroot-Skip-on-s390x-by-default.patch
debian/Skip-test-admin-deploy-uboot.sh-on-s390x.patch
deepin-deploy-when-root-is-overlay.patch
make-socket-callback-during-cleanup-into.patch
deepin-save-last-boot-as-defalt-for-grub.patch

0 comments on commit 348c238

Please sign in to comment.