From 22529499728478b4079912b1b6b50dc7b16fe02b2328e6d9275a706200fb2eca Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Mon, 15 Aug 2016 04:10:39 +0000 Subject: [PATCH] Accepting request 418875 from home:michael-chang:branches:Base:System - Workaround default entry in snapshot menu (bsc#956046) * grub2-btrfs-08-workaround-snapshot-menu-default-entry.patch - grub2.spec: Add true command to grub.efi (bsc#993274) OBS-URL: https://build.opensuse.org/request/show/418875 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=226 --- ...rkaround-snapshot-menu-default-entry.patch | 58 +++++++++++++++++++ grub2.changes | 7 +++ grub2.spec | 4 +- 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 grub2-btrfs-08-workaround-snapshot-menu-default-entry.patch diff --git a/grub2-btrfs-08-workaround-snapshot-menu-default-entry.patch b/grub2-btrfs-08-workaround-snapshot-menu-default-entry.patch new file mode 100644 index 0000000..5b8c62f --- /dev/null +++ b/grub2-btrfs-08-workaround-snapshot-menu-default-entry.patch @@ -0,0 +1,58 @@ +Index: grub-2.02~beta2/grub-core/normal/menu.c +=================================================================== +--- grub-2.02~beta2.orig/grub-core/normal/menu.c ++++ grub-2.02~beta2/grub-core/normal/menu.c +@@ -575,6 +575,44 @@ print_countdown (struct grub_term_coordi + grub_refresh (); + } + ++/* bsc#956046 - The first entry titled 'Bootable snapshot #$NUM' is inserted on ++ top at runtime to display current snapshot information. If default entry is ++ using number as key to index the entry, the result will be shifted so here we ++ add specical handling to shift it back. We apply this workaround until a better ++ solution can be found. */ ++static void ++workaround_snapshot_menu_default_entry (grub_menu_t menu, const char *name, int *default_entry) ++{ ++ grub_menu_entry_t entry; ++ ++ if ((entry = grub_menu_get_entry (menu, 0)) ++ && entry->submenu ++ && grub_strncmp (entry->title, "Bootable snapshot", sizeof("Bootable snapshot") - 1) == 0) ++ { ++ const char *val; ++ ++ if (*default_entry == -1 && menu->size > 1) ++ { ++ *default_entry = 1; ++ return; ++ } ++ ++ val = grub_env_get (name); ++ ++ grub_error_push (); ++ ++ if (val) ++ grub_strtoul (val, 0, 0); ++ ++ if (*default_entry < (menu->size - 1) && grub_errno == GRUB_ERR_NONE) ++ ++(*default_entry); ++ ++ grub_error_pop (); ++ } ++ ++ return; ++} ++ + #define GRUB_MENU_PAGE_SIZE 10 + + /* Show the menu and handle menu entry selection. Returns the menu entry +@@ -593,6 +631,8 @@ run_menu (grub_menu_t menu, int nested, + + default_entry = get_entry_number (menu, "default"); + ++ workaround_snapshot_menu_default_entry (menu, "default", &default_entry); ++ + /* If DEFAULT_ENTRY is not within the menu entries, fall back to + the first entry. */ + if (default_entry < 0 || default_entry >= menu->size) diff --git a/grub2.changes b/grub2.changes index 56428b5..f5525e2 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Aug 12 08:32:05 UTC 2016 - mchang@suse.com + +- Workaround default entry in snapshot menu (bsc#956046) + * grub2-btrfs-08-workaround-snapshot-menu-default-entry.patch +- grub2.spec: Add true command to grub.efi (bsc#993274) + ------------------------------------------------------------------- Wed Aug 3 04:45:51 UTC 2016 - mchang@suse.com diff --git a/grub2.spec b/grub2.spec index fe6d0aa..ac40069 100644 --- a/grub2.spec +++ b/grub2.spec @@ -193,6 +193,7 @@ Patch104: grub2-btrfs-04-grub2-install.patch Patch105: grub2-btrfs-05-grub2-mkconfig.patch Patch106: grub2-btrfs-06-subvol-mount.patch Patch107: grub2-btrfs-07-subvol-fallback.patch +Patch108: grub2-btrfs-08-workaround-snapshot-menu-default-entry.patch # Support EFI xen loader Patch120: grub2-efi-xen-chainload.patch Patch121: grub2-efi-chainloader-root.patch @@ -430,6 +431,7 @@ swap partition while in resuming %patch105 -p1 %patch106 -p1 %patch107 -p1 +%patch108 -p1 %patch120 -p1 %patch121 -p1 %patch122 -p1 @@ -527,7 +529,7 @@ make %{?_smp_mflags} #TODO: add efifwsetup module FS_MODULES="ext2 btrfs ext2 xfs jfs reiserfs" -CD_MODULES=" all_video boot cat chain configfile echo \ +CD_MODULES=" all_video boot cat chain configfile echo true \ efinet font gfxmenu gfxterm gzio halt iso9660 \ jpeg minicmd normal part_apple part_msdos part_gpt \ password_pbkdf2 png reboot search search_fs_uuid \